# tanmay7264/twin-nagar architecture

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

- Interactive diagram: https://gitdiagram.com/tanmay7264/twin-nagar
- Repository: https://github.com/tanmay7264/twin-nagar

## Overview

Twin Nagar is a browser-based isometric city and glucose digital twin. The user explores Asha’s day, changes meals or activities in the Twin Lab, compares whole-day glucose outcomes, and can replay the plan with alerts and guard actions. The graph preserves the city, interiors, scenario configuration, simulation, forecasting, and risk-detection capabilities described in the README. Source excerpts show the main module calls; unsampled details are represented only where documented.

Main entry points: [`city.js`](https://github.com/tanmay7264/twin-nagar/blob/main/city.js) (Asha and HUD), [`world.js`](https://github.com/tanmay7264/twin-nagar/blob/main/world.js) (World engine), [`interiors.js`](https://github.com/tanmay7264/twin-nagar/blob/main/interiors.js) (Building interiors), [`cityscape.js`](https://github.com/tanmay7264/twin-nagar/blob/main/cityscape.js) (City fabric)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["City experience"]
  node_world["World engine<br/>[world.js]"]
  node_citylife["Asha and HUD<br/>[city.js]"]
  node_lab["Twin Lab<br/>[city.js]"]
  node_scenarios["Day scenarios<br/>[world.config.js]"]
end

subgraph group_twin["Glucose twin"]
  node_twinmodel["Glucose model<br/>[twin.js]"]
  node_risk["Alerts and guard<br/>[twin.js]"]
end

subgraph group_visuals["City rendering"]
  node_cityfabric["City fabric<br/>[cityscape.js]"]
  node_interiors["Building interiors<br/>[interiors.js]"]
  node_people["People and poses<br/>[figures.js]"]
end

node_user(("Player"))

node_user -->|"explores"| node_world
node_world -->|"starts"| node_citylife
node_world -->|"builds"| node_cityfabric
node_world -->|"reads settings"| node_scenarios
node_citylife -->|"reads scenarios"| node_scenarios
node_citylife -->|"simulates days"| node_twinmodel
node_citylife -->|"checks risk"| node_risk
node_user -->|"changes plan"| node_lab
node_lab -->|"compares plans"| node_twinmodel
node_lab -->|"reports incidents"| node_risk
node_citylife -->|"builds interiors"| node_interiors
node_cityfabric -->|"creates figures"| node_people
node_interiors -->|"poses figures"| node_people
node_interiors -->|"reads floor height"| node_cityfabric

click node_world "https://github.com/tanmay7264/twin-nagar/blob/main/world.js"
click node_citylife "https://github.com/tanmay7264/twin-nagar/blob/main/city.js"
click node_lab "https://github.com/tanmay7264/twin-nagar/blob/main/city.js"
click node_scenarios "https://github.com/tanmay7264/twin-nagar/blob/main/world.config.js"
click node_twinmodel "https://github.com/tanmay7264/twin-nagar/blob/main/twin.js"
click node_risk "https://github.com/tanmay7264/twin-nagar/blob/main/twin.js"
click node_cityfabric "https://github.com/tanmay7264/twin-nagar/blob/main/cityscape.js"
click node_interiors "https://github.com/tanmay7264/twin-nagar/blob/main/interiors.js"
click node_people "https://github.com/tanmay7264/twin-nagar/blob/main/figures.js"

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_world,node_citylife,node_lab,node_scenarios toneBlue
class node_twinmodel,node_risk toneAmber
class node_cityfabric,node_interiors,node_people toneMint
class node_user toneIndigo
```

## Components

### City experience

- [World engine](https://github.com/tanmay7264/twin-nagar/blob/main/world.js): `world.js`
- [Asha and HUD](https://github.com/tanmay7264/twin-nagar/blob/main/city.js): `city.js`
- [Twin Lab](https://github.com/tanmay7264/twin-nagar/blob/main/city.js): `city.js`
- [Day scenarios](https://github.com/tanmay7264/twin-nagar/blob/main/world.config.js): `world.config.js`

### Glucose twin

- [Glucose model](https://github.com/tanmay7264/twin-nagar/blob/main/twin.js): `twin.js`
- [Alerts and guard](https://github.com/tanmay7264/twin-nagar/blob/main/twin.js): `twin.js`

### City rendering

- [City fabric](https://github.com/tanmay7264/twin-nagar/blob/main/cityscape.js): `cityscape.js`
- [Building interiors](https://github.com/tanmay7264/twin-nagar/blob/main/interiors.js): `interiors.js`
- [People and poses](https://github.com/tanmay7264/twin-nagar/blob/main/figures.js): `figures.js`

### Other components

- **Player**

## Connections

- Player → World engine: explores (evidence: `README.md`)
- World engine → Asha and HUD: starts (evidence: `world.js`)
- World engine → City fabric: builds (evidence: `world.js`)
- World engine → Day scenarios: reads settings (evidence: `world.js`)
- Asha and HUD → Day scenarios: reads scenarios (evidence: `city.js`)
- Asha and HUD → Glucose model: simulates days (evidence: `city.js`)
- Asha and HUD → Alerts and guard: checks risk (evidence: `city.js`)
- Player → Twin Lab: changes plan (evidence: `README.md`)
- Twin Lab → Glucose model: compares plans (evidence: `city.js`)
- Twin Lab → Alerts and guard: reports incidents (evidence: `README.md`)
- Asha and HUD → Building interiors: builds interiors (evidence: `city.js`)
- City fabric → People and poses: creates figures (evidence: `cityscape.js`)
- Building interiors → People and poses: poses figures (evidence: `interiors.js`)
- Building interiors → City fabric: reads floor height (evidence: `interiors.js`)
