# ll1370/rescueroute architecture

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

- Interactive diagram: https://gitdiagram.com/ll1370/rescueroute
- Repository: https://github.com/ll1370/rescueroute

## Overview

RescueRoute is a batch food-rescue scheduling and evaluation engine. An operator runs the CLI with a JSON dataset; the loader validates and builds domain records, then the CLI runs FIFO and urgency-first greedy schedules. Both strategies share feasibility checks and mutable capacity/pickup state. The CLI compares metrics and presents decision explanations, with an optional report export. The graph reflects the sampled modules and README-documented capabilities; it does not assume connections for unsampled code.

Main entry points: [`main.py`](https://github.com/ll1370/rescueroute/blob/main/main.py) (Application CLI), [`reports.py`](https://github.com/ll1370/rescueroute/blob/main/reports.py) (Comparison and export), [`loader.py`](https://github.com/ll1370/rescueroute/blob/main/loader.py) (Data loader), [`scheduler_common.py`](https://github.com/ll1370/rescueroute/blob/main/scheduler_common.py) (Donation processing)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_input["Input and domain"]
  node_json_data["JSON dataset<br/>[sample.json]"]
  node_loader["Data loader<br/>[loader.py]"]
  node_validation["Input validation<br/>[validation.py]"]
  node_models["Domain records<br/>[models.py]"]
end

subgraph group_scheduling["Scheduling"]
  node_fifo["FIFO scheduler<br/>[fifo.py]"]
  node_greedy["Urgency scheduler<br/>[greedy.py]"]
  node_common["Donation processing"]
  node_matching["Feasibility and state<br/>[matching.py]"]
end

subgraph group_evaluation["Evaluation and explanation"]
  node_metrics["Metrics and deltas<br/>[metrics.py]"]
  node_reports["Comparison and export<br/>[reports.py]"]
  node_explain["Decision explanations<br/>[explain.py]"]
end

subgraph group_interface["CLI and output"]
  node_cli["Application CLI<br/>[main.py]"]
  node_terminal["Terminal output"]
  node_report_file["Exported report"]
end

node_operator(("Operator"))

node_operator -->|"runs"| node_cli
node_json_data -->|"loads"| node_loader
node_cli -->|"loads data"| node_loader
node_loader -->|"validates"| node_validation
node_loader -->|"builds records"| node_models
node_cli -->|"runs baseline"| node_fifo
node_cli -->|"runs strategy"| node_greedy
node_fifo -->|"processes donations"| node_common
node_fifo -->|"initializes state"| node_matching
node_greedy -->|"processes donations"| node_common
node_greedy -->|"initializes state"| node_matching
node_common -->|"finds feasible match"| node_matching
node_common -->|"creates assignments"| node_models
node_cli -->|"computes and compares"| node_metrics
node_metrics -->|"reads records"| node_models
node_cli -->|"formats and exports"| node_reports
node_reports -->|"formats reasons"| node_explain
node_reports -->|"reads report data"| node_models
node_cli -->|"prints results"| node_terminal
node_reports -->|"writes report"| node_report_file
node_cli -->|"prints explanations"| node_terminal
node_operator -.->|"provides input"| node_json_data

click node_json_data "https://github.com/ll1370/rescueroute/blob/main/data/sample.json"
click node_loader "https://github.com/ll1370/rescueroute/blob/main/loader.py"
click node_validation "https://github.com/ll1370/rescueroute/blob/main/validation.py"
click node_models "https://github.com/ll1370/rescueroute/blob/main/models.py"
click node_fifo "https://github.com/ll1370/rescueroute/blob/main/fifo.py"
click node_greedy "https://github.com/ll1370/rescueroute/blob/main/greedy.py"
click node_common "https://github.com/ll1370/rescueroute/blob/main/scheduler_common.py"
click node_matching "https://github.com/ll1370/rescueroute/blob/main/matching.py"
click node_metrics "https://github.com/ll1370/rescueroute/blob/main/metrics.py"
click node_reports "https://github.com/ll1370/rescueroute/blob/main/reports.py"
click node_explain "https://github.com/ll1370/rescueroute/blob/main/explain.py"
click node_cli "https://github.com/ll1370/rescueroute/blob/main/main.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_json_data,node_loader,node_validation,node_models toneBlue
class node_fifo,node_greedy,node_common,node_matching toneAmber
class node_metrics,node_reports,node_explain toneMint
class node_cli,node_terminal,node_report_file toneRose
class node_operator toneIndigo
```

## Components

### Input and domain

- [JSON dataset](https://github.com/ll1370/rescueroute/blob/main/data/sample.json): `data/sample.json`
- [Data loader](https://github.com/ll1370/rescueroute/blob/main/loader.py): `loader.py`
- [Input validation](https://github.com/ll1370/rescueroute/blob/main/validation.py): `validation.py`
- [Domain records](https://github.com/ll1370/rescueroute/blob/main/models.py): `models.py`

### Scheduling

- [FIFO scheduler](https://github.com/ll1370/rescueroute/blob/main/fifo.py): `fifo.py`
- [Urgency scheduler](https://github.com/ll1370/rescueroute/blob/main/greedy.py): `greedy.py`
- [Donation processing](https://github.com/ll1370/rescueroute/blob/main/scheduler_common.py): `scheduler_common.py`
- [Feasibility and state](https://github.com/ll1370/rescueroute/blob/main/matching.py): `matching.py`

### Evaluation and explanation

- [Metrics and deltas](https://github.com/ll1370/rescueroute/blob/main/metrics.py): `metrics.py`
- [Comparison and export](https://github.com/ll1370/rescueroute/blob/main/reports.py): `reports.py`
- [Decision explanations](https://github.com/ll1370/rescueroute/blob/main/explain.py): `explain.py`

### CLI and output

- [Application CLI](https://github.com/ll1370/rescueroute/blob/main/main.py): `main.py`
- **Terminal output**
- **Exported report**

### Other components

- **Operator**

## Connections

- Operator → Application CLI: runs (evidence: `main.py`)
- JSON dataset → Data loader: loads
- Application CLI → Data loader: loads data (evidence: `main.py`)
- Data loader → Input validation: validates (evidence: `loader.py`)
- Data loader → Domain records: builds records (evidence: `loader.py`)
- Application CLI → FIFO scheduler: runs baseline (evidence: `main.py`)
- Application CLI → Urgency scheduler: runs strategy (evidence: `main.py`)
- FIFO scheduler → Donation processing: processes donations (evidence: `fifo.py`)
- FIFO scheduler → Feasibility and state: initializes state (evidence: `fifo.py`)
- Urgency scheduler → Donation processing: processes donations (evidence: `greedy.py`)
- Urgency scheduler → Feasibility and state: initializes state (evidence: `greedy.py`)
- Donation processing → Feasibility and state: finds feasible match (evidence: `scheduler_common.py`)
- Donation processing → Domain records: creates assignments (evidence: `scheduler_common.py`)
- Application CLI → Metrics and deltas: computes and compares (evidence: `main.py`)
- Metrics and deltas → Domain records: reads records (evidence: `metrics.py`)
- Application CLI → Comparison and export: formats and exports (evidence: `main.py`)
- Comparison and export → Decision explanations: formats reasons (evidence: `reports.py`)
- Comparison and export → Domain records: reads report data (evidence: `reports.py`)
- Application CLI → Terminal output: prints results (evidence: `main.py`)
- Comparison and export → Exported report: writes report (evidence: `reports.py`)
- Application CLI → Terminal output: prints explanations (evidence: `main.py`)
- Operator → JSON dataset: provides input
