# shafwansafi06/cortex-one-ai architecture

> Architecture diagram of the GitHub repository shafwansafi06/cortex-one-ai, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-11-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/shafwansafi06/cortex-one-ai
- Repository: https://github.com/shafwansafi06/cortex-one-ai

## Overview

##### Project type and purpose
- This is a single-page frontend application (React + TypeScript) built with Vite.
- It simulates an enterprise AI dashboard (“CortexOne”) that unifies HR, Finance, and Support insights via reusable UI components and local mock JSON endpoints (with a future option to swap in real Supabase or other API backends).

##### File structure
Top-level:
- public/
– mock-data/ (static JSON endpoints: hr.json, finance.json)
– robots.txt, logo.svg
- src/
– components/ (layout, UI primitives, and domain mockup composites)
– pages/ (Auth, Dashboard, HR, Finance, Support, Demo, Settings, NotFound)
– integrations/supabase (client, types)
– lib/ (shared helpers: auth, motion, utils)
– hooks/ (custom React hooks)
– data/demoData.ts (demo flows)
– App.tsx, main.tsx, index.css
Configuration and build:
- vite.config.ts, tsconfig*.json, tailwind.config.ts, postcss.config.js, eslint.config.js
- supabase/config.toml (local Supabase emulator or deployment)

##### Key insights from README
- Frontend only; no dedicated backend in this repo
- Local JSON files under public/mock-data are fetched like API endpoints
- Supabase integration scaffold is in place (client.ts, config.toml) for auth or live data
- Clear, reusable UI components and rapid model-swap capability

