Skip to content

Dispatch-AI-com/frontend

Repository files navigation

Frontend Service - DispatchAI Platform

Next.js 15 Web Application providing the user interface for managing AI-powered service dispatch, bookings, and customer interactions.

🎯 Overview

The Frontend is a modern React application built with Next.js 15, Material-UI, and TypeScript, delivering a comprehensive dashboard for managing services, viewing call logs, scheduling appointments, and configuring AI settings.

πŸ—οΈ Architecture

Tech Stack

  • Framework: Next.js 15 (App Router)
  • UI Library: Material-UI (MUI) v6
  • Styling: Emotion (CSS-in-JS), Styled Components
  • State Management: Redux Toolkit + RTK Query
  • Form Handling: React Hook Form + Zod validation
  • Date Management: date-fns, dayjs, react-big-calendar
  • HTTP Client: Axios
  • Charts: MUI X Charts
  • Language: TypeScript 5.8

Project Structure

apps/frontend/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/                        # Next.js App Router
β”‚   β”‚   β”œβ”€β”€ (public)/              # Public pages
β”‚   β”‚   β”‚   β”œβ”€β”€ landing/          # Landing page
β”‚   β”‚   β”‚   β”œβ”€β”€ features/         # Features page
β”‚   β”‚   β”‚   β”œβ”€β”€ products/         # Products page
β”‚   β”‚   β”‚   β”œβ”€β”€ blogs/            # Blog listing & detail
β”‚   β”‚   β”‚   β”œβ”€β”€ pricing/          # Pricing page
β”‚   β”‚   β”‚   β”œβ”€β”€ about/            # About us
β”‚   β”‚   β”‚   β”œβ”€β”€ login/            # Login page
β”‚   β”‚   β”‚   β”œβ”€β”€ signup/           # Signup page
β”‚   β”‚   β”‚   β”œβ”€β”€ terms/            # Terms of service
β”‚   β”‚   β”‚   └── privacy/          # Privacy policy
β”‚   β”‚   β”œβ”€β”€ admin/                 # Dashboard pages (protected)
β”‚   β”‚   β”‚   β”œβ”€β”€ overview/         # Dashboard overview
β”‚   β”‚   β”‚   β”œβ”€β”€ booking/          # Service bookings
β”‚   β”‚   β”‚   β”œβ”€β”€ calendar/         # Calendar view
β”‚   β”‚   β”‚   β”œβ”€β”€ inbox/            # Call logs & transcripts
β”‚   β”‚   β”‚   β”œβ”€β”€ ai-setup/         # AI phone setup
β”‚   β”‚   β”‚   β”œβ”€β”€ service-management/ # Services CRUD
β”‚   β”‚   β”‚   β”œβ”€β”€ settings/         # User settings
β”‚   β”‚   β”‚   └── billing/          # Billing & subscriptions
β”‚   β”‚   β”œβ”€β”€ onboarding/            # User onboarding
β”‚   β”‚   β”œβ”€β”€ auth/                  # Auth callbacks
β”‚   β”‚   β”œβ”€β”€ layout.tsx             # Root layout
β”‚   β”‚   └── page.tsx               # Home page
β”‚   β”œβ”€β”€ components/                 # Reusable components
β”‚   β”‚   β”œβ”€β”€ layout/               # Layout components
β”‚   β”‚   β”‚   β”œβ”€β”€ admin-layout/     # Dashboard layout
β”‚   β”‚   β”‚   β”œβ”€β”€ main-layout/      # Public layout
β”‚   β”‚   β”‚   β”œβ”€β”€ dashboard-layout/ # Sidebar layout
β”‚   β”‚   β”‚   └── ...
β”‚   β”‚   β”œβ”€β”€ providers/            # Context providers
β”‚   β”‚   └── ui/                   # UI components
β”‚   β”œβ”€β”€ features/                   # Feature modules (RTK slices)
β”‚   β”‚   β”œβ”€β”€ auth/                 # Authentication
β”‚   β”‚   β”œβ”€β”€ subscription/         # Subscriptions
β”‚   β”‚   β”œβ”€β”€ service/              # Services
β”‚   β”‚   β”œβ”€β”€ calendar/             # Calendar
β”‚   β”‚   β”œβ”€β”€ callog/               # Call logs
β”‚   β”‚   β”œβ”€β”€ transcript/           # Transcripts
β”‚   β”‚   β”œβ”€β”€ settings/             # Settings
β”‚   β”‚   └── ...
β”‚   β”œβ”€β”€ redux/                      # Redux store
β”‚   β”‚   └── store.ts              # Store configuration
β”‚   β”œβ”€β”€ types/                      # TypeScript types
β”‚   β”œβ”€β”€ lib/                        # Utility libraries
β”‚   └── utils/                      # Helper functions
β”œβ”€β”€ public/                          # Static assets
β”‚   β”œβ”€β”€ assets/                    # Images, icons
β”‚   β”œβ”€β”€ dashboard/                 # Dashboard assets
β”‚   └── ...
β”œβ”€β”€ package.json                    # Dependencies
β”œβ”€β”€ next.config.ts                  # Next.js config
β”œβ”€β”€ tsconfig.json                   # TypeScript config
β”œβ”€β”€ Dockerfile.dev                 # Development Docker
└── Dockerfile.uat                 # UAT Docker

