# p47d4/imvinci-coat-custom architecture

> Architecture diagram of the GitHub repository p47d4/imvinci-coat-custom, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/p47d4/imvinci-coat-custom
- Repository: https://github.com/p47d4/imvinci-coat-custom

## Overview

##### Project Type and Purpose
- This is a client-focused Single-Page Application (SPA) built with:
- Vite & React (TypeScript)
- Tailwind CSS & shadcn-ui for styling/UI components
- It uses Supabase as a Backend-as-a-Service (BaaS) for authentication, database (PostgreSQL), and storage.
- The app offers e-commerce & quote-generation features (shop, cart, quotes, profile management, blog, personalization).

##### File Structure for Architectural Layers
- **Presentation Layer** (src/pages, src/components): UI pages and reusable components.
- **State & Business Logic Layer** (src/contexts, src/hooks, src/services):
- AuthContext & CartContext manage global state.
- Hooks like useCart, useToast.
- Services (cartService, cartMigrationService) encapsulate domain logic.
- **Data Access Layer** (src/integrations/supabase + src/lib/utils):
- Supabase client & types.
- Utilities for transforming/syncing data.
- **Static Assets** (public/, index.html): Logos, robots.txt, Vite entry point.
- **Deployment Config**: vite.config.ts, supabase/config.toml, migrations under supabase/.

##### Review README for Additional Context
- Confirms tech stack and deployment via Lovable or custom hosting.
- No custom backend code—everything routes through Supabase.

##### Relationships & Data Flows
- **User → Browser**: Initiates navigation, form submissions.
- **Browser (React SPA) → Supabase Auth**:
- ProtectedRoute component checks JWT via AuthContext.
- **Browser → Supabase Database**:
- Queries for products (src/data or fetched via RPC), blog posts, quotes.
- Writes to carts, orders, quotes.
- **Browser → Supabase Storage**:
- File uploads (if supported).
- **Browser → External API**:
- WhatsApp messaging for support/contact.

##### Architectural Patterns & Principles
- **Component-based UI**: shadcn-ui primitives + custom components.
- **Context for State**: AuthContext & CartContext for app-wide state.
- **Service Abstraction**: cartService decouples UI from storage details.
- **Hexagonal-ish Layers**: UI ↔ Services ↔ Integrations.
- **API-First**: All backend operations go through Supabase.

##### Final Checklist
- [ ] All major components are present and labeled.
- [ ] Technologies & frameworks are annotated (React, Vite, Supabase, Tailwind, shadcn-ui).
- [ ] External integrations (WhatsApp API) are shown as separate clouds.

## Diagram (Mermaid)

