# cyetheguy/uark_csce_eeg_capstone architecture

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

- Interactive diagram: https://gitdiagram.com/cyetheguy/uark_csce_eeg_capstone
- Repository: https://github.com/cyetheguy/uark_csce_eeg_capstone

## Overview

DreamRT is a wireless EEG sleep-monitoring product: users sign in, connect a BLE device, view live EEG and sleep-stage feedback, and review or export saved sessions. The React reader is the user-facing hub; its hooks call the Python API, which coordinates BLE acquisition, signal processing, and encrypted per-user session storage. Review and sleep statistics are additional product stages. The README documents the device-to-tracer workflow, while sampled code confirms key UI/API and backend calls; unsampled subsystem links are omitted or marked unverified.

Main entry points: [`frontend/src/functions/components/EEGDataReader/EEGDataReader.tsx`](https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/frontend/src/functions/components/EEGDataReader/EEGDataReader.tsx) (EEG reader), [`backend/main.py`](https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/backend/main.py) (HTTP API), [`backend/data_processor.py`](https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/backend/data_processor.py) (Signal processing), [`backend/crypto_ops.py`](https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/backend/crypto_ops.py) (Account & encryption)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_reader["Reader UI"]
  node_app["Desktop app shell<br/>[main.cjs]"]
  node_routes["Reader routes<br/>[App.tsx]"]
  node_reader_ui["EEG reader<br/>[EEGDataReader.tsx]"]
  node_auth_ui["Login state<br/>[useAuth.ts]"]
  node_sleep_ui["Session data<br/>[useSleepData.ts]"]
  node_visualization["EEG visualization"]
  node_session_view["Session controls<br/>[SessionPanel.tsx]"]
  node_stage_ui["Stage estimation"]
end

subgraph group_api["Backend API"]
  node_api_server["HTTP API<br/>[main.py]"]
end

subgraph group_signal["Acquisition &amp; Analysis"]
  node_ble_service["BLE bridge<br/>[ble_comms.py]"]
  node_processor["Signal processing<br/>[data_processor.py]"]
  node_stage_backend["Sleep staging"]
end

subgraph group_security["Accounts &amp; Sessions"]
  node_account_crypto["Account &amp; encryption<br/>[crypto_ops.py]"]
  node_session_store[("Encrypted sessions<br/>[crypto_ops.py]")]
  node_runtime_data["Runtime data paths<br/>[runtime_paths.py]"]
end

subgraph group_hardware["EEG Hardware"]
  node_device["EEG device firmware<br/>[main.c]"]
  node_ble_client["Desktop BLE client"]
  node_ble_device_module["Device BLE module"]
  node_security_cpp["Desktop security"]
  node_bigint["Big integer math<br/>[BigInt.h]"]
end

node_user(("EEG user"))

node_user -->|"opens"| node_app
node_app -.->|"hosts"| node_routes
node_routes -->|"routes to"| node_reader_ui
node_user -->|"uses"| node_reader_ui
node_reader_ui -->|"uses"| node_auth_ui
node_reader_ui -->|"uses"| node_sleep_ui
node_reader_ui -->|"renders"| node_visualization
node_reader_ui -->|"renders"| node_session_view
node_sleep_ui -->|"computes labels"| node_stage_ui
node_auth_ui -->|"logs in"| node_api_server
node_sleep_ui -->|"requests sessions"| node_api_server
node_api_server -->|"authenticates"| node_account_crypto
node_api_server -->|"requests plots"| node_processor
node_api_server -->|"gets samples"| node_ble_service
node_api_server -->|"exports samples"| node_processor
node_processor -->|"decrypts sessions"| node_account_crypto
node_processor -->|"uses staging"| node_stage_backend
node_account_crypto -->|"reads and writes"| node_session_store
node_account_crypto -.->|"resolves directories"| node_runtime_data
node_device -.->|"streams BLE data"| node_ble_client
node_ble_client -.->|"relays samples"| node_ble_service
node_device -.->|"BLE interface"| node_ble_device_module
node_security_cpp -.->|"uses arithmetic"| node_bigint

