# milyonkifleyesus/wheels-and-code- architecture

> Architecture diagram of the GitHub repository milyonkifleyesus/wheels-and-code-, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-23). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/milyonkifleyesus/wheels-and-code-
- Repository: https://github.com/milyonkifleyesus/wheels-and-code-

## Overview

##### Project type and purpose
- This is a full-stack, single-page web application for automotive sales and service.
- Frontend: React 18 + TypeScript + Tailwind CSS, built with Vite and hosted on Netlify.
- Backend: Supabase (PostgreSQL database, Auth, real-time subscriptions).

##### File structure
- Top level:
– Configuration files (.env.example, netlify.toml, tsconfig.json, vite.config.ts, etc.)
– supabase/ folder: SQL migration scripts and setup.sql for database schema and RLS policies.
– src/ folder:
- pages/ – route components (HomePage, InventoryPage, AdminPage, BookingPage, etc.)
- components/ – domain-specific UI:
· /admin (AdminDashboard, ContentManager, SEOManager, etc.)
· /booking (BookingManager)
· /home (HeroSection, ServicesPreview, etc.)
· /inventory (InventoryManager)
· /layout (Header, Footer)
· /ui (Modal, Toast, VehicleCard, Car3D, etc.)
- contexts/ – React Contexts wrapping Supabase clients and state (AuthContext, BookingContext, ContentContext, VehicleContext)
- lib/ and utils/ – Supabase client setup and shared helpers
- main.tsx & App.tsx – application entry point and root component
- Deployment scripts: package.json, Netlify configuration

##### README for additional insights
- Tech stack: React, TypeScript, Tailwind CSS, Vite; Supabase for backend; Netlify for hosting.
- Features: Vehicle inventory, booking, customer management, admin CMS, real-time updates.
- Deployment: Netlify build and environment variables, plus manual database migration steps.

##### Main components
a. Client Browser (User Interface)
– React SPA served from Netlify CDN
– Runs App.tsx, loads pages, components, contexts
b. Netlify (CI/CD & CDN)
– Hosts static bundle (dist/)
– Handles build (npm run build) and deploy
c. Supabase Backend
– Auth service (email/password, RLS policies)
– PostgreSQL database (schema defined by migration files)
– Real-time engine (for live updates on inventory, bookings, content)
d. External Services (if any)
– Third-party map or analytics services (optional / configurable in code)

##### Relationships and interactions
- Browser ↔ Netlify/CDN:
– Initial HTML/CSS/JS fetch (index.html, main.js, CSS)
- Browser ↔ Supabase:
– REST and WebSocket calls via `@supabase/supabase-js` client in lib/supabase.ts or utils/supabase.ts
– AuthContext wraps sign-in/out, token management
– Data fetch & subscriptions for pages (e.g., InventoryPage uses VehicleContext to list vehicles)
- Supabase Real-time → Browser:
– Subscriptions push updates to components (e.g., live inventory changes, booking confirmations)

