# rxntn/wlb architecture

> Architecture diagram of the GitHub repository rxntn/wlb, 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/rxntn/wlb
- Repository: https://github.com/rxntn/wlb

## Overview

WLB is a steel-coil wagon dispatch optimizer with a Flask web interface and a command-line entry point. Its main workflow accepts a coil CSV and a selected or generated wagon rake, then loads, classifies, orders, and assigns coils through a MILP optimizer; results include wagon-level assignments and operational KPIs for review and export. The graph preserves the catalog, compatibility, and constraint-rule capabilities. Some internal calls and UI details are inferred only from the README or module references; dashed links mark unverified relationships.

Main entry points: [`main.py`](https://github.com/rxntn/wlb/blob/main/main.py) (Optimizer Orchestrator), [`milp_solver.py`](https://github.com/rxntn/wlb/blob/main/milp_solver.py) (MILP Assignment), [`app.py`](https://github.com/rxntn/wlb/blob/main/app.py) (Web Application), [`wagon_catalog.py`](https://github.com/rxntn/wlb/blob/main/wagon_catalog.py) (Wagon Catalog)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["Web Interface"]
  node_web_app["Web Application<br/>[app.py]"]
  node_rake_setup["Rake Selection<br/>[app.py]"]
  node_result_review["Results Review and Export<br/>[app.py]"]
end

subgraph group_dispatch["Dispatch Workflow"]
  node_rake_generator["Rake Generator<br/>[rake_generator.py]"]
  node_optimizer["Optimizer Orchestrator<br/>[main.py]"]
  node_data_loader["Coil Data Loader<br/>[data_loader.py]"]
  node_classifier["Material Classifier"]
  node_coil_ordering["FIFO Coil Ordering<br/>[coil_pairing.py]"]
  node_milp_solver["MILP Assignment<br/>[milp_solver.py]"]
end

subgraph group_rules["Planning Rules"]
  node_wagon_catalog["Wagon Catalog<br/>[wagon_catalog.py]"]
  node_product_catalog["Product Compatibility<br/>[product_catalog.py]"]
  node_constraint_rules["Load Constraints"]
end

subgraph group_results["Results"]
  node_formatter["Assignment Formatter"]
  node_kpis["Dispatch KPIs<br/>[main.py]"]
end

node_operator(("Dispatch Operator"))
node_csv_input["Coil CSV"]

node_operator -->|"uses"| node_web_app
node_operator -->|"provides"| node_csv_input
node_csv_input -->|"uploads"| node_web_app
node_operator -->|"selects"| node_rake_setup
node_rake_setup -->|"generates"| node_rake_generator
node_rake_generator -->|"reads"| node_wagon_catalog
node_web_app -->|"runs"| node_optimizer
node_optimizer -->|"loads"| node_data_loader
node_optimizer -->|"classifies"| node_classifier
node_optimizer -->|"orders"| node_coil_ordering
node_optimizer -->|"solves"| node_milp_solver
node_milp_solver -->|"checks compatibility"| node_product_catalog
node_milp_solver -->|"uses wagon data"| node_wagon_catalog
node_optimizer -->|"formats assignments"| node_formatter
node_optimizer -->|"computes"| node_kpis
node_web_app -->|"shows and exports"| node_result_review
node_result_review -->|"presents results"| node_operator
node_constraint_rules -->|"reads"| node_wagon_catalog
node_milp_solver -.-> node_constraint_rules

click node_web_app "https://github.com/rxntn/wlb/blob/main/app.py"
click node_rake_setup "https://github.com/rxntn/wlb/blob/main/app.py"
click node_rake_generator "https://github.com/rxntn/wlb/blob/main/rake_generator.py"
click node_wagon_catalog "https://github.com/rxntn/wlb/blob/main/wagon_catalog.py"
click node_optimizer "https://github.com/rxntn/wlb/blob/main/main.py"
click node_data_loader "https://github.com/rxntn/wlb/blob/main/data_loader.py"
click node_classifier "https://github.com/rxntn/wlb/blob/main/material_classifier.py"
click node_coil_ordering "https://github.com/rxntn/wlb/blob/main/coil_pairing.py"
click node_milp_solver "https://github.com/rxntn/wlb/blob/main/milp_solver.py"
click node_product_catalog "https://github.com/rxntn/wlb/blob/main/product_catalog.py"
click node_constraint_rules "https://github.com/rxntn/wlb/blob/main/constraint_rules.py"
click node_formatter "https://github.com/rxntn/wlb/blob/main/output_formatter.py"
click node_kpis "https://github.com/rxntn/wlb/blob/main/main.py"
click node_result_review "https://github.com/rxntn/wlb/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_web_app,node_rake_setup,node_result_review toneBlue
class node_rake_generator,node_optimizer,node_data_loader,node_classifier,node_coil_ordering,node_milp_solver toneAmber
class node_wagon_catalog,node_product_catalog,node_constraint_rules toneMint
class node_formatter,node_kpis toneRose
class node_operator,node_csv_input toneIndigo
```

## Components

### Web Interface

- [Web Application](https://github.com/rxntn/wlb/blob/main/app.py): `app.py`
- [Rake Selection](https://github.com/rxntn/wlb/blob/main/app.py): `app.py`
- [Results Review and Export](https://github.com/rxntn/wlb/blob/main/app.py): `app.py`

### Dispatch Workflow

- [Rake Generator](https://github.com/rxntn/wlb/blob/main/rake_generator.py): `rake_generator.py`
- [Optimizer Orchestrator](https://github.com/rxntn/wlb/blob/main/main.py): `main.py`
- [Coil Data Loader](https://github.com/rxntn/wlb/blob/main/data_loader.py): `data_loader.py`
- [Material Classifier](https://github.com/rxntn/wlb/blob/main/material_classifier.py): `material_classifier.py`
- [FIFO Coil Ordering](https://github.com/rxntn/wlb/blob/main/coil_pairing.py): `coil_pairing.py`
- [MILP Assignment](https://github.com/rxntn/wlb/blob/main/milp_solver.py): `milp_solver.py`

### Planning Rules

- [Wagon Catalog](https://github.com/rxntn/wlb/blob/main/wagon_catalog.py): `wagon_catalog.py`
- [Product Compatibility](https://github.com/rxntn/wlb/blob/main/product_catalog.py): `product_catalog.py`
- [Load Constraints](https://github.com/rxntn/wlb/blob/main/constraint_rules.py): `constraint_rules.py`

### Results

- [Assignment Formatter](https://github.com/rxntn/wlb/blob/main/output_formatter.py): `output_formatter.py`
- [Dispatch KPIs](https://github.com/rxntn/wlb/blob/main/main.py): `main.py`

### Other components

- **Dispatch Operator**
- **Coil CSV**

## Connections

- Dispatch Operator → Web Application: uses (evidence: `README.md`)
- Dispatch Operator → Coil CSV: provides (evidence: `README.md`)
- Coil CSV → Web Application: uploads (evidence: `README.md`)
- Dispatch Operator → Rake Selection: selects (evidence: `README.md`)
- Rake Selection → Rake Generator: generates (evidence: `app.py`)
- Rake Generator → Wagon Catalog: reads (evidence: `rake_generator.py`)
- Web Application → Optimizer Orchestrator: runs (evidence: `app.py`)
- Optimizer Orchestrator → Coil Data Loader: loads (evidence: `main.py`)
- Optimizer Orchestrator → Material Classifier: classifies (evidence: `main.py`)
- Optimizer Orchestrator → FIFO Coil Ordering: orders (evidence: `main.py`)
- Optimizer Orchestrator → MILP Assignment: solves (evidence: `main.py`)
- MILP Assignment → Product Compatibility: checks compatibility (evidence: `milp_solver.py`)
- MILP Assignment → Wagon Catalog: uses wagon data (evidence: `milp_solver.py`)
- Optimizer Orchestrator → Assignment Formatter: formats assignments (evidence: `main.py`)
- Optimizer Orchestrator → Dispatch KPIs: computes (evidence: `main.py`)
- Web Application → Results Review and Export: shows and exports (evidence: `README.md`)
- Results Review and Export → Dispatch Operator: presents results (evidence: `README.md`)
- Load Constraints → Wagon Catalog: reads (evidence: `constraint_rules.py`)
- MILP Assignment → Load Constraints
