# adilmunawar/adigon architecture

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

- Interactive diagram: https://gitdiagram.com/adilmunawar/adigon
- Repository: https://github.com/adilmunawar/adigon

## Overview

##### Project Type and Purpose
- Full-stack/web-app front-end built with React (Vite + TypeScript + Tailwind + shadcn-ui).
- Uses Supabase for backend (Auth + Database + Migrations).
- Integrates with external AI services via `src/lib/gemini.ts` & `src/lib/runware.ts`.

##### File Structure
- Top-level “public” holds static assets and `index.html`.
- “src” subdivides into:
- `components/` – UI building blocks (chat interface, 3D scene, voice input, etc.)
- `ui/` – shadcn-ui primitives (buttons, dialogs, forms, etc.)
- `hooks/` – custom React hooks (mobile detection, toast)
- `providers/` – React Context providers (AuthProvider, ThemeProvider)
- `integrations/supabase/` – Supabase client & type definitions
- `lib/` – app-specific logic (AI integration, utils)
- `pages/` – route views (Auth, Index, NotFound)
- `main.tsx` & `App.tsx` – entrypoint & root component
- “supabase/” holds your database config and SQL migrations.

##### README Insights
- Confirms tech stack.
- Deployment via Lovable platform.
- Supabase is a managed BaaS; no custom server code here.

##### Main Components & Their Relationships
a. Frontend Client (React App)
- Browser runs the Vite-bundled static assets.
- UI layer: components + shadcn-ui + Tailwind CSS.
- State & context: AuthProvider, ThemeProvider.
- Hooks drive device detection and global toast notifications.
b. BaaS Backend (Supabase)
- Auth API for sign-in/up (`src/integrations/supabase/client.ts`).
- Database API for persisting chat history, settings.
- Managed via `supabase/config.toml` + migrations.
c. External AI Service
- `src/lib/gemini.ts` & `src/lib/runware.ts` wrap calls to an AI/LLM endpoint.
- Fetches responses for chat interface or other AI-driven features.
d. Development & Deployment Tools
- Vite – dev server, HMR, production build.
- Lovable Platform – code editing, CI/CD, hosting & custom domains.

Interactions:
– React app ↔ Supabase (HTTP/REST calls via JS client).
– React app ↔ AI service (HTTP/gRPC calls via your lib).
– Developer pushes code → Lovable CI → static build deployed.

##### Architectural Patterns & Design Principles
- Component-driven UI – single responsibility React components.
- Provider pattern – centralized Auth & Theme state.
- Hook abstraction – encapsulate cross-cutting concerns (mobile, toast).
- BaaS consumption – offload backend responsibilities to Supabase.
- Modular integrations – AI logic isolated in `src/lib`.