##### Architectural patterns & design principles
- Component-based UI layering (pages → domain components → UI primitives)
- Context API for global state and dependency injection (Auth, Booking, Content, Vehicle)
- Infrastructure as code for database (SQL migrations under supabase/migrations)
- Static front-end hosting + serverless backend (BaaS model)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User and Hosting
    Browser["User Browser"]:::infra
    Netlify["Netlify (CI/CD & CDN)"]:::infra
    Browser -->|"Fetch Static Assets\n(HTTP GET)"| Netlify

    %% Frontend Layer
    subgraph "Frontend (React SPA)" 
        direction TB
        StaticHTML["index.html"]:::frontend
        Styles["Global Styles\n(src/index.css,\nsrc/styles/globals.css)"]:::frontend
        TailwindConfig["Tailwind Config\n(tailwind.config.js,\npostcss.config.js)"]:::config
        Entry["main.tsx"]:::frontend
        Root["App.tsx"]:::frontend

        subgraph "Pages & UI Components"
            direction TB
            Pages["Page Route Components\n(src/pages/)"]:::frontend
            UI["UI Components\n(src/components/)"]:::frontend
            subgraph "Domain Components"
                direction TB
                Admin["Admin UI Components\n(src/components/admin/)"]:::frontend
                Booking["BookingManager.tsx"]:::frontend
                Home["Home UI Components\n(src/components/home/)"]:::frontend
                Inventory["InventoryManager.tsx"]:::frontend
            end
            subgraph "Layout Components"
                Header["Header.tsx"]:::frontend
                Footer["Footer.tsx"]:::frontend
            end
            UIPrimitives["Shared UI Primitives\n(src/components/ui/)"]:::frontend
        end

        subgraph "State Management (Contexts)"
            direction TB
            AuthCtx["AuthContext.tsx"]:::state
            BookingCtx["BookingContext.tsx"]:::state
            ContentCtx["ContentContext.tsx"]:::state
            VehicleCtx["VehicleContext.tsx"]:::state
        end

        subgraph "Data Access Layer"
            direction TB
            SupClient["supabase.ts"]:::data
            SupUtils["utils/supabase.ts"]:::data
        end

        subgraph "Build & Dev Configurations"
            direction TB
            ViteConfig["vite.config.ts"]:::config
            TSConfigs["tsconfig.json\n(tsconfig.app.json,\ntsconfig.node.json)"]:::config
            ESLint["eslint.config.js"]:::config
            Package["package.json\npackage-lock.json"]:::config
        end

        %% Connections within Frontend
        StaticHTML --> Entry
        Styles --> Entry
        TailwindConfig --> Entry
        Entry --> Root
        Root --> Pages
        Root --> AuthCtx
        Root --> BookingCtx
        Root --> ContentCtx
        Root --> VehicleCtx
        Root --> SupClient
        Pages --> Admin
        Pages --> Booking
        Pages --> Home
        Pages --> Inventory
        Pages --> UI
        UI --> UIPrimitives
        UI --> Header
        UI --> Footer
        AuthCtx --> SupClient
        BookingCtx --> SupClient
        ContentCtx --> SupClient
        VehicleCtx --> SupClient
        SupClient --> SupUtils
        Entry --> ViteConfig
        Entry --> TSConfigs
        Entry --> ESLint
        Entry --> Package

        %% Served via Netlify
        Netlify -->|"Serves App\n(CDN)"| Root
    end

    %% Supabase Backend
    subgraph "Supabase Backend" 
        direction TB
        AuthService["Auth Service"]:::backend
        RealTime["Real-time Engine"]:::backend
        subgraph "Database"
            direction TB
            Postgres[(PostgreSQL)]:::db
            Migrations["supabase/migrations/"]:::backend
            SetupSQL["supabase/setup.sql"]:::backend
        end
    end

    %% Interactions between Frontend and Supabase
    Browser -->|"REST Calls\n(GET/POST)"| AuthService
    Browser -->|"REST Calls\n(Queries/Mutations)"| Postgres
    SupClient -->|"API Calls"| AuthService
    SupClient -->|"API Calls"| Postgres
    RealTime -->|"WebSocket Push\n(Subcriptions)"| Browser

    %% Click Events
    click StaticHTML "https://github.com/milyonkifleyesus/wheels-and-code-/blob/main/index.html"
    click Styles "https://github.com/milyonkifleyesus/wheels-and-code-/blob/main/src/index.css"
    click Styles "https://github.com/milyonkifleyesus/wheels-and-code-/blob/main/src/styles/globals.css"
    click TailwindConfig "https://github.com/milyonkifleyesus/wheels-and-code-/blob/main/tailwind.config.js"
    click TailwindConfig "https://github.com/milyonkifleyesus/wheels-and-code-/blob/main/postcss.config.js"
    click Entry "https://github.com/milyonkifleyesus/wheels-and-code-/blob/main/src/main.tsx"
    click Root "https://github.com/milyonkifleyesus/wheels-and-code-/blob/main/src/App.tsx"
    click Pages "https://github.com/milyonkifleyesus/wheels-and-code-/tree/main/src/pages/"
    click UI "https://github.com/milyonkifleyesus/wheels-and-code-/tree/main/src/components/"
    click Admin "https://github.com/milyonkifleyesus/wheels-and-code-/tree/main/src/components/admin/"
    click Booking "https://github.com/milyonkifleyesus/wheels-and-code-/blob/main/src/components/booking/BookingManager.tsx"
    click Home "https://github.com/milyonkifleyesus/wheels-and-code-/tree/main/src/components/home/"
    click Inventory "https://github.com/milyonkifleyesus/wheels-and-code-/blob/main/src/components/inventory/InventoryManager.tsx"
    click Header "https://github.com/milyonkifleyesus/wheels-and-code-/blob/main/src/components/layout/Header.tsx"
    click Footer "https://github.com/milyonkifleyesus/wheels-and-code-/blob/main/src/components/layout/Footer.tsx"
    click UIPrimitives "https://github.com/milyonkifleyesus/wheels-and-code-/tree/main/src/components/ui/"
    click AuthCtx "https://github.com/milyonkifleyesus/wheels-and-code-/blob/main/src/contexts/AuthContext.tsx"
    click BookingCtx "https://github.com/milyonkifleyesus/wheels-and-code-/blob/main/src/contexts/BookingContext.tsx"
    click ContentCtx "https://github.com/milyonkifleyesus/wheels-and-code-/blob/main/src/contexts/ContentContext.tsx"
    click VehicleCtx "https://github.com/milyonkifleyesus/wheels-and-code-/blob/main/src/contexts/VehicleContext.tsx"
    click SupClient "https://github.com/milyonkifleyesus/wheels-and-code-/blob/main/src/lib/supabase.ts"
    click SupUtils "https://github.com/milyonkifleyesus/wheels-and-code-/blob/main/src/utils/supabase.ts"
    click Migrations "https://github.com/milyonkifleyesus/wheels-and-code-/tree/main/supabase/migrations/"
    click SetupSQL "https://github.com/milyonkifleyesus/wheels-and-code-/blob/main/supabase/setup.sql"
    click Netlify "https://github.com/milyonkifleyesus/wheels-and-code-/blob/main/netlify.toml"
    click ViteConfig "https://github.com/milyonkifleyesus/wheels-and-code-/blob/main/vite.config.ts"
    click TSConfigs "https://github.com/milyonkifleyesus/wheels-and-code-/blob/main/tsconfig.json"
    click ESLint "https://github.com/milyonkifleyesus/wheels-and-code-/blob/main/eslint.config.js"
    click Package "https://github.com/milyonkifleyesus/wheels-and-code-/blob/main/package.json"

    %% Styles
    classDef frontend fill:#CFE2FF,stroke:#0366d6,stroke-width:1px
    classDef backend fill:#D1E7DD,stroke:#14532d,stroke-width:1px
    classDef db fill:#FCE5CD,stroke:#b45309,stroke-width:1px,stroke-dasharray: 5 5
    classDef infra fill:#FFF2CC,stroke:#92400e,stroke-width:1px
    classDef state fill:#FFE599,stroke:#b47d1a,stroke-width:1px
    classDef data fill:#E2DFDA,stroke:#5a5a5a,stroke-width:1px
    classDef config fill:#D9D2E9,stroke:#5b21b6,stroke-width:1px
```
