# kevin-khoamai/endorse-flow-nexus architecture

> Architecture diagram of the GitHub repository kevin-khoamai/endorse-flow-nexus, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-10-03). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kevin-khoamai/endorse-flow-nexus
- Repository: https://github.com/kevin-khoamai/endorse-flow-nexus

## Overview

##### Project type and purpose
- This is a full-stack single-page application (SPA) built with React, Vite, and TypeScript that relies on Supabase as a backend-as-a-service (BaaS) for authentication, database, and storage.
- The README confirms it’s a “Lovable” project scaffolded for rapid front-end development and integrated with Supabase.

##### File structure
- Top-level:
- package.json, vite.config.ts, tsconfig.* → build and compile the React/TypeScript app with Vite.
- public/ + index.html → static assets and HTML shell.
- src/ → UI code (pages, components, hooks, contexts, integrations).
- src/integrations/supabase → client.ts & types.ts encapsulate Supabase API usage.
- supabase/ → local Supabase config.toml and SQL migrations.
- Patterns: component-driven UI under src/components, shared state via src/contexts/AuthContext.tsx, data hooks in src/hooks/use*.
- No custom backend code—Supabase handles auth, Postgres, and file storage.

##### README
- Confirms tech stack (Vite, TypeScript, React, Tailwind, shadcn-ui).
- No custom serverless functions—everything runs in the browser and talks directly to Supabase.

##### Main components of the system
a. Frontend (React SPA)
- Pages: Auth, Index (dashboard), NotFound
- UI Components: dashboards, dialogs, cards, grids
- State Management: React Context (AuthContext), custom hooks (useCampaigns, useVideos, etc.)
b. Build/Deployment
- Vite dev server for local dev
- CI/CD via GitHub/Lovable auto-publish
c. Backend services (Supabase)
- Authentication service (email/password, OAuth)
- Postgres database (tables created via migrations)
- Storage (for video uploads)
d. Repository & Infrastructure as Code
- Git repo with migrations under supabase/migrations
- Supabase config.toml for local emulation

##### Relationships and interactions
- Browser → (HTTP/WebSocket) → Vite dev server or static hosting → serves index.html + JS/CSS
- React app → (Supabase client) → Supabase Auth / Postgres / Storage
- User actions (upload video, fetch campaigns) invoke hooks → integrations/supabase/client.ts → Supabase
- Migrations define DB schema; config.toml ensures local Supabase match prod.