##### Main components & relationships
A. Presentation Layer (Client Browser / SPA)
- App Shell (App.tsx → AuthGuard, Layout, NavBar, Sidebar)
- Pages (Dashboard, HR, Finance, Support, Demo, Settings)
- UI Primitives (components/ui/*) & Mockup composites (components/mockups/*)
B. Data Access Layer (in-browser fetches)
- Static Mock API (public/mock-data/*.json)
- Supabase Client (integrations/supabase/client.ts)
– Auth workflows (sign-in/signup)
– Real-time data or user data
C. Build & Deployment
- Vite Dev Server (for local demo) → serves index.html + public files + HMR
- Production Build → Static hosting (Netlify, Vercel, S3, etc.)
D. External Services
- Supabase (Auth, Database)
- Future AI/model endpoints (swap into mock-data)

##### Architectural patterns & principles
- Component-based UI (separation of layout, primitives, and domain mockups)
- Logical layering: Presentation (components/pages) → Data (fetch layer) → External
- Single source of truth for styling: Tailwind + CSS modules (index.css, App.css)
- Extensibility: mock-data endpoints mirror real API contract for easy swap-out
- Client-only, serverless mindset: minimal backend dependencies

##### Detailed breakdown to capture essential elements
- NavBar, Sidebar (layout comps)
- AuthGuard (route guard logic)
- Branch out page components (Dashboard, HRMockup, FinanceMockup, SupportMockup)
- Optional path from pages to Supabase integration client
- That components/ui/* are shared primitives used across pages

Summary
By dividing the system into:

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Layer
    subgraph "User & Browser"
        direction TB
        User["User"]:::external
        Browser["Browser (SPA)"]:::external
        User -->|"interacts with"| Browser
    end

    %% SPA Application Layer
    subgraph "SPA Application" 
        direction TB
        AppShell["App Shell"]:::presentation
        AuthGuard["Auth Guard"]:::presentation
        LayoutComp["Layout"]:::presentation
        NavBar["NavBar"]:::presentation
        Sidebar["Sidebar"]:::presentation

        AppShell -->|"uses"| AuthGuard
        AppShell -->|"renders"| LayoutComp
        LayoutComp -->|includes| NavBar
        LayoutComp -->|includes| Sidebar

        subgraph "Page Routes" 
            direction TB
            AuthPage["Auth Page"]:::presentation
            DashboardPage["Dashboard Page"]:::presentation
            HRPage["HR Page"]:::presentation
            FinancePage["Finance Page"]:::presentation
            SupportPage["Support Page"]:::presentation
            DemoPage["Demo Page"]:::presentation
            SettingsPage["Settings Page"]:::presentation
            NotFoundPage["NotFound Page"]:::presentation
            IndexRoute["Index (Routing Helper)"]:::presentation
            DemoAuthRoute["DemoAuth (Routing Helper)"]:::presentation
        end

        AppShell -->|"routes to"| AuthPage
        AppShell -->|"routes to"| DashboardPage
        AppShell -->|"routes to"| HRPage
        AppShell -->|"routes to"| FinancePage
        AppShell -->|"routes to"| SupportPage
        AppShell -->|"routes to"| DemoPage
        AppShell -->|"routes to"| SettingsPage
        AppShell -->|"routes to"| NotFoundPage

        subgraph "UI Components" 
            direction TB
            UIPrimitives["UI Primitives"]:::presentation
            HRMockup["HR Mockup"]:::presentation
            FinanceMockup["Finance Mockup"]:::presentation
            SupportMockup["Support Mockup"]:::presentation
        end

        DashboardPage -->|"uses"| UIPrimitives
        HRPage -->|"uses"| HRMockup
        FinancePage -->|"uses"| FinanceMockup
        SupportPage -->|"uses"| SupportMockup
        DemoPage -->|"uses"| UIPrimitives

        CustomHooks["Custom Hooks"]:::presentation
        DemoData["Demo Data Flows"]:::presentation
        SharedLibs["Shared Libraries"]:::presentation

        AppShell -->|import| CustomHooks
        AppShell -->|import| DemoData
        AppShell -->|import| SharedLibs

        click AppShell "https://github.com/shafwansafi06/cortex-one-ai/blob/main/src/App.tsx"
        click AuthGuard "https://github.com/shafwansafi06/cortex-one-ai/blob/main/src/components/AuthGuard.tsx"
        click LayoutComp "https://github.com/shafwansafi06/cortex-one-ai/blob/main/src/components/layout/Layout.tsx"
        click NavBar "https://github.com/shafwansafi06/cortex-one-ai/blob/main/src/components/layout/NavBar.tsx"
        click Sidebar "https://github.com/shafwansafi06/cortex-one-ai/blob/main/src/components/layout/Sidebar.tsx"
        click AuthPage "https://github.com/shafwansafi06/cortex-one-ai/blob/main/src/pages/Auth.tsx"
        click DashboardPage "https://github.com/shafwansafi06/cortex-one-ai/blob/main/src/pages/Dashboard.tsx"
        click HRPage "https://github.com/shafwansafi06/cortex-one-ai/blob/main/src/pages/HR.tsx"
        click FinancePage "https://github.com/shafwansafi06/cortex-one-ai/blob/main/src/pages/Finance.tsx"
        click SupportPage "https://github.com/shafwansafi06/cortex-one-ai/blob/main/src/pages/Support.tsx"
        click DemoPage "https://github.com/shafwansafi06/cortex-one-ai/blob/main/src/pages/Demo.tsx"
        click SettingsPage "https://github.com/shafwansafi06/cortex-one-ai/blob/main/src/pages/Settings.tsx"
        click NotFoundPage "https://github.com/shafwansafi06/cortex-one-ai/blob/main/src/pages/NotFound.tsx"
        click IndexRoute "https://github.com/shafwansafi06/cortex-one-ai/blob/main/src/pages/Index.tsx"
        click DemoAuthRoute "https://github.com/shafwansafi06/cortex-one-ai/blob/main/src/pages/DemoAuth.tsx"
        click UIPrimitives "https://github.com/shafwansafi06/cortex-one-ai/tree/main/src/components/ui"
        click HRMockup "https://github.com/shafwansafi06/cortex-one-ai/blob/main/src/components/mockups/HRMockup.tsx"
        click FinanceMockup "https://github.com/shafwansafi06/cortex-one-ai/blob/main/src/components/mockups/FinanceMockup.tsx"
        click SupportMockup "https://github.com/shafwansafi06/cortex-one-ai/blob/main/src/components/mockups/SupportMockup.tsx"
        click CustomHooks "https://github.com/shafwansafi06/cortex-one-ai/blob/main/src/hooks/use-mobile.tsx"
        click CustomHooks "https://github.com/shafwansafi06/cortex-one-ai/blob/main/src/hooks/use-toast.ts"
        click DemoData "https://github.com/shafwansafi06/cortex-one-ai/blob/main/src/data/demoData.ts"
        click SharedLibs "https://github.com/shafwansafi06/cortex-one-ai/blob/main/src/lib/auth.tsx"
        click SharedLibs "https://github.com/shafwansafi06/cortex-one-ai/blob/main/src/lib/motion.ts"
        click SharedLibs "https://github.com/shafwansafi06/cortex-one-ai/blob/main/src/lib/utils.ts"

    end

    %% Data Access Layer
    subgraph "Data Access Layer"
        direction TB
        StaticMock["Static Mock JSON Endpoints"]:::dataaccess
        SupabaseClient["Supabase Client"]:::dataaccess
        StaticMock -->|"GET /mock-data/*.json"| AppShell
        SupabaseClient -->|"supabase.auth.signIn()"| AppShell

        click StaticMock "https://github.com/shafwansafi06/cortex-one-ai/blob/main/public/mock-data/hr.json"
        click StaticMock "https://github.com/shafwansafi06/cortex-one-ai/blob/main/public/mock-data/finance.json"
        click SupabaseClient "https://github.com/shafwansafi06/cortex-one-ai/blob/main/src/integrations/supabase/client.ts"
        click SupabaseClient "https://github.com/shafwansafi06/cortex-one-ai/blob/main/src/integrations/supabase/types.ts"
        click SupabaseClient "https://github.com/shafwansafi06/cortex-one-ai/blob/main/supabase/config.toml"
    end

    %% External Services
    subgraph "External Services"
        direction TB
        SupabaseService["Supabase Service"]:::external
        AIMock["Future AI/Model Endpoints"]:::external
        AppShell -->|"optional real-time data"| SupabaseService
        AppShell -->|"swap mock with real"| AIMock
    end

    %% Build & Deployment
    subgraph "Build & Deploy"
        direction TB
        NodeNPM["Node / NPM"]:::build
        Vite["Vite Dev Server / Build"]:::build
        Hosting["Static Hosting"]:::build

        NodeNPM -->|"npm run dev / build"| Vite
        Vite -->|"bundle assets"| Hosting

        click NodeNPM "https://github.com/shafwansafi06/cortex-one-ai/blob/main/package.json"
        click Vite "https://github.com/shafwansafi06/cortex-one-ai/blob/main/vite.config.ts"
        click Hosting "https://github.com/shafwansafi06/cortex-one-ai/blob/main/netlify.toml"
    end

    %% Styles
    classDef presentation fill:#D0E8FF,stroke:#3B82F6,color:#1E3A8A
    classDef dataaccess fill:#D1FAE5,stroke:#10B981,color:#065F46
    classDef external fill:#FFEDD5,stroke:#FB923C,color:#7C2D12
    classDef build fill:#E5E7EB,stroke:#6B7280,color:#374151
```
