# karn-aashish/nexus-surveillance architecture

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

- Interactive diagram: https://gitdiagram.com/karn-aashish/nexus-surveillance
- Repository: https://github.com/karn-aashish/nexus-surveillance

## Overview

##### Project type and purpose
- This is a full-stack single-page application (SPA) named “Nexus,” serving as a real-time surveillance dashboard.
- Frontend: React + TypeScript + Vite + Tailwind CSS + shadcn-ui components
- Backend: Supabase (Auth, Postgres database, real-time subscriptions)

##### File structure
- Top-level files & config:
– index.html, public/ (static assets), vite.config.ts, tailwind.config.ts
– package.json, tsconfig.json, supabase/config.toml
- src/:
– main.tsx / App.tsx wrap the React application
– src/pages/: route-level pages (Dashboard, MonitorPage, DevicesPage, etc.)
– src/components/: UI building blocks (cards, logs, maps, sidebars, monitors) + src/components/ui/: collection of design-system primitives
– src/integrations/supabase/: client.ts + types.ts for connecting to BaaS
– src/hooks/: custom hooks (use-mobile, use-toast)
– src/lib/utils.ts: shared utilities

##### README for additional insights
- Lists core tech stack (Vite, TypeScript, React, shadcn-ui, Tailwind CSS)
- Deployment via Bunny hosting (static asset serving + CDN)
- Data persistence & real-time via Supabase

## Diagram (Mermaid)

