# normangw/streamlit_demo architecture

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

- Interactive diagram: https://gitdiagram.com/normangw/streamlit_demo
- Repository: https://github.com/normangw/streamlit_demo
- Video tour (about a minute): https://gitdiagram.com/normangw/streamlit_demo/video

## Overview

This is a small Streamlit teaching tool for exploring how shipment-risk scores, business costs, and expedite capacity affect decisions. A student adjusts a scenario, model, and threshold; the app presents decision metrics and visual comparisons across five lesson tabs. The synthetic-data module generates the fixed-seed shipment history and provides the metric calculations, while a matching CSV is available to students. The main app excerpt is partial, so some tab-specific implementation links are documented rather than verified in source.

Main entry points: [`app.py`](https://github.com/normangw/streamlit_demo/blob/main/app.py) (Streamlit app), [`expedite_data.py`](https://github.com/normangw/streamlit_demo/blob/main/expedite_data.py) (Metric functions), [`shipments.csv`](https://github.com/normangw/streamlit_demo/blob/main/shipments.csv) (Student CSV)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_classroom["Classroom interaction"]
  node_streamlit_app["Streamlit app<br/>[app.py]"]
  node_scenario_controls["Scenario controls<br/>[app.py]"]
end

subgraph group_data["Shipment data"]
  node_shipment_generator["Shipment generator<br/>[expedite_data.py]"]
  node_shipment_csv["Student CSV<br/>[shipments.csv]"]
end

subgraph group_analysis["Decision analytics"]
  node_metric_functions["Metric functions<br/>[expedite_data.py]"]
end

subgraph group_lesson["Lesson views"]
  node_threshold_view["Threshold explorer<br/>[app.py]"]
  node_round_one["Shipment round<br/>[app.py]"]
  node_model_showdown["Model showdown<br/>[app.py]"]
  node_calibration_view["Calibration view<br/>[app.py]"]
  node_data_view["Data view<br/>[app.py]"]
end

node_student(("Student"))

node_student -->|"uses"| node_streamlit_app
node_student -->|"adjusts"| node_scenario_controls
node_streamlit_app -.->|"generates data"| node_shipment_generator
node_shipment_generator -->|"writes data"| node_shipment_csv
node_streamlit_app -->|"calls metrics"| node_metric_functions
node_scenario_controls -->|"sets inputs"| node_threshold_view
node_streamlit_app -->|"renders"| node_threshold_view
node_streamlit_app -->|"renders"| node_round_one
node_streamlit_app -->|"renders"| node_model_showdown
node_streamlit_app -->|"renders"| node_calibration_view
node_streamlit_app -->|"renders"| node_data_view
node_threshold_view -->|"evaluates thresholds"| node_metric_functions
node_round_one -->|"scores picks"| node_metric_functions
node_model_showdown -->|"compares models"| node_metric_functions

click node_streamlit_app "https://github.com/normangw/streamlit_demo/blob/main/app.py"
click node_scenario_controls "https://github.com/normangw/streamlit_demo/blob/main/app.py"
click node_shipment_generator "https://github.com/normangw/streamlit_demo/blob/main/expedite_data.py"
click node_shipment_csv "https://github.com/normangw/streamlit_demo/blob/main/shipments.csv"
click node_metric_functions "https://github.com/normangw/streamlit_demo/blob/main/expedite_data.py"
click node_threshold_view "https://github.com/normangw/streamlit_demo/blob/main/app.py"
click node_round_one "https://github.com/normangw/streamlit_demo/blob/main/app.py"
click node_model_showdown "https://github.com/normangw/streamlit_demo/blob/main/app.py"
click node_calibration_view "https://github.com/normangw/streamlit_demo/blob/main/app.py"
click node_data_view "https://github.com/normangw/streamlit_demo/blob/main/app.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_streamlit_app,node_scenario_controls toneBlue
class node_shipment_generator,node_shipment_csv toneAmber
class node_metric_functions toneMint
class node_threshold_view,node_round_one,node_model_showdown,node_calibration_view,node_data_view toneRose
class node_student toneIndigo
```

## Components

### Classroom interaction

- [Streamlit app](https://github.com/normangw/streamlit_demo/blob/main/app.py): `app.py`
- [Scenario controls](https://github.com/normangw/streamlit_demo/blob/main/app.py): `app.py`

### Shipment data

- [Shipment generator](https://github.com/normangw/streamlit_demo/blob/main/expedite_data.py): `expedite_data.py`
- [Student CSV](https://github.com/normangw/streamlit_demo/blob/main/shipments.csv): `shipments.csv`

### Decision analytics

- [Metric functions](https://github.com/normangw/streamlit_demo/blob/main/expedite_data.py): `expedite_data.py`

### Lesson views

- [Threshold explorer](https://github.com/normangw/streamlit_demo/blob/main/app.py): `app.py`
- [Shipment round](https://github.com/normangw/streamlit_demo/blob/main/app.py): `app.py`
- [Model showdown](https://github.com/normangw/streamlit_demo/blob/main/app.py): `app.py`
- [Calibration view](https://github.com/normangw/streamlit_demo/blob/main/app.py): `app.py`
- [Data view](https://github.com/normangw/streamlit_demo/blob/main/app.py): `app.py`

### Other components

- **Student**

## Connections

- Student → Streamlit app: uses (evidence: `README.md`)
- Student → Scenario controls: adjusts (evidence: `README.md`)
- Streamlit app → Shipment generator: generates data (evidence: `app.py`)
- Shipment generator → Student CSV: writes data (evidence: `expedite_data.py`)
- Streamlit app → Metric functions: calls metrics (evidence: `app.py`)
- Scenario controls → Threshold explorer: sets inputs (evidence: `app.py`)
- Streamlit app → Threshold explorer: renders (evidence: `app.py`)
- Streamlit app → Shipment round: renders (evidence: `README.md`)
- Streamlit app → Model showdown: renders (evidence: `README.md`)
- Streamlit app → Calibration view: renders (evidence: `README.md`)
- Streamlit app → Data view: renders (evidence: `README.md`)
- Threshold explorer → Metric functions: evaluates thresholds (evidence: `app.py`)
- Shipment round → Metric functions: scores picks (evidence: `app.py`)
- Model showdown → Metric functions: compares models (evidence: `app.py`)
