# xheikhtalha2004/vertex-labs architecture

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

- Interactive diagram: https://gitdiagram.com/xheikhtalha2004/vertex-labs
- Repository: https://github.com/xheikhtalha2004/vertex-labs

## Overview

##### Project Type and Purpose
- This is a full-stack, single-page web application built with Vite and React/TypeScript.
- Purpose: a marketing site with an AI-powered chat widget (Google Gemini API), a Supabase-backed contact form, and interactive 3D canvas animations.
- Deployed as a static build plus serverless API endpoints on Vercel.

##### File Structure
- Top-level “src” directory holds all client-side code:
- src/App.tsx + main.tsx + index.html: entrypoints
- src/components: subdivided into canvas (3D scenes), chat (AI UI), dom/Services/ContactForm, and a generic UI library
- src/lib: service wrappers (chatService.ts, formService.ts), Supabase client, utilities
- src/hooks: device/motion utilities
- src/shaders: WebGL GLSL materials
- “api” folder at root: two serverless functions:
- chat.ts – proxies chat requests to Google Gemini
- submit-form.ts – writes contact data into Supabase
- Config & deployment:
- .env.example + .env.local for API keys
- vite.config.ts, tailwind.config.js – build tools
- vercel.json – serverless routing
- setup-supabase.sql – table schema

##### Key README Insights
- Features: floating AI chatbot (Google Gemini), contact form saved to Supabase, WhatsApp handoff.
- Env vars for Google AI and Supabase.
- Deployment via Vercel CLI/GitHub with env var injection.
- Tested workflows: chat messages, form submissions, navigation.

a. Main Components
1) Client Browser (React SPA)
- UI: 3D Canvas (Three.js via React), Chat Widget, Contact Form, Site Navigation
- Service Clients: chatService (calls /api/chat), formService (/api/submit-form), direct Supabase client (optional)
2) Serverless API Layer (Vercel Functions)
- /api/chat → Google AI Studio API
- /api/submit-form → Supabase Insert
3) External Services
- Google AI Studio (Gemini API)
- Supabase (Postgres DB with contact_submissions table)
- WhatsApp (via chat widget handoff link)
4) Hosting/CI
- Vercel (serves static assets, runs serverless functions)
- GitHub (source repo, CI triggers)

b. Relationships and Data Flows
- User interacts with Chat Widget → React invokes chatService → POST /api/chat → serverless → Google AI → response → back to client UI.
- User submits Contact Form → React invokes formService → POST /api/submit-form → serverless → Supabase insert → success → client confirmation.
- Navigation, asset fetching and static content delivered from Vercel CDN.
- 3D Canvas shaders and assets loaded directly in the browser; no backend involvement.

c. Architectural Patterns & Principles
- Client-Server with thin serverless façade.
- Separation of concerns: UI components vs. service wrappers vs. API handlers.
- Modular React component hierarchy (canvas vs. chat vs. form vs. common UI).
- Environment-driven configuration for keys and endpoints.
- Scalability: serverless auto-scales with traffic.