##### Architectural patterns & design principles
- Component-driven UI with shadcn-ui primitives (atomic design).
- Separation of concerns: UI, state (contexts/hooks), data integration (supabase client).
- BaaS: no custom API server—client communicates directly with Supabase.
- Infrastructure as code: supabase migrations tracked in repo.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Developer & CI/CD Layer
    subgraph "Developer & CI/CD Layer"
        Git["Git Repository"]:::dev
        CI["CI/CD Pipeline"]:::infra
    end

    %% Hosting & Build Layer
    subgraph "Hosting & Build Layer"
        VITE["Vite Build\nvite.config.ts"]:::infra
        HOST["Lovable Hosting/CDN"]:::infra
    end

    %% Client (React SPA) Layer
    subgraph "Client (React SPA)"
        Browser["Browser (End-User)"]:::frontend
        SPA["React SPA"]:::frontend

        subgraph "SPA Internals"
            Entry["src/main.tsx"]:::frontend
            HTML["public/index.html"]:::frontend
            Pkg["package.json"]:::infra
            TSConf["tsconfig.json"]:::infra
            subgraph "Pages"
                Auth["src/pages/Auth.tsx"]:::frontend
                IndexP["src/pages/Index.tsx"]:::frontend
                NotFound["src/pages/NotFound.tsx"]:::frontend
            end
            subgraph "UI Components"
                ADash["src/components/AdvertiserDashboard.tsx"]:::frontend
                PDash["src/components/PublisherDashboard.tsx"]:::frontend
                SPD["src/components/SPTeamDashboard.tsx"]:::frontend
                CGrid["src/components/CampaignGrid.tsx"]:::frontend
                CCard["src/components/CampaignCard.tsx"]:::frontend
                VUpload["src/components/VideoUploadDialog.tsx"]:::frontend
                AppDlg["src/components/ApplicationDialog.tsx"]:::frontend
                Notif["src/components/NotificationDropdown.tsx"]:::frontend
                UIPrims["shadcn-ui Primitives\nsrc/components/ui/*"]:::frontend
            end
            subgraph "State Management"
                AuthCtx["src/contexts/AuthContext.tsx"]:::frontend
                subgraph "Hooks"
                    HC1["src/hooks/useCampaigns.ts"]:::frontend
                    HC2["src/hooks/useVideos.ts"]:::frontend
                    HC3["src/hooks/useApplications.ts"]:::frontend
                    HC4["src/hooks/useNotifications.ts"]:::frontend
                    HC5["src/hooks/use-toast.ts"]:::frontend
                    HC6["src/hooks/use-mobile.tsx"]:::frontend
                end
            end
            subgraph "Integrations & Utils"
                SupClient["src/integrations/supabase/client.ts"]:::frontend
                SupTypes["src/integrations/supabase/types.ts"]:::frontend
                Utils["src/lib/utils.ts"]:::frontend
            end
            subgraph "Styles & Config"
                AppCSS["src/App.css"]:::frontend
                IndexCSS["src/index.css"]:::frontend
                Tailwind["tailwind.config.ts"]:::infra
                ESLint["eslint.config.js"]:::infra
            end
        end
    end

    %% Supabase Services Layer
    subgraph "Supabase Services"
        AuthSvc["Authentication Service"]:::service
        DB["Postgres Database"]:::service
        Storage["Storage Service"]:::service
    end

    %% Connections
    Git --> CI
    CI --> VITE
    VITE --> HOST
    HOST -->|HTTPS| Browser
    Browser -->|loads SPA| SPA
    SPA -->|invokes| SupClient
    SupClient -->|HTTPS/WebSocket| AuthSvc
    SupClient -->|HTTPS| DB
    SupClient -->|HTTPS| Storage
    Git -->|migrations| DB

    %% Click Events
    click Entry "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/src/main.tsx"
    click HTML "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/public/index.html"
    click Pkg "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/package.json"
    click TSConf "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/tsconfig.json"
    click Auth "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/src/pages/Auth.tsx"
    click IndexP "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/src/pages/Index.tsx"
    click NotFound "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/src/pages/NotFound.tsx"
    click ADash "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/src/components/AdvertiserDashboard.tsx"
    click PDash "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/src/components/PublisherDashboard.tsx"
    click SPD "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/src/components/SPTeamDashboard.tsx"
    click CGrid "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/src/components/CampaignGrid.tsx"
    click CCard "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/src/components/CampaignCard.tsx"
    click VUpload "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/src/components/VideoUploadDialog.tsx"
    click AppDlg "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/src/components/ApplicationDialog.tsx"
    click Notif "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/src/components/NotificationDropdown.tsx"
    click UIPrims "https://github.com/kevin-khoamai/endorse-flow-nexus/tree/main/src/components/ui/"
    click AuthCtx "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/src/contexts/AuthContext.tsx"
    click HC1 "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/src/hooks/useCampaigns.ts"
    click HC2 "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/src/hooks/useVideos.ts"
    click HC3 "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/src/hooks/useApplications.ts"
    click HC4 "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/src/hooks/useNotifications.ts"
    click HC5 "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/src/hooks/use-toast.ts"
    click HC6 "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/src/hooks/use-mobile.tsx"
    click SupClient "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/src/integrations/supabase/client.ts"
    click SupTypes "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/src/integrations/supabase/types.ts"
    click Utils "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/src/lib/utils.ts"
    click Tailwind "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/tailwind.config.ts"
    click ESLint "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/eslint.config.js"
    click DB "https://github.com/kevin-khoamai/endorse-flow-nexus/tree/main/supabase/migrations/"
    click AuthSvc "https://github.com/kevin-khoamai/endorse-flow-nexus/blob/main/supabase/config.toml"

    %% Styles
    classDef dev fill:#D3D3D3,stroke:#333,stroke-width:1px
    classDef infra fill:#ADD8E6,stroke:#333,stroke-width:1px
    classDef frontend fill:#20B2AA,stroke:#333,stroke-width:1px
    classDef service fill:#9370DB,stroke:#333,stroke-width:1px
```