πŸ“„ Key Pages & Features

Public Pages

Landing (/)

Marketing homepage with hero, features, pricing, testimonials

Features (/features)

Detailed feature showcase with comparison table

Products (/products)

Product information with FAQ section

Blogs (/blogs)

Blog listing and detail pages

Pricing (/pricing)

Subscription plans and features

Login/Signup (/login, /signup)

Authentication pages with Google OAuth

Dashboard Pages (Protected)

Overview (/admin/overview)

Main dashboard with activity, campaign progress, recent bookings

Components:

  • ActivitySection - Recent activity feed
  • CampaignProgressSection - Call statistics
  • RecentService - Recent service bookings

Booking Management (/admin/booking)

Service booking management with calendar view

Features:

  • Filter bookings by status
  • Search bookings
  • View booking details
  • Manage booking lifecycle

Calendar (/admin/calendar)

Calendar view of appointments and bookings

Features:

  • Monthly, weekly, daily views
  • Task cards with status colors
  • Task detail modal
  • Drag & drop (future)

Inbox (/admin/inbox)

Call logs, transcripts, and conversation history

Features:

  • Filter by date, caller, status
  • Search transcripts
  • View full conversation
  • Transcript chunks modal
  • Delete call logs

AI Setup (/admin/ai-setup)

Phone number configuration for AI assistant

Features:

  • Device type selection (Apple/Android)
  • QR code setup (instant)
  • Manual setup instructions
  • Test call functionality
  • Troubleshooting guide

Service Management (/admin/service-management)

CRUD interface for services

Features:

  • Create/edit/delete services
  • Custom form fields
  • Service pricing
  • Description & duration
  • Grid/card layout

Settings (/admin/settings)

User and company configuration

Sections:

  • User Profile - Name, email
  • Company Info - Business details
  • Greeting Message - Custom AI greeting
  • Calendar Integrations - Google/Outlook
  • Verification - Phone verification
  • Billing Address

Billing (/admin/billing)

Subscription and payment management

Features:

  • View current plan
  • Upgrade/downgrade plans
  • Payment history
  • Invoices
  • Refund history

Onboarding

Onboarding Flow (/onboarding)

Interactive chat-based onboarding

Steps:

  1. Welcome & introduction
  2. Business information collection
  3. Service setup
  4. Phone number verification
  5. AI configuration
  6. Completion

🎨 UI Components

Layout Components

AdminPageLayout: Dashboard page wrapper with title and padding

DashboardLayout: Sidebar navigation layout

MainLayout: Public pages layout with navbar & footer

OnboardingLayout: Onboarding chat interface

UI Components

AddressAutocomplete: Google Places address autocomplete

StatusChip: Status badges (Confirmed, Cancelled, Done)

ProFeatureModal: Upgrade prompts for premium features

CalendarView: Calendar display with multiple views

TaskCard: Booking/appointment card

DeleteCallLogModal: Confirmation modal

TranscriptionChunksModal: Transcript chunks display

πŸ”Œ API Integration

RTK Query Slices

authApi: Authentication endpoints

endpoints: {
  login, signup, googleLogin, logout, me
}

serviceBookingApi: Service booking endpoints

endpoints: {
  getBookings, createBooking, updateBooking, deleteBooking
}

calllogApi: Call log endpoints

endpoints: {
  getCallLogs, getCallLog, getMetrics
}

transcriptApi: Transcript endpoints

endpoints: {
  getTranscript, createTranscript, updateTranscript
}

calendarApi: Calendar integration

endpoints: {
  getAuthUrl, callback, saveToken, getToken
}

subscriptionApi: Subscription management

endpoints: {
  getSubscription, updateSubscription, getInvoices, getRefunds
}

settingsApi: Settings management

endpoints: {
  getUser, updateUser, getCompany, updateCompany, verifyPhone
}

πŸš€ Development

Getting Started

  1. Install dependencies:

    cd apps/frontend
    pnpm install

    Note: This project uses pnpm as the package manager. If you don't have pnpm installed:

    npm install -g pnpm
  2. Set up environment:

    # Create .env.local
    NEXT_PUBLIC_API_URL=http://localhost:4000/api
    NEXT_PUBLIC_AI_URL=http://localhost:8000/api
    NEXT_PUBLIC_GOOGLE_CLIENT_ID=your_client_id
    NEXT_PUBLIC_GOOGLE_MAPS_API_KEY=your_maps_key
  3. Run development server:

    pnpm dev
  4. Access application:

Available Commands

