# sakethgottimukkula/t1dm architecture

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

- Interactive diagram: https://gitdiagram.com/sakethgottimukkula/t1dm
- Repository: https://github.com/sakethgottimukkula/t1dm

## Overview

Glucose Horizon forecasts CGM glucose at four horizons and presents forecasts and clinical safety information in a dashboard. The runtime path is the dashboard and REST API through feature construction and horizon-specific model inference; separate API capabilities support CSV prediction, backtesting, and case inspection. Training and offline evaluation produce model artifacts and benchmark metrics. Source excerpts establish backend calls and some data flow; the frontend-to-API connection is documented only at the product level, so that edge is dashed.

Main entry points: [`backend/app/main.py`](https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/app/main.py) (FastAPI routes), [`backend/app/features.py`](https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/app/features.py) (CGM features), [`backend/scripts/train_models.py`](https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/scripts/train_models.py) (Model training), [`backend/scripts/evaluate.py`](https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/scripts/evaluate.py) (Offline evaluation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Clinical experience"]
  node_dashboard["Clinical dashboard<br/>[script.js]"]
end

subgraph group_service["Forecast service"]
  node_api["FastAPI routes<br/>[main.py]"]
  node_contracts["Request schemas<br/>[schemas.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
  node_features["CGM features<br/>[features.py]"]
  node_predictor["Model inference<br/>[predictor.py]"]
  node_cases["Case inspection<br/>[casedata.py]"]
  node_time["Timestamp utilities<br/>[timeutil.py]"]
end

subgraph group_evaluation["Clinical evaluation"]
  node_backtest["Backtest metrics<br/>[metrics.py]"]
  node_ega["Clarke EGA<br/>[ega.py]"]
  node_metricsfile["Metrics validation<br/>[metricsfile.py]"]
  node_metricsdata["Evaluation metrics<br/>[metrics.json]"]
end

subgraph group_ml["Model lifecycle"]
  node_trainer["Model training<br/>[train_models.py]"]
  node_evaluator["Offline evaluation<br/>[evaluate.py]"]
  node_models["Horizon models"]
end

node_clinician(("Clinician"))

node_clinician -->|"uses"| node_dashboard
node_dashboard -.->|"requests forecasts"| node_api
node_api -->|"validates with"| node_contracts
node_api -->|"configures from"| node_config
node_api -->|"builds features"| node_features
node_api -->|"requests inference"| node_predictor
node_api -->|"loads cases"| node_cases
node_api -->|"evaluates forecasts"| node_backtest
node_api -->|"loads metrics"| node_metricsfile
node_cases -->|"parses timestamps"| node_time
node_predictor -->|"uses feature columns"| node_features
node_predictor -->|"loads and predicts"| node_models
node_backtest -->|"classifies zones"| node_ega
node_trainer -->|"builds features"| node_features
node_trainer -->|"evaluates zones"| node_ega
node_trainer -->|"writes models"| node_models
node_evaluator -->|"builds features"| node_features
node_evaluator -->|"evaluates saved models"| node_models
node_evaluator -->|"produces metrics"| node_metricsdata
node_metricsfile -.->|"reads metrics"| node_metricsdata

click node_dashboard "https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/Frontend/script.js"
click node_api "https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/app/main.py"
click node_contracts "https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/app/schemas.py"
click node_config "https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/app/config.py"
click node_features "https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/app/features.py"
click node_predictor "https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/app/predictor.py"
click node_cases "https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/app/casedata.py"
click node_time "https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/app/timeutil.py"
click node_backtest "https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/app/metrics.py"
click node_ega "https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/app/ega.py"
click node_metricsfile "https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/app/metricsfile.py"
click node_metricsdata "https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/models/metrics.json"
click node_trainer "https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/scripts/train_models.py"
click node_evaluator "https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/scripts/evaluate.py"
click node_models "https://github.com/sakethgottimukkula/t1dm/tree/sync/backend-model/backend/models"

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_dashboard toneBlue
class node_api,node_contracts,node_config,node_features,node_predictor,node_cases,node_time toneAmber
class node_backtest,node_ega,node_metricsfile,node_metricsdata toneMint
class node_trainer,node_evaluator,node_models toneRose
class node_clinician toneIndigo
```

## Components

### Clinical experience

- [Clinical dashboard](https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/Frontend/script.js): `Frontend/script.js`

### Forecast service

- [FastAPI routes](https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/app/main.py): `backend/app/main.py`
- [Request schemas](https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/app/schemas.py): `backend/app/schemas.py`
- [Runtime configuration](https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/app/config.py): `backend/app/config.py`
- [CGM features](https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/app/features.py): `backend/app/features.py`
- [Model inference](https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/app/predictor.py): `backend/app/predictor.py`
- [Case inspection](https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/app/casedata.py): `backend/app/casedata.py`
- [Timestamp utilities](https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/app/timeutil.py): `backend/app/timeutil.py`

### Clinical evaluation

- [Backtest metrics](https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/app/metrics.py): `backend/app/metrics.py`
- [Clarke EGA](https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/app/ega.py): `backend/app/ega.py`
- [Metrics validation](https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/app/metricsfile.py): `backend/app/metricsfile.py`
- [Evaluation metrics](https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/models/metrics.json): `backend/models/metrics.json`

### Model lifecycle

- [Model training](https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/scripts/train_models.py): `backend/scripts/train_models.py`
- [Offline evaluation](https://github.com/sakethgottimukkula/t1dm/blob/sync/backend-model/backend/scripts/evaluate.py): `backend/scripts/evaluate.py`
- [Horizon models](https://github.com/sakethgottimukkula/t1dm/tree/sync/backend-model/backend/models): `backend/models`

### Other components

- **Clinician**

## Connections

- Clinician → Clinical dashboard: uses (evidence: `README.md`)
- Clinical dashboard → FastAPI routes: requests forecasts
- FastAPI routes → Request schemas: validates with (evidence: `backend/app/main.py`)
- FastAPI routes → Runtime configuration: configures from (evidence: `backend/app/main.py`)
- FastAPI routes → CGM features: builds features (evidence: `backend/app/main.py`)
- FastAPI routes → Model inference: requests inference (evidence: `backend/app/main.py`)
- FastAPI routes → Case inspection: loads cases (evidence: `backend/app/main.py`)
- FastAPI routes → Backtest metrics: evaluates forecasts (evidence: `backend/app/main.py`)
- FastAPI routes → Metrics validation: loads metrics (evidence: `backend/app/main.py`)
- Case inspection → Timestamp utilities: parses timestamps (evidence: `backend/app/casedata.py`)
- Model inference → CGM features: uses feature columns (evidence: `backend/app/predictor.py`)
- Model inference → Horizon models: loads and predicts (evidence: `backend/app/predictor.py`)
- Backtest metrics → Clarke EGA: classifies zones (evidence: `backend/app/metrics.py`)
- Model training → CGM features: builds features (evidence: `backend/scripts/train_models.py`)
- Model training → Clarke EGA: evaluates zones (evidence: `backend/scripts/train_models.py`)
- Model training → Horizon models: writes models (evidence: `backend/scripts/train_models.py`)
- Offline evaluation → CGM features: builds features (evidence: `backend/scripts/evaluate.py`)
- Offline evaluation → Horizon models: evaluates saved models (evidence: `backend/scripts/evaluate.py`)
- Offline evaluation → Evaluation metrics: produces metrics (evidence: `README.md`)
- Metrics validation → Evaluation metrics: reads metrics