d. Key Technologies
- Vite + React + TypeScript
- Three.js or react-three-fiber for 3D Canvas
- Tailwind CSS / PostCSS for styling
- Vercel Functions for serverless backend
- Google AI Studio (Gemini)
- Supabase (Postgres + Row-Level Security)
- GitHub + Vercel CI/CD

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Source & Deployment
    GitHub["GitHub Repository"]:::infra
    VercelCI["Vercel (CI/CD & Hosting)"]:::infra

    GitHub -->|push| VercelCI

    %% Client SPA Layer
    subgraph "Client SPA (Vite + React)" 
        direction TB
        Browser["User Browser (React SPA)"]:::frontend

        subgraph "Entrypoints"
            direction TB
            Main["main.tsx"]:::frontend
            App["App.tsx"]:::frontend
            Index["index.html"]:::frontend
        end

        subgraph "Components"
            direction TB
            subgraph "3D Canvas Components" 
                direction TB
                GlobalCanvas["GlobalCanvas.tsx"]:::frontend
                CameraRig["CameraRig.tsx"]:::frontend
                LenisProvider["LenisProvider.tsx"]:::frontend
                PostProcessing["PostProcessing.tsx"]:::frontend
                PerformanceTier["PerformanceTier.tsx"]:::frontend
                CrystalMesh["CrystalMesh.tsx"]:::frontend
                GridBackground["GridBackground.tsx"]:::frontend
                ParticleField["ParticleField.tsx"]:::frontend
                OrbitalServices["OrbitalServices.tsx"]:::frontend
                SmallCrystal["SmallCrystal.tsx"]:::frontend
            end
            subgraph "Chat UI Components"
                direction TB
                ChatWidget["ChatWidget.tsx"]:::frontend
                AIConsultant["AIConsultant.tsx"]:::frontend
            end
            subgraph "DOM Sections"
                direction TB
                ContactForm["ContactForm.tsx"]:::frontend
                ServicesSection["ServicesSection.tsx"]:::frontend
                ProcessSection["ProcessSection.tsx"]:::frontend
            end
            subgraph "UI Library"
                direction TB
                UILib["src/components/ui/*"]:::frontend
            end
        end

        subgraph "Service Wrappers / API Clients"
            direction TB
            ChatService["chatService.ts"]:::frontend
            FormService["formService.ts"]:::frontend
            SupabaseClient["supabase.ts"]:::frontend
            Utils["utils.ts"]:::frontend
        end

        subgraph "React Hooks"
            direction TB
            UseMobile["use-mobile.ts"]:::frontend
            UseReducedMotion["useReducedMotion.ts"]:::frontend
        end

        subgraph "Shader Files"
            direction TB
            GridDistortion["gridDistortion.ts"]:::frontend
            HolographicMaterial["holographicMaterial.ts"]:::frontend
            ShadersIndex["index.ts"]:::frontend
        end

        Browser --> App
        App --> Main
        App --> Index

        %% UI to services
        ChatWidget -->|uses| ChatService
        ContactForm -->|uses| FormService

        %% Canvas uses shaders
        GlobalCanvas -->|loads| GridDistortion
        GlobalCanvas -->|loads| HolographicMaterial
        GlobalCanvas -->|imports| ShadersIndex
    end

    %% Serverless API Layer
    subgraph "Serverless API Layer (Vercel Functions)"
        direction TB
        APIC["/api/chat (chat.ts)"]:::backend
        APIF["/api/submit-form (submit-form.ts)"]:::backend
    end

    %% External Services
    subgraph "External Services"
        direction TB
        GoogleAI["Google AI Studio (Gemini)"]:::external
        SupabaseDB["Supabase Postgres"]:::external
        WhatsApp["WhatsApp Handoff"]:::external
    end

    %% Hosting Connectivity
    VercelCI -->|"deploy static assets"| Browser
    VercelCI -->|"deploy functions"| APIC
    VercelCI -->|"deploy functions"| APIF

    %% Chat Flow
    ChatService -->|POST /api/chat| APIC
    APIC -->|calls| GoogleAI
    GoogleAI -->|response| APIC
    APIC -->|response| ChatService
    ChatService -->|data| ChatWidget
    ChatWidget -->|handoff| WhatsApp

    %% Form Flow
    FormService -->|POST /api/submit-form| APIF
    APIF -->|insert| SupabaseDB
    SupabaseDB -->|ack| APIF
    APIF -->|response| FormService
    FormService -->|data| ContactForm

    %% Click Events
    click Main "https://github.com/xheikhtalha2004/vertex-labs/blob/main/src/main.tsx"
    click App "https://github.com/xheikhtalha2004/vertex-labs/blob/main/src/App.tsx"
    click Index "https://github.com/xheikhtalha2004/vertex-labs/blob/main/index.html"
    click GlobalCanvas "https://github.com/xheikhtalha2004/vertex-labs/blob/main/src/components/canvas/GlobalCanvas.tsx"
    click CameraRig "https://github.com/xheikhtalha2004/vertex-labs/blob/main/src/components/canvas/CameraRig.tsx"
    click LenisProvider "https://github.com/xheikhtalha2004/vertex-labs/blob/main/src/components/canvas/LenisProvider.tsx"
    click PostProcessing "https://github.com/xheikhtalha2004/vertex-labs/blob/main/src/components/canvas/PostProcessing.tsx"
    click PerformanceTier "https://github.com/xheikhtalha2004/vertex-labs/blob/main/src/components/canvas/PerformanceTier.tsx"
    click CrystalMesh "https://github.com/xheikhtalha2004/vertex-labs/blob/main/src/components/canvas/hero/CrystalMesh.tsx"
    click GridBackground "https://github.com/xheikhtalha2004/vertex-labs/blob/main/src/components/canvas/hero/GridBackground.tsx"
    click ParticleField "https://github.com/xheikhtalha2004/vertex-labs/blob/main/src/components/canvas/hero/ParticleField.tsx"
    click OrbitalServices "https://github.com/xheikhtalha2004/vertex-labs/blob/main/src/components/canvas/services/OrbitalServices.tsx"
    click SmallCrystal "https://github.com/xheikhtalha2004/vertex-labs/blob/main/src/components/canvas/services/SmallCrystal.tsx"
    click ChatWidget "https://github.com/xheikhtalha2004/vertex-labs/blob/main/src/components/chat/ChatWidget.tsx"
    click AIConsultant "https://github.com/xheikhtalha2004/vertex-labs/blob/main/src/components/chat/AIConsultant.tsx"
    click ContactForm "https://github.com/xheikhtalha2004/vertex-labs/blob/main/src/components/dom/ContactForm.tsx"
    click ServicesSection "https://github.com/xheikhtalha2004/vertex-labs/blob/main/src/components/dom/ServicesSection.tsx"
    click ProcessSection "https://github.com/xheikhtalha2004/vertex-labs/blob/main/src/components/dom/ProcessSection.tsx"
    click UILib "https://github.com/xheikhtalha2004/vertex-labs/tree/main/src/components/ui/"
    click ChatService "https://github.com/xheikhtalha2004/vertex-labs/blob/main/src/lib/chatService.ts"
    click FormService "https://github.com/xheikhtalha2004/vertex-labs/blob/main/src/lib/formService.ts"
    click SupabaseClient "https://github.com/xheikhtalha2004/vertex-labs/blob/main/src/lib/supabase.ts"
    click Utils "https://github.com/xheikhtalha2004/vertex-labs/blob/main/src/lib/utils.ts"
    click UseMobile "https://github.com/xheikhtalha2004/vertex-labs/blob/main/src/hooks/use-mobile.ts"
    click UseReducedMotion "https://github.com/xheikhtalha2004/vertex-labs/blob/main/src/hooks/useReducedMotion.ts"
    click GridDistortion "https://github.com/xheikhtalha2004/vertex-labs/blob/main/src/shaders/gridDistortion.ts"
    click HolographicMaterial "https://github.com/xheikhtalha2004/vertex-labs/blob/main/src/shaders/holographicMaterial.ts"
    click ShadersIndex "https://github.com/xheikhtalha2004/vertex-labs/blob/main/src/shaders/index.ts"
    click APIC "https://github.com/xheikhtalha2004/vertex-labs/blob/main/api/chat.ts"
    click APIF "https://github.com/xheikhtalha2004/vertex-labs/blob/main/api/submit-form.ts"

    %% Styles
    classDef frontend fill:#D0E8FF,stroke:#0366D6,color:#000
    classDef backend fill:#DFF6DD,stroke:#228B22,color:#000
    classDef external fill:#FFE8A1,stroke:#DAA520,color:#000
    classDef infra fill:#E2E2E2,stroke:#888888,color:#000
```
