# vickyadityaraj/fivsed architecture

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

- Interactive diagram: https://gitdiagram.com/vickyadityaraj/fivsed
- Repository: https://github.com/vickyadityaraj/fivsed

## Overview

FIVSED is an embedded-firmware integrity monitoring system with a web operations dashboard. The documented flow begins with STM32-authoritative firmware verification, passes the result through the ESP32 uploader to the web ingestion endpoint, and presents stored telemetry to operators. The repository includes the ESP32 firmware and Next.js application, but not the STM32 implementation or Raspberry Pi system. Unsampled firmware-module wiring is shown only where documented or marked unverified.

Main entry points: [`lib/context/fivsed-context.tsx`](https://github.com/vickyadityaraj/fivsed/blob/main/lib/context/fivsed-context.tsx) (Telemetry state), [`components/layout/AppLayout.tsx`](https://github.com/vickyadityaraj/fivsed/blob/main/components/layout/AppLayout.tsx) (Protected app shell), [`app/dashboard/page.tsx`](https://github.com/vickyadityaraj/fivsed/blob/main/app/dashboard/page.tsx) (Dashboard), [`app/api/events/route.ts`](https://github.com/vickyadityaraj/fivsed/blob/main/app/api/events/route.ts) (Event API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_embedded["Embedded telemetry"]
  node_esp32["ESP32 controller<br/>[main.cpp]"]
  node_uart["UART protocol<br/>[uart_protocol.cpp]"]
  node_wifi["Wi-Fi manager<br/>[wifi_manager.cpp]"]
  node_config["Device configuration<br/>[config_storage.cpp]"]
  node_uploader["Web uploader<br/>[web_uploader.cpp]"]
end

subgraph group_ingest["Ingestion and storage"]
  node_api["Event API<br/>[route.ts]"]
  node_eventstore["Runtime event store<br/>[event-store.ts]"]
  node_serverclient["Server Supabase client<br/>[server.ts]"]
end

subgraph group_state["Application services"]
  node_fivsedstate["Telemetry state<br/>[fivsed-context.tsx]"]
  node_auth["Authentication state<br/>[auth-context.tsx]"]
  node_supabaseclient["Browser Supabase client<br/>[client.ts]"]
  node_types["Domain data types<br/>[fivsed.ts]"]
end

subgraph group_operations["Operator workflows"]
  node_dashboard["Dashboard<br/>[page.tsx]"]
  node_integrity["Integrity history<br/>[page.tsx]"]
  node_events["Security events<br/>[page.tsx]"]
  node_alerts["Alert management<br/>[page.tsx]"]
  node_devices["Device inventory<br/>[page.tsx]"]
  node_device_detail["Device detail<br/>[page.tsx]"]
  node_history["Verification history<br/>[page.tsx]"]
  node_architecture["Architecture view<br/>[page.tsx]"]
  node_settings["Account settings<br/>[page.tsx]"]
  node_profile["Operator profile<br/>[page.tsx]"]
  node_login["Sign-in page<br/>[page.tsx]"]
end

subgraph group_presentation["Shared presentation"]
  node_layout["Protected app shell<br/>[AppLayout.tsx]"]
  node_integritycard["Integrity status card"]
  node_chart["Security event chart"]
  node_timeline["Verification timeline"]
  node_alertbanner["Active alerts banner"]
  node_devicecard["Device card<br/>[DeviceCard.tsx]"]
  node_eventmodal["Event details modal"]
  node_archview["Interactive architecture"]
end

node_operator(("Security operator"))
node_stm32{{"STM32 authority"}}
node_database[("Supabase PostgreSQL")]

node_stm32 -->|"sends decision"| node_esp32
node_esp32 -->|"uploads telemetry"| node_api
node_esp32 -.->|"uses protocol"| node_uart
node_esp32 -.->|"uses network"| node_wifi
node_esp32 -.->|"loads settings"| node_config
node_esp32 -.->|"dispatches upload"| node_uploader
node_api -->|"records events"| node_eventstore
node_api -->|"clears runtime data"| node_eventstore
node_api -->|"gets client"| node_serverclient
node_api -->|"clears persisted data"| node_database
node_serverclient -->|"connects to"| node_database
node_fivsedstate -->|"fetches telemetry"| node_api
node_fivsedstate -->|"acknowledges alerts"| node_api
node_fivsedstate -->|"queries and subscribes"| node_supabaseclient
node_supabaseclient -.->|"reads live data"| node_database
node_auth -->|"authenticates users"| node_supabaseclient
node_fivsedstate -->|"uses domain types"| node_types
node_auth -->|"uses profile types"| node_types
node_dashboard -->|"reads telemetry"| node_fivsedstate
node_integrity -->|"reads verifications"| node_fivsedstate
node_events -->|"reads events"| node_fivsedstate
node_alerts -->|"reads alerts"| node_fivsedstate
node_devices -->|"reads devices"| node_fivsedstate
node_device_detail -->|"reads device data"| node_fivsedstate
node_history -->|"reads history"| node_fivsedstate
node_dashboard -->|"renders within"| node_layout
node_integrity -->|"renders within"| node_layout
node_events -->|"renders within"| node_layout
node_alerts -->|"renders within"| node_layout
node_devices -->|"renders within"| node_layout
node_device_detail -->|"renders within"| node_layout
node_history -->|"renders within"| node_layout
node_architecture -->|"renders within"| node_layout
node_settings -->|"renders within"| node_layout
node_profile -->|"renders within"| node_layout
node_login -->|"uses authentication"| node_auth
node_layout -->|"checks access"| node_auth
node_dashboard -->|"renders status"| node_integritycard
node_dashboard -->|"renders chart"| node_chart
node_dashboard -->|"renders timeline"| node_timeline
node_dashboard -->|"renders alerts"| node_alertbanner
node_devices -->|"renders cards"| node_devicecard
node_events -->|"opens details"| node_eventmodal
node_architecture -->|"renders diagram"| node_archview
node_operator -->|"signs in"| node_login
node_operator -.->|"monitors system"| node_dashboard

click node_esp32 "https://github.com/vickyadityaraj/fivsed/blob/main/firmware/esp32_fivsed_uploader/main.cpp"
click node_uart "https://github.com/vickyadityaraj/fivsed/blob/main/firmware/esp32_fivsed_uploader/uart_protocol.cpp"
click node_wifi "https://github.com/vickyadityaraj/fivsed/blob/main/firmware/esp32_fivsed_uploader/wifi_manager.cpp"
click node_config "https://github.com/vickyadityaraj/fivsed/blob/main/firmware/esp32_fivsed_uploader/config_storage.cpp"
click node_uploader "https://github.com/vickyadityaraj/fivsed/blob/main/firmware/esp32_fivsed_uploader/web_uploader.cpp"
click node_api "https://github.com/vickyadityaraj/fivsed/blob/main/app/api/events/route.ts"
click node_eventstore "https://github.com/vickyadityaraj/fivsed/blob/main/lib/server/event-store.ts"
click node_serverclient "https://github.com/vickyadityaraj/fivsed/blob/main/lib/supabase/server.ts"
click node_fivsedstate "https://github.com/vickyadityaraj/fivsed/blob/main/lib/context/fivsed-context.tsx"
click node_auth "https://github.com/vickyadityaraj/fivsed/blob/main/lib/context/auth-context.tsx"
click node_supabaseclient "https://github.com/vickyadityaraj/fivsed/blob/main/lib/supabase/client.ts"
click node_types "https://github.com/vickyadityaraj/fivsed/blob/main/types/fivsed.ts"
click node_dashboard "https://github.com/vickyadityaraj/fivsed/blob/main/app/dashboard/page.tsx"
click node_integrity "https://github.com/vickyadityaraj/fivsed/blob/main/app/integrity/page.tsx"
click node_events "https://github.com/vickyadityaraj/fivsed/blob/main/app/events/page.tsx"
click node_alerts "https://github.com/vickyadityaraj/fivsed/blob/main/app/alerts/page.tsx"
click node_devices "https://github.com/vickyadityaraj/fivsed/blob/main/app/devices/page.tsx"
click node_device_detail "https://github.com/vickyadityaraj/fivsed/blob/main/app/devices/%5Bid%5D/page.tsx"
click node_history "https://github.com/vickyadityaraj/fivsed/blob/main/app/history/page.tsx"
click node_architecture "https://github.com/vickyadityaraj/fivsed/blob/main/app/architecture/page.tsx"
click node_settings "https://github.com/vickyadityaraj/fivsed/blob/main/app/settings/page.tsx"
click node_profile "https://github.com/vickyadityaraj/fivsed/blob/main/app/profile/page.tsx"
click node_login "https://github.com/vickyadityaraj/fivsed/blob/main/app/login/page.tsx"
click node_layout "https://github.com/vickyadityaraj/fivsed/blob/main/components/layout/AppLayout.tsx"
click node_integritycard "https://github.com/vickyadityaraj/fivsed/blob/main/components/dashboard/IntegrityStatusCard.tsx"
click node_chart "https://github.com/vickyadityaraj/fivsed/blob/main/components/dashboard/SecurityEventChart.tsx"
click node_timeline "https://github.com/vickyadityaraj/fivsed/blob/main/components/dashboard/VerificationTimeline.tsx"
click node_alertbanner "https://github.com/vickyadityaraj/fivsed/blob/main/components/dashboard/ActiveAlertsBanner.tsx"
click node_devicecard "https://github.com/vickyadityaraj/fivsed/blob/main/components/devices/DeviceCard.tsx"
click node_eventmodal "https://github.com/vickyadityaraj/fivsed/blob/main/components/events/EventDetailsModal.tsx"
click node_archview "https://github.com/vickyadityaraj/fivsed/blob/main/components/architecture/InteractiveArchitecture.tsx"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_esp32,node_uart,node_wifi,node_config,node_uploader toneBlue
class node_api,node_eventstore,node_serverclient,node_database toneAmber
class node_fivsedstate,node_auth,node_supabaseclient,node_types toneMint
class node_dashboard,node_integrity,node_events,node_alerts,node_devices,node_device_detail,node_history,node_architecture,node_settings,node_profile,node_login toneRose
class node_layout,node_integritycard,node_chart,node_timeline,node_alertbanner,node_devicecard,node_eventmodal,node_archview,node_operator,node_stm32 toneIndigo
```

## Components

### Embedded telemetry

- [ESP32 controller](https://github.com/vickyadityaraj/fivsed/blob/main/firmware/esp32_fivsed_uploader/main.cpp): `firmware/esp32_fivsed_uploader/main.cpp`
- [UART protocol](https://github.com/vickyadityaraj/fivsed/blob/main/firmware/esp32_fivsed_uploader/uart_protocol.cpp): `firmware/esp32_fivsed_uploader/uart_protocol.cpp`
- [Wi-Fi manager](https://github.com/vickyadityaraj/fivsed/blob/main/firmware/esp32_fivsed_uploader/wifi_manager.cpp): `firmware/esp32_fivsed_uploader/wifi_manager.cpp`
- [Device configuration](https://github.com/vickyadityaraj/fivsed/blob/main/firmware/esp32_fivsed_uploader/config_storage.cpp): `firmware/esp32_fivsed_uploader/config_storage.cpp`
- [Web uploader](https://github.com/vickyadityaraj/fivsed/blob/main/firmware/esp32_fivsed_uploader/web_uploader.cpp): `firmware/esp32_fivsed_uploader/web_uploader.cpp`

### Ingestion and storage

- [Event API](https://github.com/vickyadityaraj/fivsed/blob/main/app/api/events/route.ts): `app/api/events/route.ts`
- [Runtime event store](https://github.com/vickyadityaraj/fivsed/blob/main/lib/server/event-store.ts): `lib/server/event-store.ts`
- [Server Supabase client](https://github.com/vickyadityaraj/fivsed/blob/main/lib/supabase/server.ts): `lib/supabase/server.ts`

### Application services

- [Telemetry state](https://github.com/vickyadityaraj/fivsed/blob/main/lib/context/fivsed-context.tsx): `lib/context/fivsed-context.tsx`
- [Authentication state](https://github.com/vickyadityaraj/fivsed/blob/main/lib/context/auth-context.tsx): `lib/context/auth-context.tsx`
- [Browser Supabase client](https://github.com/vickyadityaraj/fivsed/blob/main/lib/supabase/client.ts): `lib/supabase/client.ts`
- [Domain data types](https://github.com/vickyadityaraj/fivsed/blob/main/types/fivsed.ts): `types/fivsed.ts`

### Operator workflows

- [Dashboard](https://github.com/vickyadityaraj/fivsed/blob/main/app/dashboard/page.tsx): `app/dashboard/page.tsx`
- [Integrity history](https://github.com/vickyadityaraj/fivsed/blob/main/app/integrity/page.tsx): `app/integrity/page.tsx`
- [Security events](https://github.com/vickyadityaraj/fivsed/blob/main/app/events/page.tsx): `app/events/page.tsx`
- [Alert management](https://github.com/vickyadityaraj/fivsed/blob/main/app/alerts/page.tsx): `app/alerts/page.tsx`
- [Device inventory](https://github.com/vickyadityaraj/fivsed/blob/main/app/devices/page.tsx): `app/devices/page.tsx`
- [Device detail](https://github.com/vickyadityaraj/fivsed/blob/main/app/devices/%5Bid%5D/page.tsx): `app/devices/[id]/page.tsx`
- [Verification history](https://github.com/vickyadityaraj/fivsed/blob/main/app/history/page.tsx): `app/history/page.tsx`
- [Architecture view](https://github.com/vickyadityaraj/fivsed/blob/main/app/architecture/page.tsx): `app/architecture/page.tsx`
- [Account settings](https://github.com/vickyadityaraj/fivsed/blob/main/app/settings/page.tsx): `app/settings/page.tsx`
- [Operator profile](https://github.com/vickyadityaraj/fivsed/blob/main/app/profile/page.tsx): `app/profile/page.tsx`
- [Sign-in page](https://github.com/vickyadityaraj/fivsed/blob/main/app/login/page.tsx): `app/login/page.tsx`

### Shared presentation

- [Protected app shell](https://github.com/vickyadityaraj/fivsed/blob/main/components/layout/AppLayout.tsx): `components/layout/AppLayout.tsx`
- [Integrity status card](https://github.com/vickyadityaraj/fivsed/blob/main/components/dashboard/IntegrityStatusCard.tsx): `components/dashboard/IntegrityStatusCard.tsx`
- [Security event chart](https://github.com/vickyadityaraj/fivsed/blob/main/components/dashboard/SecurityEventChart.tsx): `components/dashboard/SecurityEventChart.tsx`
- [Verification timeline](https://github.com/vickyadityaraj/fivsed/blob/main/components/dashboard/VerificationTimeline.tsx): `components/dashboard/VerificationTimeline.tsx`
- [Active alerts banner](https://github.com/vickyadityaraj/fivsed/blob/main/components/dashboard/ActiveAlertsBanner.tsx): `components/dashboard/ActiveAlertsBanner.tsx`
- [Device card](https://github.com/vickyadityaraj/fivsed/blob/main/components/devices/DeviceCard.tsx): `components/devices/DeviceCard.tsx`
- [Event details modal](https://github.com/vickyadityaraj/fivsed/blob/main/components/events/EventDetailsModal.tsx): `components/events/EventDetailsModal.tsx`
- [Interactive architecture](https://github.com/vickyadityaraj/fivsed/blob/main/components/architecture/InteractiveArchitecture.tsx): `components/architecture/InteractiveArchitecture.tsx`

### Other components

- **Security operator**
- **STM32 authority**
- **Supabase PostgreSQL**

## Connections

- STM32 authority → ESP32 controller: sends decision (evidence: `README.md`)
- ESP32 controller → Event API: uploads telemetry (evidence: `README.md`)
- ESP32 controller → UART protocol: uses protocol
- ESP32 controller → Wi-Fi manager: uses network
- ESP32 controller → Device configuration: loads settings
- ESP32 controller → Web uploader: dispatches upload
- Event API → Runtime event store: records events (evidence: `app/api/events/route.ts`)
- Event API → Runtime event store: clears runtime data (evidence: `app/api/events/route.ts`)
- Event API → Server Supabase client: gets client (evidence: `app/api/events/route.ts`)
- Event API → Supabase PostgreSQL: clears persisted data (evidence: `app/api/events/route.ts`)
- Server Supabase client → Supabase PostgreSQL: connects to (evidence: `lib/supabase/server.ts`)
- Telemetry state → Event API: fetches telemetry (evidence: `lib/context/fivsed-context.tsx`)
- Telemetry state → Event API: acknowledges alerts (evidence: `lib/context/fivsed-context.tsx`)
- Telemetry state → Browser Supabase client: queries and subscribes (evidence: `lib/context/fivsed-context.tsx`)
- Browser Supabase client → Supabase PostgreSQL: reads live data
- Authentication state → Browser Supabase client: authenticates users (evidence: `lib/context/auth-context.tsx`)
- Telemetry state → Domain data types: uses domain types (evidence: `lib/context/fivsed-context.tsx`)
- Authentication state → Domain data types: uses profile types (evidence: `lib/context/auth-context.tsx`)
- Dashboard → Telemetry state: reads telemetry (evidence: `app/dashboard/page.tsx`)
- Integrity history → Telemetry state: reads verifications (evidence: `app/integrity/page.tsx`)
- Security events → Telemetry state: reads events (evidence: `app/events/page.tsx`)
- Alert management → Telemetry state: reads alerts (evidence: `app/alerts/page.tsx`)
- Device inventory → Telemetry state: reads devices (evidence: `app/devices/page.tsx`)
- Device detail → Telemetry state: reads device data (evidence: `app/devices/[id]/page.tsx`)
- Verification history → Telemetry state: reads history (evidence: `app/history/page.tsx`)
- Dashboard → Protected app shell: renders within (evidence: `app/dashboard/page.tsx`)
- Integrity history → Protected app shell: renders within (evidence: `app/integrity/page.tsx`)
- Security events → Protected app shell: renders within (evidence: `app/events/page.tsx`)
- Alert management → Protected app shell: renders within (evidence: `app/alerts/page.tsx`)
- Device inventory → Protected app shell: renders within (evidence: `app/devices/page.tsx`)
- Device detail → Protected app shell: renders within (evidence: `app/devices/[id]/page.tsx`)
- Verification history → Protected app shell: renders within (evidence: `app/history/page.tsx`)
- Architecture view → Protected app shell: renders within (evidence: `app/architecture/page.tsx`)
- Account settings → Protected app shell: renders within (evidence: `app/settings/page.tsx`)
- Operator profile → Protected app shell: renders within (evidence: `app/profile/page.tsx`)
- Sign-in page → Authentication state: uses authentication (evidence: `app/login/page.tsx`)
- Protected app shell → Authentication state: checks access (evidence: `components/layout/AppLayout.tsx`)
- Dashboard → Integrity status card: renders status (evidence: `app/dashboard/page.tsx`)
- Dashboard → Security event chart: renders chart (evidence: `app/dashboard/page.tsx`)
- Dashboard → Verification timeline: renders timeline (evidence: `app/dashboard/page.tsx`)
- Dashboard → Active alerts banner: renders alerts (evidence: `app/dashboard/page.tsx`)
- Device inventory → Device card: renders cards (evidence: `app/devices/page.tsx`)
- Security events → Event details modal: opens details (evidence: `app/events/page.tsx`)
- Architecture view → Interactive architecture: renders diagram (evidence: `app/architecture/page.tsx`)
- Security operator → Sign-in page: signs in (evidence: `README.md`)
- Security operator → Dashboard: monitors system