```mermaid
graph TB
    %% External Users and Hosting
    Browser["User's Web Browser"]:::external
    CDN["Bunny CDN / Static Hosting"]:::hosting

    Browser -->|"GET index.html, JS, CSS"| CDN

    %% React SPA Subsystem
    subgraph "React SPA" 
        direction TB

        subgraph "Entry Point" 
            direction TB
            Main["src/main.tsx"]:::entry
            App["src/App.tsx"]:::entry
        end

        subgraph "Routing / Pages Layer"
            direction TB
            IDX["Index.tsx"]:::pages
            DBP["Dashboard.tsx"]:::pages
            MP["MonitorPage.tsx"]:::pages
            DP["DevicesPage.tsx"]:::pages
            CP["CamerasPage.tsx"]:::pages
            LP["LocationsPage.tsx"]:::pages
            NP["NetworkPage.tsx"]:::pages
            TP["TargetsPage.tsx"]:::pages
            EP["ExtractionPage.tsx"]:::pages
            NF["NotFound.tsx"]:::pages
        end

        subgraph "UI Components Library"
            direction TB
            UI["src/components/ui/"]:::ui
        end

        subgraph "Shared Presentational Components"
            direction TB
            SB["SurveillanceSidebar.tsx"]:::comps
            DC["DeviceCard.tsx"]:::comps
            SC["StatusCard.tsx"]:::comps
            AL["ActivityLog.tsx"]:::comps
            TA["ThreatAlert.tsx"]:::comps
            LM["LiveMonitor.tsx"]:::comps
            NSC["NetworkScanner.tsx"]:::comps
            HG["HolographicGlobe.tsx"]:::comps
            TPV["ThemeProvider.tsx"]:::comps
        end

        subgraph "Integration Layer (Supabase Client)"
            direction TB
            CLIENT["client.ts"]:::integration
            TYPES["types.ts"]:::integration
        end

        subgraph "Custom Hooks"
            direction TB
            HM["use-mobile.tsx"]:::hooks
            HT["use-toast.tsx"]:::hooks
        end

        subgraph "Shared Utilities"
            direction TB
            UT["utils.ts"]:::utils
        end
    end

    %% Connections within SPA
    CDN -->|"serves static bundle"| Main
    Main --> App
    App --> IDX
    App --> DBP
    App --> MP
    App --> DP
    App --> CP
    App --> LP
    App --> NP
    App --> TP
    App --> EP
    App --> NF
    App --> SB
    App --> DC
    App --> SC
    App --> AL
    App --> TA
    App --> LM
    App --> NSC
    App --> HG
    App --> TPV
    App --> CLIENT
    CLIENT --> TYPES
    App --> HM
    App --> HT
    App --> UT

    %% Supabase Backend Services
    subgraph "Supabase BaaS" 
        direction TB
        Auth["Auth Service"]:::baas
        DB["Postgres Database"]:::database
        Realtime["Realtime (WebSocket)"]:::baas
    end

    %% API and Real-time flows
    App -->|"REST API calls"| Auth
    App -->|"CRUD (fetch, insert, update, delete)"| DB
    App -->|"subscribe/unsubscribe"| Realtime
    Realtime -->|"events pushed"| App

    %% Click Events
    click Main "https://github.com/karn-aashish/nexus-surveillance/blob/main/src/main.tsx"
    click App "https://github.com/karn-aashish/nexus-surveillance/blob/main/src/App.tsx"
    click IDX "https://github.com/karn-aashish/nexus-surveillance/blob/main/src/pages/Index.tsx"
    click DBP "https://github.com/karn-aashish/nexus-surveillance/blob/main/src/pages/Dashboard.tsx"
    click MP "https://github.com/karn-aashish/nexus-surveillance/blob/main/src/pages/MonitorPage.tsx"
    click DP "https://github.com/karn-aashish/nexus-surveillance/blob/main/src/pages/DevicesPage.tsx"
    click CP "https://github.com/karn-aashish/nexus-surveillance/blob/main/src/pages/CamerasPage.tsx"
    click LP "https://github.com/karn-aashish/nexus-surveillance/blob/main/src/pages/LocationsPage.tsx"
    click NP "https://github.com/karn-aashish/nexus-surveillance/blob/main/src/pages/NetworkPage.tsx"
    click TP "https://github.com/karn-aashish/nexus-surveillance/blob/main/src/pages/TargetsPage.tsx"
    click EP "https://github.com/karn-aashish/nexus-surveillance/blob/main/src/pages/ExtractionPage.tsx"
    click NF "https://github.com/karn-aashish/nexus-surveillance/blob/main/src/pages/NotFound.tsx"
    click UI "https://github.com/karn-aashish/nexus-surveillance/tree/main/src/components/ui/"
    click SB "https://github.com/karn-aashish/nexus-surveillance/blob/main/src/components/SurveillanceSidebar.tsx"
    click DC "https://github.com/karn-aashish/nexus-surveillance/blob/main/src/components/DeviceCard.tsx"
    click SC "https://github.com/karn-aashish/nexus-surveillance/blob/main/src/components/StatusCard.tsx"
    click AL "https://github.com/karn-aashish/nexus-surveillance/blob/main/src/components/ActivityLog.tsx"
    click TA "https://github.com/karn-aashish/nexus-surveillance/blob/main/src/components/ThreatAlert.tsx"
    click LM "https://github.com/karn-aashish/nexus-surveillance/blob/main/src/components/LiveMonitor.tsx"
    click NSC "https://github.com/karn-aashish/nexus-surveillance/blob/main/src/components/NetworkScanner.tsx"
    click HG "https://github.com/karn-aashish/nexus-surveillance/blob/main/src/components/HolographicGlobe.tsx"
    click TPV "https://github.com/karn-aashish/nexus-surveillance/blob/main/src/components/ThemeProvider.tsx"
    click CLIENT "https://github.com/karn-aashish/nexus-surveillance/blob/main/src/integrations/supabase/client.ts"
    click TYPES "https://github.com/karn-aashish/nexus-surveillance/blob/main/src/integrations/supabase/types.ts"
    click HM "https://github.com/karn-aashish/nexus-surveillance/blob/main/src/hooks/use-mobile.tsx"
    click HT "https://github.com/karn-aashish/nexus-surveillance/blob/main/src/hooks/use-toast.tsx"
    click UT "https://github.com/karn-aashish/nexus-surveillance/blob/main/src/lib/utils.ts"

    %% Styles
    classDef external fill:#E0F7FA,stroke:#006064,color:#000
    classDef hosting fill:#FFE0B2,stroke:#EF6C00,color:#000
    classDef entry fill:#BBDEFB,stroke:#1E88E5,color:#000
    classDef pages fill:#BBDEFB,stroke:#1E88E5,color:#000
    classDef ui fill:#C8E6C9,stroke:#388E3C,color:#000
    classDef comps fill:#C8E6C9,stroke:#388E3C,color:#000
    classDef integration fill:#D1C4E9,stroke:#7E57C2,color:#000
    classDef hooks fill:#F0F4C3,stroke:#AFB42B,color:#000
    classDef utils fill:#F5F5F5,stroke:#9E9E9E,color:#000
    classDef baas fill:#C8E6C9,stroke:#2E7D32,color:#000
    classDef database fill:#FFF9C4,stroke:#F9A825,color:#000
```