```mermaid
graph TB
    %% Browser Container
    subgraph "Browser (React SPA)" 
        direction TB
        subgraph "Entry & Root"
            MTS["Main.tsx"]:::presentation
            ATS["App.tsx"]:::presentation
        end
        MTS --> ATS

        subgraph "Pages"
            direction TB
            Index["Index Page"]:::presentation
            ShopPage["Shop Page"]:::presentation
            CartPage["Cart Page"]:::presentation
            CheckoutPage["Checkout Page"]:::presentation
            GetQuotePage["GetQuote Page"]:::presentation
            ProfilePage["Profile Page"]:::presentation
            BlogPage["Blog List Page"]:::presentation
            BlogDetailPage["Blog Detail Page"]:::presentation
            AboutPage["About Page"]:::presentation
            ContactPage["Contact Page"]:::presentation
            ServicesPage["Services Page"]:::presentation
            PackagesPage["Packages Page"]:::presentation
            NotFoundPage["NotFound Page"]:::presentation
        end

        subgraph "Components"
            direction TB
            Header["Header"]:::presentation
            Footer["Footer"]:::presentation
            ProtectedRoute["ProtectedRoute"]:::presentation
            ShopList["Shop (Product List)"]:::presentation
            ProductCard["ProductCard"]:::presentation
            CategoryFilter["CategoryFilter"]:::presentation
            CartSummary["CartSummary"]:::presentation
            CartItemRow["CartItemRow"]:::presentation
            EmptyCart["EmptyCart"]:::presentation
            OrderSummary["OrderSummary"]:::presentation
            QuoteForm["QuoteForm"]:::presentation
            QuoteFields["QuoteFormFields"]:::presentation
            QuoteInfo["QuoteInfoSections"]:::presentation
            VehicleSelector["VehicleTypeSelector"]:::presentation
            ProfileEdit["ProfileEditModal"]:::presentation
            QuotesHistory["QuotesHistory"]:::presentation
            Hero["Hero"]:::presentation
            PackagesSection["PackagesSection"]:::presentation
            ServicesSection["Services"]:::presentation
            CarPersonalizer["CarPersonalizer"]:::presentation
            WhatsAppButton["WhatsAppButton"]:::external
        end

        subgraph "State & Business Logic"
            direction TB
            AuthContext["AuthContext"]:::business
            CartContext["CartContext"]:::business
            useCartHook["useCart"]:::business
            useToastHook["use-toast"]:::business
            useMobileHook["use-mobile"]:::business
            cartService["cartService"]:::business
            cartMigService["cartMigrationService"]:::business
        end

        subgraph "Data Access & Utils"
            direction TB
            SupaClient["Supabase Client"]:::data
            SupaTypes["Supabase Types"]:::data
            Utils["utils.ts"]:::data
            CartUtils["cartUtils.ts"]:::data
            Pricing["pricing.ts"]:::data
        end

        ATS --> Pages
        ATS --> Components
        ATS --> AuthContext
        ATS --> CartContext
        AuthContext --> useCartHook
        CartContext --> useCartHook
        useCartHook --> cartService
        cartService --> SupaClient
        SupaClient --> SupaTypes
        SupaClient --> Utils
        SupaClient --> CartUtils
        SupaClient --> Pricing
        Components --> WhatsAppButton

    end

    %% Hosting / CDN
    subgraph "Hosting / CDN" 
        StaticHost["Static Assets (Netlify/Vercel/CDN)"]:::presentation
    end
    StaticHost -->|Serves| MTS

    %% Supabase BaaS
    subgraph "Supabase BaaS" 
        direction TB
        AuthService["Auth Service"]:::data
        DB["PostgreSQL DB"]:::data
        Storage["Storage Bucket"]:::data
        subgraph "Migrations"
            direction TB
            Migs["*.sql"]:::data
        end
    end

    %% External Integrations
    subgraph "External Services"
        WhatsAppAPI["WhatsApp API"]:::external
    end

    %% Data Flows
    ATS -->|"Auth"| AuthService
    ATS -->|"Read/Writes"| DB
    ATS -->|"Uploads"| Storage
    WhatsAppButton -->|"Messages"| WhatsAppAPI
    Migs --> DB

    %% Click Events
    click MTS "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/main.tsx"
    click ATS "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/App.tsx"
    click Index "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/pages/Index.tsx"
    click ShopPage "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/pages/Shop.tsx"
    click CartPage "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/pages/Cart.tsx"
    click CheckoutPage "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/pages/Checkout.tsx"
    click GetQuotePage "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/pages/GetQuote.tsx"
    click ProfilePage "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/pages/Profile.tsx"
    click BlogPage "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/pages/Blog.tsx"
    click BlogDetailPage "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/pages/BlogDetail.tsx"
    click AboutPage "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/pages/About.tsx"
    click ContactPage "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/pages/Contact.tsx"
    click ServicesPage "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/pages/Services.tsx"
    click PackagesPage "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/pages/Packages.tsx"
    click NotFoundPage "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/pages/NotFound.tsx"
    click Header "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/components/Header.tsx"
    click Footer "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/components/Footer.tsx"
    click ProtectedRoute "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/components/ProtectedRoute.tsx"
    click ShopList "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/components/Shop.tsx"
    click ProductCard "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/components/shop/ProductCard.tsx"
    click CategoryFilter "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/components/shop/CategoryFilter.tsx"
    click CartSummary "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/components/shop/CartSummary.tsx"
    click CartItemRow "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/components/cart/CartItemRow.tsx"
    click EmptyCart "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/components/cart/EmptyCart.tsx"
    click OrderSummary "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/components/cart/OrderSummary.tsx"
    click QuoteForm "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/components/quote/QuoteForm.tsx"
    click QuoteFields "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/components/quote/QuoteFormFields.tsx"
    click QuoteInfo "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/components/quote/QuoteInfoSections.tsx"
    click VehicleSelector "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/components/quote/VehicleTypeSelector.tsx"
    click ProfileEdit "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/components/profile/ProfileEditModal.tsx"
    click QuotesHistory "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/components/profile/QuotesHistory.tsx"
    click Hero "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/components/Hero.tsx"
    click PackagesSection "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/components/PackagesSection.tsx"
    click ServicesSection "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/components/Services.tsx"
    click CarPersonalizer "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/components/CarPersonalizer.tsx"
    click WhatsAppButton "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/components/WhatsAppButton.tsx"
    click AuthContext "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/contexts/AuthContext.tsx"
    click CartContext "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/contexts/CartContext.tsx"
    click useCartHook "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/hooks/useCart.ts"
    click useToastHook "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/hooks/use-toast.ts"
    click useMobileHook "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/hooks/use-mobile.tsx"
    click cartService "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/services/cartService.ts"
    click cartMigService "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/services/cartMigrationService.ts"
    click SupaClient "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/integrations/supabase/client.ts"
    click SupaTypes "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/integrations/supabase/types.ts"
    click Utils "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/lib/utils.ts"
    click CartUtils "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/utils/cartUtils.ts"
    click Pricing "https://github.com/p47d4/imvinci-coat-custom/blob/main/src/utils/pricing.ts"

    %% Styles
    classDef presentation fill:#cce5ff,stroke:#333,stroke-width:1px
    classDef business fill:#d4edda,stroke:#333,stroke-width:1px
    classDef data fill:#ffe5b4,stroke:#333,stroke-width:1px
    classDef external fill:#eeeeee,stroke:#333,stroke-width:1px
```
