roadmkt

byrohit kumar

Build a complete, responsive, server-less Sales Canvassing and Lead Tracker web application (named "Road MKT") integrated with Supabase (PostgreSQL) as the backend. The application features a custom, dense, utilitarian design system (Outfit & Inter fonts, dark/light theme options, minimal 4px border-radius, flat container panels with no box-shadows, and high contrast layout elements). Ensure the output matches the following specifications for database schema, logic layer, and page views: ========================================= 1. DATABASE & STORAGE ARCHITECTURE ========================================= The database uses Supabase PostgreSQL, but utilizes a "flexible schema" pattern where Firestore-style collections are represented as tables. Each table must have: - `id` (TEXT PRIMARY KEY) representing the document ID. - `data` (JSONB) containing all document fields. - `created_at` and `updated_at` (TIMESTAMPTZ) handling timestamps automatically. Recreate the following tables: - `users`: Stores user profile data. Fields inside `data`: `role` ('super', 'admin', 'user'), `email`, `warehouseId`, `pinColor`, `needsPasswordSetup` (boolean). (No plaintext passwords must be stored). - `visits`: The core lead-tracking table. Fields inside `data`: `biz` (business name), `rep` (username), `date` (MM/DD/YYYY), `comments`, `leads` (status), `lat` (latitude), `lng` (longitude), `warehouseId`, `followup` (Yes/No), `postal`, `addr`, `city`, `phone`, `email`. - `pending_users`: Stores registration requests before admin approval. Fields: `pass` (plaintext temporary password), `warehouseId`, `role`, `requestedAt`. - `settings`: Application configuration settings (e.g. `sheetAccess` configurations, form config, cycle info). - `configs`: Custom per-warehouse settings (e.g. table columns). - `activity_logs`: Audit trail for user operations (e.g. logouts, logins, visit saving). - `lockouts`: Tracks failed sign-in attempts by username. ========================================= 2. CLIENT-SIDE SUPABASE COMPATIBILITY LAYER ========================================= Write a compatibility script (`lib/supabase.js`) that wraps the Supabase JS SDK client to expose a Firestore-compatible interface. This allows the application logic to call Firestore-like APIs. Recreate: - `db.collection(name)`: returns a CollectionReference. - `CollectionReference.doc(id)`: returns a DocRef. - `DocRef.get()`: fetches document, returns DocSnapshot with `.id`, `.exists`, `.data()`, and `.ref`. - `DocRef.set(data, { merge: true })`: upserts document. If merge is true, reads existing JSONB data, merges new fields, and writes back. - `DocRef.update(data)`: updates specific JSONB fields. - `DocRef.delete()`: deletes the row by id. - `CollectionReference.add(data)`: generates a custom 20-character alphanumeric ID, inserts a new row, and returns a DocRef. - `db.batch()`: returns a WriteBatch containing `.set()`, `.update()`, and `.delete()`. `.commit()` runs all batch operations concurrently. - Queries chaining: `.where(field, op, value)`, `.orderBy(field, direction)`, and `.limit(n)`. - Server-side Filtering & Pagination: Re-map where conditions to Supabase queries using Postgres JSONB containment (`data->>field`). Implement pagination (page looping by calling `.range(offset, offset + limit)`) to automatically fetch all matching records, bypassing PostgREST's 1,000-row limit. - Re-map Firebase Auth calls: `firebase.auth().signInWithEmailAndPassword(email, password)` maps to `supabase.auth.signInWithPassword`. `firebase.auth().signOut()` maps to `supabase.auth.signOut`. ========================================= 3. PAGE LAYOUTS & USER INTERFACES ========================================= --- A. LOGIN & REGISTRATION HUB (login.html) --- Create a clean, responsive login page utilizing a split-pane layout: - Left pane (desktop only): Features a dark cover graphic representing Costco, overlayed with a brand badge ("Road MKT") and a checklist of core features (Live Geolocation, Secure Auth, Performance Dashboards). - Right pane (or centered full width on mobile): Holds a secure sign-in card. - User ID input accepts usernames or email addresses. If username is inputted, automatically append a generic email suffix (e.g. `@yourdomain.com`) behind the scenes to authenticate. - Support 6-character password constraint check: If the password is shorter than 6 characters, automatically pad it with trailing zeroes (e.g. '123' -> '123000') during authentication calls to comply with Supabase restrictions. - Contains links that switch to a "Request Account" registration form, saving requests to `pending_users`. --- B. DESKTOP WORKSPACE PORTAL (index.html & app.js) --- Create a multi-pane control room for sales reps and admins: - Header: Displays "Road MKT Portal", active user role badge, and user name menu. - Sidebar Navigation: Allows navigating between Map, Log List, Analytics, and Admin Settings. - Interactive Map View: Employs Google Maps JS API. Draws active pins representing visits. Each pin must have: - Rep-specific color coding. - Interactive InfoWindow showing business name, rep name, comment, date, status, and an admin-only "Delete Visit" button. - Sidebar Log List: Dense list of visits for the rep's warehouse with search, filtering, and "Pencil" Edit / "Trash" Delete buttons. - Quick Log Form Modal: Input fields for logging new canvassing visits (Business, Specific Industry, Status, Comments, Follow-up date/reason, Address, City, Postal Code, Phone, Email). Auto-geocodes addresses via Google Maps Geocoder or falls back to browser's getCurrentPosition. - Deletion Logic: Clicking delete prompts confirmation. Upon confirmation, locates the record by ID (resolving local timestamp vs database key) and deletes it from both memory and the Supabase backend. --- C. MOBILE COMPACT PORTAL (mobile.html) --- A compact, touch-optimized page designed for sales reps on the go: - Dense single-column interface fitting mobile status bars with safe-area insets. - Navigation bar with quick buttons: Toggle Map view vs List view, Log New Visit, User Profile, Sync Status (offline indicator). - Bottom bottom-sheet for quick logs and history checks. - Incorporates location watcher to continuously display the rep's current position and automatically pre-fill lat/lng coordinates. --- D. ADMIN CONTROL DASHBOARD (dashboard.html & analytics.html) --- - User Approvals Tab: Lists pending user requests from `pending_users`. Clicking "Approve" registers the user in Supabase Auth via admin tools and creates their profile in the `users` table, then deletes the request. Clicking "Deny" deletes the request. - Excel Databases Tab: Allows importing database records by uploading `.xlsx` files (parsed client-side and upserted in batches), and includes database clear functions ("Clear Firefly Data", "Clear Custom Locations"). - Analytics Dashboard: Embedded visual reports (charts showing visits by rep, visits by city, top-performing warehouses, status breakdowns). Make sure the logic is cleanly separated, all references to Firebase libraries are completely removed and replaced with Supabase SDK, and the code contains NO hardcoded credentials.

