# syedminamurrehman/epicdrive architecture

> Architecture diagram of the GitHub repository syedminamurrehman/epicdrive, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/syedminamurrehman/epicdrive
- Repository: https://github.com/syedminamurrehman/epicdrive

## Overview

1. **Top-level architecture**
   EpicDrive is a **Next.js 16 App Router** application written in **TypeScript**. The repo is split into route-driven UI under `app/`, reusable presentation components under `components/`, domain/data logic in `services/`, and Supabase/Postgres schema artifacts in `supabase/`. This is a server-rendered, route-centric architecture rather than a separate frontend/backend split.

2. **Public customer-facing surface**
   The public site lives mainly in `app/page.tsx`, `app/cars/page.tsx`, and `app/cars/[id]/page.tsx`, with supporting legal pages for privacy and terms. The public experience includes a landing page, car catalog, individual vehicle detail pages, and a booking form. SEO is built into the routing layer via dynamic car pages, plus `app/robots.txt` and `app/sitemap.ts`.

3. **Car discovery and booking flow**
   The main customer flow is: browse cars, filter/search, open a car detail page, then submit a booking request. UI pieces like `SearchFilters`, `CarCard`, `CarGallery`, and `BookingForm` support that flow. The booking form is the handoff point from UI to persistence: it collects customer and rental data and sends it into the service layer for database creation.

4. **Admin portal**
   `app/admin/` is a separate administrative area with its own layout and login page. It includes dashboards for analytics, bookings, customers, and fleet management, plus create/edit screens for fleet records. This is the operational boundary of the app: public users interact with listings and bookings, while staff manage inventory and booking status here.

5. **Data access layer**
   `services/carService.ts` is the core business/data abstraction. It hides Supabase query details behind domain-oriented operations such as fetching cars, loading a car by ID, and creating bookings. The README indicates this layer also handles more complex filtering and joins, including post-query filtering for specialized fields like ADAS.

6. **Database model**
   The Supabase/Postgres schema uses a **polymorphic vehicle spec design**. `cars` stores shared vehicle data, while `specs_engine`, `specs_hybrid`, and `specs_electric` store powertrain-specific fields. `bookings` tracks rental requests and their relationship to cars and customers. This split is the key persistence boundary and explains how one car type can map to different technical sub-records.

7. **Supabase integration and environment boundary**
   `lib/supabase.ts` centralizes Supabase client setup, and the app relies on Supabase environment variables for URL and anon key. The README describes failover behavior when env vars are missing, which suggests the app is designed to keep building/running in degraded diagnostic mode rather than crashing immediately. That makes Supabase the primary external dependency for both data and auth.

8. **Routing protection and request boundary**
   `proxy.ts` is the request interception layer for the app. In an architecture diagram, this is the place to show route-level protection around `/admin`, separating public traffic from staff-only traffic before pages are rendered.

9. **Shared UI and brand system**
   Most of the visual experience is composed from reusable components in `components/`: navigation, hero sections, footer, FAQ, background effects, WhatsApp floating contact, and catalog/booking widgets. `app/globals.css` provides the global styling entry point for the Tailwind-based design system. This is a shared presentation layer used across both public and admin surfaces.

10. **Types, constants, and domain consistency**
   `types/index.ts` and `constants/index.ts` provide the shared contract for vehicle categories, specs, and other app-wide domain values. These files reduce duplication between the public catalog, admin forms, and the service layer, keeping UI labels and database-shaped data aligned.

11. **Static assets and car media**
   `public/` contains optimized static assets, with per-car folders under `public/cars/` for imagery and supporting media. These assets are consumed by the car gallery/detail views and are part of the product presentation layer, not the database.

12. **Operational/diagnostic surfaces**
   The `app/diagnostics` route is a production-check endpoint for environment and database health. Together with SEO files and the Supabase-backed data layer, it shows the app has a production-ops mindset: observable, crawlable, and resilient enough for deployment on Vercel.