click node_app "https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/frontend/electron/main.cjs"
click node_routes "https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/frontend/src/App.tsx"
click node_reader_ui "https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/frontend/src/functions/components/EEGDataReader/EEGDataReader.tsx"
click node_auth_ui "https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/frontend/src/functions/components/EEGDataReader/hooks/useAuth.ts"
click node_sleep_ui "https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/frontend/src/functions/components/EEGDataReader/hooks/useSleepData.ts"
click node_visualization "https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/frontend/src/functions/components/EEGDataReader/components/VisualizationPanel.tsx"
click node_session_view "https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/frontend/src/functions/components/EEGDataReader/components/SessionPanel.tsx"
click node_stage_ui "https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/frontend/src/functions/components/EEGDataReader/utils/sleepStagesFromAmplitude.ts"
click node_api_server "https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/backend/main.py"
click node_ble_service "https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/backend/ble_comms.py"
click node_processor "https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/backend/data_processor.py"
click node_stage_backend "https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/backend/sleep_stages_amplitude.py"
click node_account_crypto "https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/backend/crypto_ops.py"
click node_session_store "https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/backend/crypto_ops.py"
click node_runtime_data "https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/backend/runtime_paths.py"
click node_device "https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/firmware/main.c"
click node_ble_client "https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/backend/CommunicationManager/src/Desktop/ConnectionManager.cpp"
click node_ble_device_module "https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/backend/CommunicationManager/src/Device/DeviceBLEModule.cpp"
click node_security_cpp "https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/backend/CommunicationManager/src/Desktop/SecurityManager.cpp"
click node_bigint "https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/backend/CommunicationManager/include/Desktop/BigInt.h"

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_app,node_routes,node_reader_ui,node_auth_ui,node_sleep_ui,node_visualization,node_session_view,node_stage_ui,node_user toneBlue
class node_api_server toneAmber
class node_ble_service,node_processor,node_stage_backend toneMint
class node_account_crypto,node_session_store,node_runtime_data toneRose
class node_device,node_ble_client,node_ble_device_module,node_security_cpp,node_bigint toneIndigo
```

## Components

### Reader UI

- [Desktop app shell](https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/frontend/electron/main.cjs): `frontend/electron/main.cjs`
- [Reader routes](https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/frontend/src/App.tsx): `frontend/src/App.tsx`
- [EEG reader](https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/frontend/src/functions/components/EEGDataReader/EEGDataReader.tsx): `frontend/src/functions/components/EEGDataReader/EEGDataReader.tsx`
- [Login state](https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/frontend/src/functions/components/EEGDataReader/hooks/useAuth.ts): `frontend/src/functions/components/EEGDataReader/hooks/useAuth.ts`
- [Session data](https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/frontend/src/functions/components/EEGDataReader/hooks/useSleepData.ts): `frontend/src/functions/components/EEGDataReader/hooks/useSleepData.ts`
- [EEG visualization](https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/frontend/src/functions/components/EEGDataReader/components/VisualizationPanel.tsx): `frontend/src/functions/components/EEGDataReader/components/VisualizationPanel.tsx`
- [Session controls](https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/frontend/src/functions/components/EEGDataReader/components/SessionPanel.tsx): `frontend/src/functions/components/EEGDataReader/components/SessionPanel.tsx`
- [Stage estimation](https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/frontend/src/functions/components/EEGDataReader/utils/sleepStagesFromAmplitude.ts): `frontend/src/functions/components/EEGDataReader/utils/sleepStagesFromAmplitude.ts`

### Backend API

- [HTTP API](https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/backend/main.py): `backend/main.py`

### Acquisition & Analysis

- [BLE bridge](https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/backend/ble_comms.py): `backend/ble_comms.py`
- [Signal processing](https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/backend/data_processor.py): `backend/data_processor.py`
- [Sleep staging](https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/backend/sleep_stages_amplitude.py): `backend/sleep_stages_amplitude.py`

### Accounts & Sessions

- [Account & encryption](https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/backend/crypto_ops.py): `backend/crypto_ops.py`
- [Encrypted sessions](https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/backend/crypto_ops.py): `backend/crypto_ops.py`
- [Runtime data paths](https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/backend/runtime_paths.py): `backend/runtime_paths.py`

### EEG Hardware

- [EEG device firmware](https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/firmware/main.c): `firmware/main.c`
- [Desktop BLE client](https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/backend/CommunicationManager/src/Desktop/ConnectionManager.cpp): `backend/CommunicationManager/src/Desktop/ConnectionManager.cpp`
- [Device BLE module](https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/backend/CommunicationManager/src/Device/DeviceBLEModule.cpp): `backend/CommunicationManager/src/Device/DeviceBLEModule.cpp`
- [Desktop security](https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/backend/CommunicationManager/src/Desktop/SecurityManager.cpp): `backend/CommunicationManager/src/Desktop/SecurityManager.cpp`
- [Big integer math](https://github.com/cyetheguy/uark_csce_eeg_capstone/blob/main/backend/CommunicationManager/include/Desktop/BigInt.h): `backend/CommunicationManager/include/Desktop/BigInt.h`

### Other components

- **EEG user**

## Connections

- EEG user → Desktop app shell: opens
- Desktop app shell → Reader routes: hosts
- Reader routes → EEG reader: routes to (evidence: `frontend/src/App.tsx`)
- EEG user → EEG reader: uses
- EEG reader → Login state: uses (evidence: `frontend/src/functions/components/EEGDataReader/EEGDataReader.tsx`)
- EEG reader → Session data: uses (evidence: `frontend/src/functions/components/EEGDataReader/EEGDataReader.tsx`)
- EEG reader → EEG visualization: renders (evidence: `frontend/src/functions/components/EEGDataReader/EEGDataReader.tsx`)
- EEG reader → Session controls: renders (evidence: `frontend/src/functions/components/EEGDataReader/EEGDataReader.tsx`)
- Session data → Stage estimation: computes labels (evidence: `frontend/src/functions/components/EEGDataReader/hooks/useSleepData.ts`)
- Login state → HTTP API: logs in (evidence: `frontend/src/functions/components/EEGDataReader/hooks/useAuth.ts`)
- Session data → HTTP API: requests sessions (evidence: `frontend/src/functions/components/EEGDataReader/hooks/useSleepData.ts`)
- HTTP API → Account & encryption: authenticates (evidence: `backend/main.py`)
- HTTP API → Signal processing: requests plots (evidence: `backend/main.py`)
- HTTP API → BLE bridge: gets samples (evidence: `backend/main.py`)
- HTTP API → Signal processing: exports samples (evidence: `backend/main.py`)
- Signal processing → Account & encryption: decrypts sessions (evidence: `backend/data_processor.py`)
- Signal processing → Sleep staging: uses staging (evidence: `backend/data_processor.py`)
- Account & encryption → Encrypted sessions: reads and writes (evidence: `backend/crypto_ops.py`)
- Account & encryption → Runtime data paths: resolves directories (evidence: `backend/crypto_ops.py`)
- EEG device firmware → Desktop BLE client: streams BLE data
- Desktop BLE client → BLE bridge: relays samples
- EEG device firmware → Device BLE module: BLE interface
- Desktop security → Big integer math: uses arithmetic