Landing
Landing

Comments (0)

No comments yet. Be the first!

System Requirements

System Requirement Document
Page 1 of 5

System Requirements Document for Road MKT

Introduction

The purpose of this document is to outline the system requirements for the "Road MKT" project, a responsive, server-less Sales Canvassing and Lead Tracker web application. The application will be integrated with Supabase (PostgreSQL) as the backend and will feature a custom, dense, utilitarian design system.

System Overview

Road MKT is designed to facilitate sales canvassing and lead tracking through a web application that leverages Supabase for its backend. The application will support a flexible schema database, a compatibility layer mimicking Firestore APIs, and distinct user interfaces for various user roles and devices.

Page 2 of 5

Functional Requirements as Story Points

  • As a User, I should be able to log in using either a username or email address.
  • As a User, I should be able to request an account through a registration form.
  • As an Admin, I should be able to approve or deny user registration requests.
  • As a Sales Rep, I should be able to log new canvassing visits with geolocation data.
  • As a Sales Rep, I should be able to view and interact with a map displaying visit locations.
  • As an Admin, I should be able to manage user roles and permissions.
  • As a User, I should be able to view analytics and reports on sales activities.
  • As a User, I should be able to switch between dark and light themes.
  • As a User, I should be able to view and edit my profile information.
  • As an Admin, I should be able to import and clear database records via Excel files.

