# kwilliams351/late_trucks_report architecture

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

## Overview

This is a local Python truck-performance reporting tool that replaces a Tableau download step. Users provide export files, then the builder normalizes and scores truck records to produce an Excel action/report workbook, a Coordinator Hub and Trucking Pulse feed, and an updateable history store. The README documents these capabilities and the main data flow; the Python excerpt shows record cleanup, schedule adjustment, scoring, and report generation. Internal stages share one implementation file, so their boundaries are logical rather than separate modules.

Main entry points: [`late_trucks.py`](https://github.com/kwilliams351/late_trucks_report/blob/main/late_trucks.py) (Truck Report Builder), [`Output/late_trucks_feed.js`](https://github.com/kwilliams351/late_trucks_report/blob/main/Output/late_trucks_feed.js) (JSON Feed), [`hub/late_trucks_feed.js`](https://github.com/kwilliams351/late_trucks_report/blob/main/hub/late_trucks_feed.js) (Hub Feed Copy), [`sql/databricks_truck_orders.sql`](https://github.com/kwilliams351/late_trucks_report/blob/main/sql/databricks_truck_orders.sql) (Databricks Query)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Data Inputs"]
  node_tableau["Tableau Export"]
  node_sql_databricks["Databricks Query"]
  node_sql_teradata["Teradata Query"]
end

subgraph group_processing["Report Builder"]
  node_builder["Truck Report Builder<br/>[late_trucks.py]"]
  node_ingestion["Input Normalization<br/>[late_trucks.py]"]
  node_record_cleanup["Record Cleanup<br/>[late_trucks.py]"]
  node_schedule_scoring["Schedule and Scoring<br/>[late_trucks.py]"]
end

subgraph group_outputs["Reports and Feeds"]
  node_action_list["Action List<br/>[late_trucks.py]"]
  node_excel_report["Excel Report<br/>[late_trucks.py]"]
  node_json_feed["JSON Feed"]
  node_hub_feed["Hub Feed Copy"]
end

subgraph group_history["History and Consumers"]
  node_history_store[("Truck History<br/>[late_trucks.py]")]
  node_daily_rollup["Daily Rollup<br/>[late_trucks.py]"]
  node_history_summary["History Summary<br/>[late_trucks.py]"]
end

node_operator(("Report Operator"))
node_power_bi(("Power BI"))
node_coordinator_hub["Coordinator Hub"]
node_trucking_pulse(("Trucking Pulse"))

node_operator -->|"runs with exports"| node_builder
node_tableau -->|"provides input"| node_ingestion
node_sql_databricks -->|"query export input"| node_ingestion
node_sql_teradata -->|"query export input"| node_ingestion
node_builder -->|"normalizes inputs"| node_ingestion
node_builder -->|"cleans and deduplicates"| node_record_cleanup
node_builder -->|"scores truck records"| node_schedule_scoring
node_builder -->|"builds open items"| node_action_list
node_builder -->|"writes workbook"| node_excel_report
node_builder -->|"writes feed"| node_json_feed
node_builder -->|"copies feed"| node_hub_feed
node_builder -->|"updates history"| node_history_store
node_history_store -->|"produces rollup"| node_daily_rollup
node_history_store -->|"produces summary"| node_history_summary
node_history_store -->|"provides history"| node_power_bi
node_hub_feed -.->|"loads feed"| node_coordinator_hub
node_json_feed -->|"provides feed"| node_trucking_pulse

click node_sql_databricks "https://github.com/kwilliams351/late_trucks_report/blob/main/sql/databricks_truck_orders.sql"
click node_sql_teradata "https://github.com/kwilliams351/late_trucks_report/blob/main/sql/teradata_flight_legs.sql"
click node_builder "https://github.com/kwilliams351/late_trucks_report/blob/main/late_trucks.py"
click node_ingestion "https://github.com/kwilliams351/late_trucks_report/blob/main/late_trucks.py"
click node_record_cleanup "https://github.com/kwilliams351/late_trucks_report/blob/main/late_trucks.py"
click node_schedule_scoring "https://github.com/kwilliams351/late_trucks_report/blob/main/late_trucks.py"
click node_action_list "https://github.com/kwilliams351/late_trucks_report/blob/main/late_trucks.py"
click node_excel_report "https://github.com/kwilliams351/late_trucks_report/blob/main/late_trucks.py"
click node_json_feed "https://github.com/kwilliams351/late_trucks_report/blob/main/Output/late_trucks_feed.js"
click node_hub_feed "https://github.com/kwilliams351/late_trucks_report/blob/main/hub/late_trucks_feed.js"
click node_history_store "https://github.com/kwilliams351/late_trucks_report/blob/main/late_trucks.py"
click node_daily_rollup "https://github.com/kwilliams351/late_trucks_report/blob/main/late_trucks.py"
click node_history_summary "https://github.com/kwilliams351/late_trucks_report/blob/main/late_trucks.py"
click node_coordinator_hub "https://github.com/kwilliams351/late_trucks_report/blob/main/hub/Coordinator%20Hub.html"

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_tableau,node_sql_databricks,node_sql_teradata toneBlue
class node_builder,node_ingestion,node_record_cleanup,node_schedule_scoring toneAmber
class node_action_list,node_excel_report,node_json_feed,node_hub_feed toneMint
class node_history_store,node_daily_rollup,node_history_summary toneRose
class node_operator,node_power_bi,node_trucking_pulse toneIndigo
class node_coordinator_hub toneTeal
```

## Components

### Data Inputs

- **Tableau Export**
- [Databricks Query](https://github.com/kwilliams351/late_trucks_report/blob/main/sql/databricks_truck_orders.sql): `sql/databricks_truck_orders.sql`
- [Teradata Query](https://github.com/kwilliams351/late_trucks_report/blob/main/sql/teradata_flight_legs.sql): `sql/teradata_flight_legs.sql`

### Report Builder

- [Truck Report Builder](https://github.com/kwilliams351/late_trucks_report/blob/main/late_trucks.py): `late_trucks.py`
- [Input Normalization](https://github.com/kwilliams351/late_trucks_report/blob/main/late_trucks.py): `late_trucks.py`
- [Record Cleanup](https://github.com/kwilliams351/late_trucks_report/blob/main/late_trucks.py): `late_trucks.py`
- [Schedule and Scoring](https://github.com/kwilliams351/late_trucks_report/blob/main/late_trucks.py): `late_trucks.py`

### Reports and Feeds

- [Action List](https://github.com/kwilliams351/late_trucks_report/blob/main/late_trucks.py): `late_trucks.py`
- [Excel Report](https://github.com/kwilliams351/late_trucks_report/blob/main/late_trucks.py): `late_trucks.py`
- [JSON Feed](https://github.com/kwilliams351/late_trucks_report/blob/main/Output/late_trucks_feed.js): `Output/late_trucks_feed.js`
- [Hub Feed Copy](https://github.com/kwilliams351/late_trucks_report/blob/main/hub/late_trucks_feed.js): `hub/late_trucks_feed.js`

### History and Consumers

- [Truck History](https://github.com/kwilliams351/late_trucks_report/blob/main/late_trucks.py): `late_trucks.py`
- [Daily Rollup](https://github.com/kwilliams351/late_trucks_report/blob/main/late_trucks.py): `late_trucks.py`
- [History Summary](https://github.com/kwilliams351/late_trucks_report/blob/main/late_trucks.py): `late_trucks.py`

### Other components

- **Report Operator**
- **Power BI**
- [Coordinator Hub](https://github.com/kwilliams351/late_trucks_report/blob/main/hub/Coordinator%20Hub.html): `hub/Coordinator Hub.html`
- **Trucking Pulse**

## Connections

- Report Operator → Truck Report Builder: runs with exports (evidence: `README.md`)
- Tableau Export → Input Normalization: provides input (evidence: `README.md`)
- Databricks Query → Input Normalization: query export input (evidence: `README.md`)
- Teradata Query → Input Normalization: query export input (evidence: `README.md`)
- Truck Report Builder → Input Normalization: normalizes inputs (evidence: `late_trucks.py`)
- Truck Report Builder → Record Cleanup: cleans and deduplicates (evidence: `late_trucks.py`)
- Truck Report Builder → Schedule and Scoring: scores truck records (evidence: `late_trucks.py`)
- Truck Report Builder → Action List: builds open items (evidence: `late_trucks.py`)
- Truck Report Builder → Excel Report: writes workbook (evidence: `README.md`)
- Truck Report Builder → JSON Feed: writes feed (evidence: `README.md`)
- Truck Report Builder → Hub Feed Copy: copies feed (evidence: `README.md`)
- Truck Report Builder → Truck History: updates history (evidence: `README.md`)
- Truck History → Daily Rollup: produces rollup (evidence: `README.md`)
- Truck History → History Summary: produces summary (evidence: `README.md`)
- Truck History → Power BI: provides history (evidence: `README.md`)
- Hub Feed Copy → Coordinator Hub: loads feed
- JSON Feed → Trucking Pulse: provides feed (evidence: `README.md`)