pnpm dev          # Development server
pnpm build        # Production build
pnpm start        # Start production server
pnpm lint         # Lint with ESLint
pnpm type-check   # Type check with TypeScript

Code Quality

# Lint
pnpm lint

# Fix linting issues
pnpm lint -- --fix

# Type check
pnpm type-check

Docker Development

# Build
docker build -f Dockerfile.dev -t dispatchai-frontend:dev .

# Run
docker run -p 3000:3000 dispatchai-frontend:dev

# Or use docker-compose
docker compose up frontend

🎯 Routing

Public Routes

  • / - Landing
  • /features - Features
  • /products - Products
  • /blogs - Blog listing
  • /blogs/[id] - Blog detail
  • /pricing - Pricing
  • /about - About us
  • /login - Login
  • /signup - Signup
  • /terms - Terms
  • /privacy - Privacy

Protected Routes (require auth)

  • /admin/overview - Dashboard
  • /admin/booking - Bookings
  • /admin/calendar - Calendar
  • /admin/inbox - Inbox
  • /admin/ai-setup - AI Setup
  • /admin/service-management - Services
  • /admin/settings - Settings
  • /admin/billing - Billing
  • /onboarding - Onboarding

Auth Routes

  • /auth/callback - OAuth callback

πŸ” Authentication

Auth Flow

  1. Login: Email/password or Google OAuth
  2. Session: JWT stored in HTTP-only cookie
  3. Guards: Protected routes require valid session
  4. Refresh: Auto-refresh on API calls

Implementation

RTK Slice: features/auth/authSlice.ts
API: features/auth/authApi.ts
Hook: useCSRFToken()

πŸ“Š State Management

Redux Store

Store: src/redux/store.ts

Slices:

  • authSlice - User authentication state
  • publicApi - Public API endpoints
  • authApi - Auth endpoints
  • serviceApi - Service endpoints
  • subscriptionApi - Subscription endpoints
  • calllogApi - Call log endpoints
  • transcriptApi - Transcript endpoints
  • calendarApi - Calendar endpoints
  • settingsApi - Settings endpoints

Persistence: Redux Persist for offline support

🎨 Theming & Styling

Material-UI Theme

Provider: components/providers/ThemeProvider.tsx

Theme Configuration:

  • Primary/secondary colors
  • Typography scales
  • Spacing
  • Breakpoints
  • Components overrides

Styling Approach

Emotion: Primary styling (CSS-in-JS)
Styled Components: Legacy components
SX Prop: Inline styling
Global Styles: src/app/globals.css

πŸ”— External Integrations

Google OAuth

Button: components/GoogleOAuthButton.tsx
Config: Environment variables
Redirect: /auth/callback

Google Maps / Places API

Component: components/ui/AddressAutocomplete.tsx
Usage: Address autocomplete in forms
API Key: NEXT_PUBLIC_GOOGLE_MAPS_API_KEY

Calendar Integration

Google Calendar: OAuth flow
Outlook: Microsoft Graph API
UI: app/admin/settings/CalendarIntegrations.tsx

πŸ“¦ Key Dependencies

Core

  • next: 15.1.7 - Framework
  • react: 19.0.0 - UI library
  • @mui/material: 6.1.9 - Component library
  • @reduxjs/toolkit: 2.8.2 - State management
  • axios: 1.9.0 - HTTP client

Forms & Validation

  • react-hook-form: 7.56.4 - Form handling
  • zod: 3.25.17 - Schema validation
  • @hookform/resolvers: 5.0.1 - Zod resolver

UI Components

  • @mui/icons-material: 6.1.9 - Icons
  • @mui/x-charts: 8.9.2 - Charts
  • @mui/x-date-pickers: 8.9.0 - Date pickers
  • react-big-calendar: 1.19.4 - Calendar

Utilities

  • date-fns: 4.1.0 - Date manipulation
  • dayjs: 1.11.13 - Date library
  • lodash: 4.17.21 - Utilities

πŸ§ͺ Testing

# Run tests (when available)
pnpm test

# Watch mode
pnpm test:watch

# Coverage
pnpm test:coverage

πŸ› Common Issues

Issue: API calls failing

Fix: Check NEXT_PUBLIC_API_URL and backend service is running

Issue: Google OAuth not working

Fix: Verify NEXT_PUBLIC_GOOGLE_CLIENT_ID and redirect URI

Issue: Maps not loading

Fix: Check NEXT_PUBLIC_GOOGLE_MAPS_API_KEY and billing

Issue: TypeScript errors

Fix: Run pnpm type-check, ensure dependencies match

Issue: Build fails

Fix: Clear .next folder, run pnpm build again

πŸ“š Additional Resources

🀝 Contributing

When adding new features:

  1. Create feature module in src/features/
  2. Add RTK Query endpoints
  3. Create UI components in src/components/
  4. Add pages in src/app/
  5. Update navigation/sidebar
  6. Add TypeScript types
  7. Test thoroughly
  8. Update this README

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Contributors