# sinchana2612/renaltwin architecture

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

- Interactive diagram: https://gitdiagram.com/sinchana2612/renaltwin
- Repository: https://github.com/sinchana2612/renaltwin

## Overview

RenalTwin is a research prototype for maintaining longitudinal kidney-health twins and generating 365-day renal-risk estimates. The documented user workflow runs from twin creation and time-stamped observation entry through validation, twin-state calculation, readiness checks, feature construction, prediction, and dashboard presentation. The graph combines sampled API, feature, and model code with README-documented capabilities; the twin engine and dashboard implementations were not excerpted, so their internal call details are limited to documented relationships.

Main entry points: [`src/renaltwin/twin/engine.py`](https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/twin/engine.py) (Twin engine), [`src/renaltwin/api/main.py`](https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/api/main.py) (FastAPI), [`src/renaltwin/cli.py`](https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/cli.py) (Research CLI), [`src/renaltwin/features/assemble.py`](https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/features/assemble.py) (Feature assembly)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_dashboard["Streamlit dashboard<br/>[app.py]"]
  node_cli["Research CLI<br/>[cli.py]"]
end

subgraph group_backend["Twin backend"]
  node_api["FastAPI<br/>[main.py]"]
  node_twin_engine["Twin engine<br/>[engine.py]"]
  node_unit_validation["Unit conversion<br/>[units.py]"]
  node_egfr_state["eGFR and CKD stage<br/>[egfr.py]"]
  node_config["Runtime configuration<br/>[config.py]"]
end

subgraph group_analytics["Risk analytics"]
  node_feature_assembly["Feature assembly<br/>[assemble.py]"]
  node_clinical_features["Clinical features"]
  node_sensor_features["Sensor features<br/>[sensor_features.py]"]
  node_predictor["Risk prediction<br/>[predictor.py]"]
  node_model_training["Model training<br/>[train.py]"]
end

subgraph group_storage["Persistence"]
  node_database[("Twin and risk store<br/>[store.py]")]
end

node_user(("Research user"))

node_user -->|"uses"| node_dashboard
node_dashboard -->|"sends HTTP requests"| node_api
node_api -->|"routes twin operations"| node_twin_engine
node_api -->|"initializes and deletes"| node_database
node_api -->|"loads model"| node_predictor
node_api -->|"gets artifact paths"| node_config
node_twin_engine -->|"persists twin data"| node_database
node_twin_engine -->|"normalizes observation units"| node_unit_validation
node_twin_engine -->|"derives CKD stage"| node_egfr_state
node_twin_engine -->|"builds prediction features"| node_feature_assembly
node_twin_engine -->|"runs ready predictions"| node_predictor
node_feature_assembly -->|"builds clinical features"| node_clinical_features
node_feature_assembly -->|"builds sensor features"| node_sensor_features
node_cli -->|"gets data paths"| node_config
node_cli -->|"starts training"| node_model_training
node_cli -->|"initializes store"| node_database
node_cli -->|"seeds demo twin"| node_twin_engine

click node_dashboard "https://github.com/sinchana2612/renaltwin/blob/main/dashboard/app.py"
click node_api "https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/api/main.py"
click node_twin_engine "https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/twin/engine.py"
click node_unit_validation "https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/units.py"
click node_egfr_state "https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/egfr.py"
click node_feature_assembly "https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/features/assemble.py"
click node_clinical_features "https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/features/clinical_features.py"
click node_sensor_features "https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/features/sensor_features.py"
click node_predictor "https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/ml/predictor.py"
click node_model_training "https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/ml/train.py"
click node_cli "https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/cli.py"
click node_config "https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/config.py"
click node_database "https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/db/store.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_dashboard,node_cli,node_user toneBlue
class node_api,node_twin_engine,node_unit_validation,node_egfr_state,node_config toneAmber
class node_feature_assembly,node_clinical_features,node_sensor_features,node_predictor,node_model_training toneMint
class node_database toneRose
```

## Components

### User experience

- [Streamlit dashboard](https://github.com/sinchana2612/renaltwin/blob/main/dashboard/app.py): `dashboard/app.py`
- [Research CLI](https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/cli.py): `src/renaltwin/cli.py`

### Twin backend

- [FastAPI](https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/api/main.py): `src/renaltwin/api/main.py`
- [Twin engine](https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/twin/engine.py): `src/renaltwin/twin/engine.py`
- [Unit conversion](https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/units.py): `src/renaltwin/units.py`
- [eGFR and CKD stage](https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/egfr.py): `src/renaltwin/egfr.py`
- [Runtime configuration](https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/config.py): `src/renaltwin/config.py`

### Risk analytics

- [Feature assembly](https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/features/assemble.py): `src/renaltwin/features/assemble.py`
- [Clinical features](https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/features/clinical_features.py): `src/renaltwin/features/clinical_features.py`
- [Sensor features](https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/features/sensor_features.py): `src/renaltwin/features/sensor_features.py`
- [Risk prediction](https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/ml/predictor.py): `src/renaltwin/ml/predictor.py`
- [Model training](https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/ml/train.py): `src/renaltwin/ml/train.py`

### Persistence

- [Twin and risk store](https://github.com/sinchana2612/renaltwin/blob/main/src/renaltwin/db/store.py): `src/renaltwin/db/store.py`

### Other components

- **Research user**

## Connections

- Research user → Streamlit dashboard: uses (evidence: `README.md`)
- Streamlit dashboard → FastAPI: sends HTTP requests (evidence: `README.md`)
- FastAPI → Twin engine: routes twin operations (evidence: `src/renaltwin/api/main.py`)
- FastAPI → Twin and risk store: initializes and deletes (evidence: `src/renaltwin/api/main.py`)
- FastAPI → Risk prediction: loads model (evidence: `src/renaltwin/api/main.py`)
- FastAPI → Runtime configuration: gets artifact paths (evidence: `src/renaltwin/api/main.py`)
- Twin engine → Twin and risk store: persists twin data (evidence: `README.md`)
- Twin engine → Unit conversion: normalizes observation units (evidence: `README.md`)
- Twin engine → eGFR and CKD stage: derives CKD stage (evidence: `README.md`)
- Twin engine → Feature assembly: builds prediction features (evidence: `README.md`)
- Twin engine → Risk prediction: runs ready predictions (evidence: `README.md`)
- Feature assembly → Clinical features: builds clinical features (evidence: `src/renaltwin/features/assemble.py`)
- Feature assembly → Sensor features: builds sensor features (evidence: `src/renaltwin/features/assemble.py`)
- Research CLI → Runtime configuration: gets data paths (evidence: `src/renaltwin/cli.py`)
- Research CLI → Model training: starts training (evidence: `src/renaltwin/cli.py`)
- Research CLI → Twin and risk store: initializes store (evidence: `src/renaltwin/cli.py`)
- Research CLI → Twin engine: seeds demo twin (evidence: `src/renaltwin/cli.py`)