User Personas

  • Admin: Responsible for managing user accounts, approving registrations, and overseeing the overall functionality of the application.
  • Sales Rep: Engages in canvassing activities, logs visits, and interacts with the map and log list.
  • User: General user who can view reports, manage their profile, and switch between themes.

Core User Flows

  • User logs in -> accesses dashboard -> views map and logs visits.
  • Admin reviews pending user requests -> approves or denies requests -> manages user roles.
  • Sales Rep logs a new visit -> inputs business details -> geolocation data is auto-filled -> visit is saved.
  • User accesses analytics -> views reports on sales activities.
Page 3 of 5

Visuals Colors and Theme

  • primary: #1E3A8A (Deep Blue)
  • primary_light: #3B82F6 (Light Blue)
  • secondary: #F59E0B (Amber)
  • accent: #EF4444 (Red)
  • highlight: #FBBF24 (Gold)
  • bg: #F3F4F6 (Light Gray)
  • surface: rgba(255, 255, 255, 0.8)
  • text: #111827 (Dark Gray)
  • text_muted: #6B7280 (Muted Gray)
  • border: rgba(209, 213, 219, 0.2)
Page 4 of 5

Signature Design Concept

Interactive Map Interface: The homepage will feature an interactive map that serves as the central hub for sales reps. Using the Google Maps JS API, the map will display dynamic pins representing each visit. Each pin will be color-coded based on the sales rep and will include interactive InfoWindows that provide detailed visit information. Users can click on pins to view or edit visit details, and admins can delete visits directly from the map. The map will be responsive and will adjust to different screen sizes, providing a seamless experience across devices.

Landing Hero Motion Brief: The landing page will feature a dynamic animation where a map of a city is gradually populated with pins representing sales visits. As the user scrolls, the map zooms in to show more detail, and pins animate into place, highlighting the active engagement of sales reps. This animation will loop every 10 seconds, providing a continuous visual narrative of the sales process. The animation will be built using motion/react for smooth transitions and interactions.

Interaction Model & Motion Direction

  • Intended Interaction Model: Animated
  • The landing page will feature moderate scroll-triggered reveals and hover transitions, providing a polished and engaging user experience. Interactive elements will utilize spring physics for a responsive feel.

Non-Functional Requirements

  • The application must be responsive and accessible on both desktop and mobile devices.
  • The system should ensure secure authentication and authorization processes.
  • The application should support real-time data synchronization with Supabase.
Page 5 of 5

Tech Stack

  • Frontend: React for Web
  • Backend: Supabase (PostgreSQL)
  • Database: Supabase PostgreSQL
  • Mapping: Google Maps JS API

Assumptions and Constraints

  • The application will be server-less and rely on Supabase for backend services.
  • All Firebase references will be replaced with Supabase SDK.
  • The application will not store plaintext passwords.

Glossary

  • Supabase: An open-source Firebase alternative that provides backend services.
  • Firestore: A NoSQL document database built for automatic scaling, high performance, and ease of application development.
  • JSONB: A binary representation of JSON data in PostgreSQL.
  • Geolocation: The identification of the real-world geographic location of an object.

This document outlines the comprehensive requirements for the Road MKT project, ensuring a robust and user-friendly application for sales canvassing and lead tracking.

Landing design preview
Login: Sign In
Dashboard: View Approvals
Dashboard: Approve User
Dashboard: Deny Request
Dashboard: Manage Roles
Dashboard: Import Excel
Dashboard: Clear Data
Map: View Visits
Map: Delete Visit
Analytics: View Reports
Settings: Configure App
Profile: Edit Profile
Settings: Switch Theme
Landing design preview
Login: Sign In
Dashboard: View Approvals
Dashboard: Approve User
Dashboard: Deny Request
Dashboard: Manage Roles
Dashboard: Import Excel
Dashboard: Clear Data
Map: View Visits
Map: Delete Visit
Analytics: View Reports
Settings: Configure App
Profile: Edit Profile
Settings: Switch Theme