# mahidahmed/timbersim architecture

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

- Interactive diagram: https://gitdiagram.com/mahidahmed/timbersim
- Repository: https://github.com/mahidahmed/timbersim

## Overview

TimberSim is a Flask application for exploring timber-supply logistics through discrete-event simulation. Users configure a single- or multi-sawmill run; the web application coordinates simulation replications, gathers site and mill performance metrics, and presents results in dashboards and PDF reports. The simulation models truck movements, logging-site loading, sawmill scale and crane operations, breakdowns, and diversions. The README also describes mapping and regional data. The graph reflects documented and indexed relationships; unsampled routes and implementation details are not inferred.

Main entry points: [`app.py`](https://github.com/mahidahmed/timbersim/blob/main/app.py) (Flask routes), [`sawmill_model.py`](https://github.com/mahidahmed/timbersim/blob/main/sawmill_model.py) (Simulation model), [`run_replication.py`](https://github.com/mahidahmed/timbersim/blob/main/run_replication.py) (Replication runner), [`sawmill_utilities.py`](https://github.com/mahidahmed/timbersim/blob/main/sawmill_utilities.py) (Result aggregation)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_webapp["Flask routes<br/>[app.py]"]
  node_pages["Web pages"]
end

subgraph group_simulation["Simulation domain"]
  node_engine["Simulation model<br/>[sawmill_model.py]"]
  node_entities["Supply-chain entities<br/>[entities.py]"]
  node_state["Travel metrics"]
end

subgraph group_analysis["Results and reporting"]
  node_replications["Replication runner<br/>[run_replication.py]"]
  node_utilities["Result aggregation"]
  node_pdf["PDF reporting<br/>[app.py]"]
end

subgraph group_inputs["Simulation inputs"]
  node_data["Timber and map data"]
end

node_user(("Browser user"))

node_user -->|"configures runs"| node_webapp
node_webapp -->|"renders pages"| node_pages
node_webapp -->|"runs replications"| node_replications
node_webapp -->|"aggregates results"| node_utilities
node_replications -->|"creates and runs"| node_engine
node_engine -->|"instantiates entities"| node_entities
node_engine -->|"combines metrics"| node_utilities
node_replications -->|"reads travel metrics"| node_state
node_webapp -->|"generates reports"| node_pdf
node_webapp -.->|"loads simulation data"| node_data

click node_webapp "https://github.com/mahidahmed/timbersim/blob/main/app.py"
click node_pages "https://github.com/mahidahmed/timbersim/tree/main/templates"
click node_engine "https://github.com/mahidahmed/timbersim/blob/main/sawmill_model.py"
click node_entities "https://github.com/mahidahmed/timbersim/blob/main/entities.py"
click node_state "https://github.com/mahidahmed/timbersim/blob/main/global_variables.py"
click node_replications "https://github.com/mahidahmed/timbersim/blob/main/run_replication.py"
click node_utilities "https://github.com/mahidahmed/timbersim/blob/main/sawmill_utilities.py"
click node_data "https://github.com/mahidahmed/timbersim/tree/main/data"
click node_pdf "https://github.com/mahidahmed/timbersim/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_webapp,node_pages,node_user toneBlue
class node_engine,node_entities,node_state toneAmber
class node_replications,node_utilities,node_pdf toneMint
class node_data toneRose
```

## Components

### Web application

- [Flask routes](https://github.com/mahidahmed/timbersim/blob/main/app.py): `app.py`
- [Web pages](https://github.com/mahidahmed/timbersim/tree/main/templates): `templates`

### Simulation domain

- [Simulation model](https://github.com/mahidahmed/timbersim/blob/main/sawmill_model.py): `sawmill_model.py`
- [Supply-chain entities](https://github.com/mahidahmed/timbersim/blob/main/entities.py): `entities.py`
- [Travel metrics](https://github.com/mahidahmed/timbersim/blob/main/global_variables.py): `global_variables.py`

### Results and reporting

- [Replication runner](https://github.com/mahidahmed/timbersim/blob/main/run_replication.py): `run_replication.py`
- [Result aggregation](https://github.com/mahidahmed/timbersim/blob/main/sawmill_utilities.py): `sawmill_utilities.py`
- [PDF reporting](https://github.com/mahidahmed/timbersim/blob/main/app.py): `app.py`

### Simulation inputs

- [Timber and map data](https://github.com/mahidahmed/timbersim/tree/main/data): `data`

### Other components

- **Browser user**

## Connections

- Browser user → Flask routes: configures runs (evidence: `README.md`)
- Flask routes → Web pages: renders pages (evidence: `app.py`)
- Flask routes → Replication runner: runs replications (evidence: `app.py`)
- Flask routes → Result aggregation: aggregates results (evidence: `app.py`)
- Replication runner → Simulation model: creates and runs (evidence: `run_replication.py`)
- Simulation model → Supply-chain entities: instantiates entities (evidence: `sawmill_model.py`)
- Simulation model → Result aggregation: combines metrics (evidence: `sawmill_model.py`)
- Replication runner → Travel metrics: reads travel metrics (evidence: `run_replication.py`)
- Flask routes → PDF reporting: generates reports (evidence: `README.md`)
- Flask routes → Timber and map data: loads simulation data