##### Critical Details Not to Miss
- The distinction between shadcn-ui primitives (`components/ui/*`) vs. your domain components (`components/ChatInterface.tsx`, etc.).
- The build step (Vite) and hosting platform (Lovable).
- The fact that Supabase handles both Auth and Database with the same client.
- Custom hooks and providers that glue UI to data and themes.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph "Frontend Client"
        direction TB
        Main["main.tsx"]:::frontend
        App["App.tsx"]:::frontend
        UIComponents["UI Components"]:::frontend
        ChatInterface["ChatInterface.tsx"]:::frontend
        ThreeScene["ThreeScene.tsx"]:::frontend
        VoiceInput["VoiceInput.tsx"]:::frontend
        OtherUI["Additional UI Components"]:::frontend
        Primitives["shadcn-ui Primitives"]:::frontend
        Providers["Providers"]:::frontend
        AuthProvider["AuthProvider.tsx"]:::frontend
        ThemeProvider["ThemeProvider.tsx"]:::frontend
        Hooks["Custom Hooks"]:::frontend
        UseMobile["use-mobile.tsx"]:::frontend
        UseToast["use-toast.ts"]:::frontend
        Pages["Pages"]:::frontend
        AuthPage["Auth.tsx"]:::frontend
        IndexPage["Index.tsx"]:::frontend
        NotFoundPage["NotFound.tsx"]:::frontend
    end

    subgraph "Supabase (BaaS Backend)"
        direction TB
        AuthAPI["Auth API"]:::backend
        DatabaseAPI["Database API"]:::backend
        Config["Config (config.toml)"]:::backend
        Migrations["SQL Migrations"]:::backend
    end

    subgraph "External AI Service"
        direction TB
        Gemini["Gemini Integration"]:::external
        Runware["Runware Integration"]:::external
    end

    subgraph "Development Tools"
        direction TB
        Vite["Vite"]:::dev
        Tailwind["Tailwind"]:::dev
        TSConfig["TypeScript Configs"]:::dev
        LovableCI["Lovable CI/CD"]:::dev
    end

    %% Connections: Frontend to Supabase
    App -->|"HTTPS JS Client"| AuthAPI
    App -->|"HTTPS JS Client"| DatabaseAPI

    %% Frontend to AI Service
    App -->|"AI Requests"| Gemini
    App -->|"AI Requests"| Runware

    %% Dev Tools to Frontend and Backend
    Vite -->|"Build/HMR"| Main
    LovableCI -->|"Deploy Static Assets"| Main
    LovableCI -->|"Manage Migrations"| Config

    %% Click Events
    click Main "https://github.com/adilmunawar/adigon/blob/main/src/main.tsx"
    click App "https://github.com/adilmunawar/adigon/blob/main/src/App.tsx"
    click ChatInterface "https://github.com/adilmunawar/adigon/blob/main/src/components/ChatInterface.tsx"
    click ThreeScene "https://github.com/adilmunawar/adigon/blob/main/src/components/ThreeScene.tsx"
    click VoiceInput "https://github.com/adilmunawar/adigon/blob/main/src/components/VoiceInput.tsx"
    click OtherUI "https://github.com/adilmunawar/adigon/tree/main/src/components/"
    click Primitives "https://github.com/adilmunawar/adigon/tree/main/src/components/ui/"
    click AuthProvider "https://github.com/adilmunawar/adigon/blob/main/src/providers/AuthProvider.tsx"
    click ThemeProvider "https://github.com/adilmunawar/adigon/blob/main/src/providers/ThemeProvider.tsx"
    click UseMobile "https://github.com/adilmunawar/adigon/blob/main/src/hooks/use-mobile.tsx"
    click UseToast "https://github.com/adilmunawar/adigon/blob/main/src/hooks/use-toast.ts"
    click AuthPage "https://github.com/adilmunawar/adigon/blob/main/src/pages/Auth.tsx"
    click IndexPage "https://github.com/adilmunawar/adigon/blob/main/src/pages/Index.tsx"
    click NotFoundPage "https://github.com/adilmunawar/adigon/blob/main/src/pages/NotFound.tsx"
    click AuthAPI "https://github.com/adilmunawar/adigon/blob/main/src/integrations/supabase/client.ts"
    click DatabaseAPI "https://github.com/adilmunawar/adigon/blob/main/src/integrations/supabase/client.ts"
    click Config "https://github.com/adilmunawar/adigon/blob/main/supabase/config.toml"
    click Migrations "https://github.com/adilmunawar/adigon/tree/main/supabase/migrations/"
    click Gemini "https://github.com/adilmunawar/adigon/blob/main/src/lib/gemini.ts"
    click Runware "https://github.com/adilmunawar/adigon/blob/main/src/lib/runware.ts"
    click Vite "https://github.com/adilmunawar/adigon/blob/main/vite.config.ts"
    click Tailwind "https://github.com/adilmunawar/adigon/blob/main/tailwind.config.ts"
    click TSConfig "https://github.com/adilmunawar/adigon/blob/main/tsconfig.json"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#009,stroke-width:1px
    classDef backend  fill:#D0FFD8,stroke:#090,stroke-width:1px
    classDef external fill:#FFE8C0,stroke:#E55,stroke-width:1px
    classDef dev       fill:#F0F0F0,stroke:#999,stroke-width:1px
```