Main entry points: [`services/carService.ts`](https://github.com/syedminamurrehman/epicdrive/blob/main/services/carService.ts) (Car service), [`app/layout.tsx`](https://github.com/syedminamurrehman/epicdrive/blob/main/app/layout.tsx) (Site shell), [`app/page.tsx`](https://github.com/syedminamurrehman/epicdrive/blob/main/app/page.tsx) (Home page), [`supabase/schema.sql`](https://github.com/syedminamurrehman/epicdrive/blob/main/supabase/schema.sql) (Schema)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_app["App routes"]
  node_node_app_root["Site shell<br/>next app<br/>[layout.tsx]"]
  node_node_app_home["Home page<br/>route<br/>[page.tsx]"]
  node_node_app_cars["Car catalog<br/>route<br/>[page.tsx]"]
  node_node_app_car_detail["Car detail<br/>route<br/>[page.tsx]"]
  node_node_app_admin["Admin portal<br/>admin route<br/>[layout.tsx]"]
  node_node_app_admin_login["Admin login<br/>route<br/>[page.tsx]"]
  node_node_app_admin_ops["Admin ops<br/>admin routes<br/>[page.tsx]"]
  node_node_app_booking["Booking form<br/>route<br/>[BookingForm.tsx]"]
  node_node_app_legal["Legal pages<br/>routes<br/>[page.tsx]"]
  node_node_app_ops["Ops pages<br/>route<br/>[page.tsx]"]
end

subgraph group_group_ui["Shared UI"]
  node_node_ui_catalog["Catalog UI<br/>components<br/>[SearchFilters.tsx]"]
  node_node_ui_brand["Brand UI<br/>components<br/>[Navbar.tsx]"]
  node_node_ui_support["Support UI<br/>components<br/>[WhatsAppFloat.tsx]"]
end

subgraph group_group_data["Data layer"]
  node_node_service_cars[("Car service<br/>data service<br/>[carService.ts]")]
  node_node_service_supabase[("Supabase client<br/>integration<br/>[supabase.ts]")]
  node_node_domain_types["Domain types<br/>shared contracts<br/>[index.ts]"]
  node_node_domain_constants["Constants<br/>shared values<br/>[index.ts]"]
end

subgraph group_group_persistence["Persistence"]
  node_node_db_schema[("Schema<br/>[schema.sql]")]
end

subgraph group_group_assets["Assets"]
  node_node_assets_cars["Car media<br/>static assets"]
end

node_node_app_root -->|"renders"| node_node_app_home
node_node_app_root -->|"composes"| node_node_ui_brand
node_node_app_home -->|"uses"| node_node_ui_brand
node_node_app_home -->|"uses"| node_node_ui_support
node_node_app_cars -->|"uses"| node_node_ui_catalog
node_node_app_cars -->|"queries"| node_node_service_cars
node_node_app_car_detail -->|"uses"| node_node_ui_catalog
node_node_app_car_detail -->|"contains"| node_node_app_booking
node_node_app_booking -->|"submits"| node_node_service_cars
node_node_service_cars -->|"uses"| node_node_service_supabase
node_node_service_cars -->|"maps to"| node_node_db_schema
node_node_service_cars -->|"types"| node_node_domain_types
node_node_service_cars -->|"references"| node_node_domain_constants
node_node_db_schema -.->|"shapes"| node_node_domain_types
node_node_app_admin -->|"gates"| node_node_app_admin_login
node_node_app_admin -->|"contains"| node_node_app_admin_ops
node_node_app_admin_ops -->|"reads/writes"| node_node_service_cars
node_node_app_ops -->|"checks"| node_node_service_supabase
node_node_app_ops -.->|"verifies"| node_node_db_schema
node_node_app_root -->|"serves"| node_node_assets_cars

click node_node_app_root "https://github.com/syedminamurrehman/epicdrive/blob/main/app/layout.tsx"
click node_node_app_home "https://github.com/syedminamurrehman/epicdrive/blob/main/app/page.tsx"
click node_node_app_cars "https://github.com/syedminamurrehman/epicdrive/blob/main/app/cars/page.tsx"
click node_node_app_car_detail "https://github.com/syedminamurrehman/epicdrive/blob/main/app/cars/[id]/page.tsx"
click node_node_app_admin "https://github.com/syedminamurrehman/epicdrive/blob/main/app/admin/layout.tsx"
click node_node_app_admin_login "https://github.com/syedminamurrehman/epicdrive/blob/main/app/admin/login/page.tsx"
click node_node_app_admin_ops "https://github.com/syedminamurrehman/epicdrive/blob/main/app/admin/page.tsx"
click node_node_app_booking "https://github.com/syedminamurrehman/epicdrive/blob/main/components/BookingForm.tsx"
click node_node_app_legal "https://github.com/syedminamurrehman/epicdrive/blob/main/app/privacy-policy/page.tsx"
click node_node_app_ops "https://github.com/syedminamurrehman/epicdrive/blob/main/app/diagnostics/page.tsx"
click node_node_ui_catalog "https://github.com/syedminamurrehman/epicdrive/blob/main/components/SearchFilters.tsx"
click node_node_ui_brand "https://github.com/syedminamurrehman/epicdrive/blob/main/components/Navbar.tsx"
click node_node_ui_support "https://github.com/syedminamurrehman/epicdrive/blob/main/components/WhatsAppFloat.tsx"
click node_node_service_cars "https://github.com/syedminamurrehman/epicdrive/blob/main/services/carService.ts"
click node_node_service_supabase "https://github.com/syedminamurrehman/epicdrive/blob/main/lib/supabase.ts"
click node_node_domain_types "https://github.com/syedminamurrehman/epicdrive/blob/main/types/index.ts"
click node_node_domain_constants "https://github.com/syedminamurrehman/epicdrive/blob/main/constants/index.ts"
click node_node_db_schema "https://github.com/syedminamurrehman/epicdrive/blob/main/supabase/schema.sql"
click node_node_assets_cars "https://github.com/syedminamurrehman/epicdrive/tree/main/public/cars"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_node_app_root,node_node_app_home,node_node_app_cars,node_node_app_car_detail,node_node_app_admin,node_node_app_admin_login,node_node_app_admin_ops,node_node_app_booking,node_node_app_legal,node_node_app_ops toneBlue
class node_node_ui_catalog,node_node_ui_brand,node_node_ui_support toneAmber
class node_node_service_cars,node_node_service_supabase,node_node_domain_types,node_node_domain_constants toneMint
class node_node_db_schema toneRose
class node_node_assets_cars toneIndigo
```

## Components

### App routes

Route-driven pages and layouts for public, admin, and operational surfaces.

- [Site shell](https://github.com/syedminamurrehman/epicdrive/blob/main/app/layout.tsx): next app · Root layout and landing page for the public experience. · `app/layout.tsx`
- [Home page](https://github.com/syedminamurrehman/epicdrive/blob/main/app/page.tsx): route · Public landing page. · `app/page.tsx`
- [Car catalog](https://github.com/syedminamurrehman/epicdrive/blob/main/app/cars/page.tsx): route · Browse and filter available vehicles. · `app/cars/page.tsx`
- [Car detail](https://github.com/syedminamurrehman/epicdrive/blob/main/app/cars/[id]/page.tsx): route · Dynamic vehicle detail pages with booking entry point. · `app/cars/[id]/page.tsx`
- [Admin portal](https://github.com/syedminamurrehman/epicdrive/blob/main/app/admin/layout.tsx): admin route · Staff area layout and dashboard entry. · `app/admin/layout.tsx`
- [Admin login](https://github.com/syedminamurrehman/epicdrive/blob/main/app/admin/login/page.tsx): route · Authentication entry for staff users. · `app/admin/login/page.tsx`
- [Admin ops](https://github.com/syedminamurrehman/epicdrive/blob/main/app/admin/page.tsx): admin routes · Analytics, bookings, customers, and fleet management screens. · `app/admin/page.tsx`
- [Booking form](https://github.com/syedminamurrehman/epicdrive/blob/main/components/BookingForm.tsx): route · Customer booking request handoff to persistence. · `components/BookingForm.tsx`
- [Legal pages](https://github.com/syedminamurrehman/epicdrive/blob/main/app/privacy-policy/page.tsx): routes · Privacy policy and terms pages. · `app/privacy-policy/page.tsx`
- [Ops pages](https://github.com/syedminamurrehman/epicdrive/blob/main/app/diagnostics/page.tsx): route · Diagnostics and crawlability endpoints. · `app/diagnostics/page.tsx`

### Shared UI

Reusable presentation components used across the site.

- [Catalog UI](https://github.com/syedminamurrehman/epicdrive/blob/main/components/SearchFilters.tsx): components · Search, cards, and gallery used in the car discovery flow. · `components/SearchFilters.tsx`
- [Brand UI](https://github.com/syedminamurrehman/epicdrive/blob/main/components/Navbar.tsx): components · Navigation, hero, footer, FAQ, and visual framing. · `components/Navbar.tsx`
- [Support UI](https://github.com/syedminamurrehman/epicdrive/blob/main/components/WhatsAppFloat.tsx): components · Booking and contact helpers such as WhatsApp floating action. · `components/WhatsAppFloat.tsx`

### Data layer

Business logic, Supabase integration, and shared domain contracts.

- [Car service](https://github.com/syedminamurrehman/epicdrive/blob/main/services/carService.ts): data service · Supabase-backed car lookup, filtering, and booking creation. · `services/carService.ts`
- [Supabase client](https://github.com/syedminamurrehman/epicdrive/blob/main/lib/supabase.ts): integration · Centralized Supabase client setup and environment boundary. · `lib/supabase.ts`
- [Domain types](https://github.com/syedminamurrehman/epicdrive/blob/main/types/index.ts): shared contracts · Vehicle and booking shapes shared across UI and services. · `types/index.ts`
- [Constants](https://github.com/syedminamurrehman/epicdrive/blob/main/constants/index.ts): shared values · App-wide labels and vehicle category values. · `constants/index.ts`

### Persistence

Supabase/Postgres schema artifacts.

- [Schema](https://github.com/syedminamurrehman/epicdrive/blob/main/supabase/schema.sql): postgres schema · Cars, powertrain spec tables, bookings, and related persistence model. · `supabase/schema.sql`

### Assets

Static media and public files consumed by the UI.

- [Car media](https://github.com/syedminamurrehman/epicdrive/tree/main/public/cars): static assets · Per-car imagery and supporting public media. · `public/cars`

## Connections

- Site shell → Home page: renders · Root shell serves the landing page.
- Site shell → Brand UI: composes · Shared presentation components are used across the public site.
- Home page → Brand UI: uses · Home page is built from shared brand components.
- Home page → Support UI: uses · Home page includes support/contact affordances.
- Car catalog → Catalog UI: uses · Catalog route composes search, cards, and gallery UI.
- Car catalog → Car service: queries · Catalog route relies on car service for data and filtering.
- Car detail → Catalog UI: uses · Detail pages reuse gallery and card presentation.
- Car detail → Booking form: contains · Vehicle pages lead into booking submission.
- Booking form → Car service: submits · Booking form hands customer/rental data to service logic.
- Car service → Supabase client: uses · Service layer delegates database access to the Supabase client.
- Car service → Schema: maps to · Service operations correspond to cars, specs, and bookings tables.
- Car service → Domain types: types · Domain contracts keep service and UI data aligned.
- Car service → Constants: references · Filtering and labels use shared constants.
- Schema → Domain types: shapes · Database model informs shared application types.
- Admin portal → Admin login: gates · Admin area is separated by its login entry.
- Admin portal → Admin ops: contains · Admin portal groups operational screens.
- Admin ops → Car service: reads/writes · Fleet and booking management use the same service boundary.
- Ops pages → Supabase client: checks · Diagnostics validate environment and database connectivity.
- Ops pages → Schema: verifies · Operational checks depend on the persistence layer existing.
- Site shell → Car media: serves · Public media is consumed by the rendered site.
