# adithiyaks/glucosense architecture

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

- Interactive diagram: https://gitdiagram.com/adithiyaks/glucosense
- Repository: https://github.com/adithiyaks/glucosense

## Overview

GlucoSense combines a Flutter app scaffold, a live Next.js monitoring dashboard, and FastAPI services for WebSocket broadcasting and persisted telemetry. The primary path is hardware-to-browser live streaming; a separate REST path ingests and retrieves patient telemetry through MongoDB. The README documents the frontend’s intended API and WebSocket connections, but the sampled dashboard source does not show those calls. The backend also includes a serial bridge and model-training code; their integration with the runtime flow is not established by the available evidence.

Main entry points: [`frontend/src/app/page.tsx`](https://github.com/adithiyaks/glucosense/blob/main/frontend/src/app/page.tsx) (Dashboard page), [`backend/app.py`](https://github.com/adithiyaks/glucosense/blob/main/backend/app.py) (WebSocket broadcaster), [`backend/main.py`](https://github.com/adithiyaks/glucosense/blob/main/backend/main.py) (Telemetry REST API), [`frontend/src/components/dashboard/SensorDashboard.tsx`](https://github.com/adithiyaks/glucosense/blob/main/frontend/src/components/dashboard/SensorDashboard.tsx) (Sensor dashboard)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_clients["Client applications"]
  node_flutter["Flutter app scaffold"]
  node_dashboard_page["Dashboard page<br/>[page.tsx]"]
  node_sensor_dashboard["Sensor dashboard"]
  node_dashboard_cards["Dashboard visualizations"]
end

subgraph group_streaming["Live streaming"]
  node_ws_broadcast["WebSocket broadcaster<br/>[app.py]"]
end

subgraph group_telemetry["Telemetry API and storage"]
  node_rest_api["Telemetry REST API<br/>[main.py]"]
  node_mongo[("Telemetry collection")]
  node_test_injector["Interactive DB injector<br/>[check.py]"]
end

subgraph group_analytics["Model development"]
  node_model_training["Glucose model training<br/>[train_model.py]"]
end

subgraph group_hardware["Hardware integration"]
  node_serial_bridge["Serial bridge<br/>[serial_bridge.py]"]
end

node_patient(("Patient or clinician"))
node_hardware_device(("Edge device"))
node_browser(("Browser client"))

node_patient -.->|"uses"| node_flutter
node_patient -->|"views"| node_dashboard_page
node_dashboard_page -->|"renders"| node_sensor_dashboard
node_sensor_dashboard -.->|"presents"| node_dashboard_cards
node_hardware_device -->|"streams telemetry"| node_ws_broadcast
node_ws_broadcast -->|"broadcasts messages"| node_browser
node_browser -->|"connects"| node_ws_broadcast
node_hardware_device -->|"posts telemetry"| node_rest_api
node_rest_api -->|"inserts and queries"| node_mongo
node_dashboard_page -.->|"fetches latest"| node_rest_api
node_test_injector -->|"inserts test data"| node_mongo

click node_flutter "https://github.com/adithiyaks/glucosense/tree/main/app"
click node_dashboard_page "https://github.com/adithiyaks/glucosense/blob/main/frontend/src/app/page.tsx"
click node_sensor_dashboard "https://github.com/adithiyaks/glucosense/blob/main/frontend/src/components/dashboard/SensorDashboard.tsx"
click node_dashboard_cards "https://github.com/adithiyaks/glucosense/tree/main/frontend/src/components/dashboard"
click node_ws_broadcast "https://github.com/adithiyaks/glucosense/blob/main/backend/app.py"
click node_rest_api "https://github.com/adithiyaks/glucosense/blob/main/backend/main.py"
click node_serial_bridge "https://github.com/adithiyaks/glucosense/blob/main/backend/serial_bridge.py"
click node_model_training "https://github.com/adithiyaks/glucosense/blob/main/backend/ml_engine/train_model.py"
click node_test_injector "https://github.com/adithiyaks/glucosense/blob/main/backend/check.py"

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_flutter,node_dashboard_page,node_sensor_dashboard,node_dashboard_cards,node_browser toneBlue
class node_ws_broadcast toneAmber
class node_rest_api,node_mongo,node_test_injector toneMint
class node_model_training toneRose
class node_serial_bridge,node_patient,node_hardware_device toneIndigo
```

## Components

### Client applications

- [Flutter app scaffold](https://github.com/adithiyaks/glucosense/tree/main/app): `app`
- [Dashboard page](https://github.com/adithiyaks/glucosense/blob/main/frontend/src/app/page.tsx): `frontend/src/app/page.tsx`
- [Sensor dashboard](https://github.com/adithiyaks/glucosense/blob/main/frontend/src/components/dashboard/SensorDashboard.tsx): `frontend/src/components/dashboard/SensorDashboard.tsx`
- [Dashboard visualizations](https://github.com/adithiyaks/glucosense/tree/main/frontend/src/components/dashboard): `frontend/src/components/dashboard`

### Live streaming

- [WebSocket broadcaster](https://github.com/adithiyaks/glucosense/blob/main/backend/app.py): `backend/app.py`

### Telemetry API and storage

- [Telemetry REST API](https://github.com/adithiyaks/glucosense/blob/main/backend/main.py): `backend/main.py`
- **Telemetry collection**
- [Interactive DB injector](https://github.com/adithiyaks/glucosense/blob/main/backend/check.py): `backend/check.py`

### Model development

- [Glucose model training](https://github.com/adithiyaks/glucosense/blob/main/backend/ml_engine/train_model.py): `backend/ml_engine/train_model.py`

### Hardware integration

- [Serial bridge](https://github.com/adithiyaks/glucosense/blob/main/backend/serial_bridge.py): `backend/serial_bridge.py`

### Other components

- **Patient or clinician**
- **Edge device**
- **Browser client**

## Connections

- Patient or clinician → Flutter app scaffold: uses (evidence: `README.md`)
- Patient or clinician → Dashboard page: views (evidence: `README.md`)
- Dashboard page → Sensor dashboard: renders (evidence: `frontend/src/app/page.tsx`)
- Sensor dashboard → Dashboard visualizations: presents
- Edge device → WebSocket broadcaster: streams telemetry (evidence: `README.md`)
- WebSocket broadcaster → Browser client: broadcasts messages (evidence: `backend/app.py`)
- Browser client → WebSocket broadcaster: connects (evidence: `README.md`)
- Edge device → Telemetry REST API: posts telemetry (evidence: `README.md`)
- Telemetry REST API → Telemetry collection: inserts and queries (evidence: `backend/main.py`)
- Dashboard page → Telemetry REST API: fetches latest (evidence: `README.md`)
- Interactive DB injector → Telemetry collection: inserts test data (evidence: `README.md`)
