# torn1apart/salesreportlab architecture

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

- Interactive diagram: https://gitdiagram.com/torn1apart/salesreportlab
- Repository: https://github.com/torn1apart/salesreportlab

## Overview

Sales Report Lab is a Streamlit application for processing purchase-delivery batches and comparing full daily-report rebuilds with incremental updates, including duplicate deliveries and late purchases. Users select the demo CSV or upload a CSV, process or replay batches, and inspect daily totals and timing comparisons. A companion experiment tool generates streams, verifies results against SQLite, benchmarks runtime and memory, and writes result artifacts. The app and core source are excerpted; experiment excerpts are partial, so links for its omitted command handling and output details rely only on the visible code.

Main entry points: [`app.py`](https://github.com/torn1apart/salesreportlab/blob/main/app.py) (Streamlit app), [`experiments.py`](https://github.com/torn1apart/salesreportlab/blob/main/experiments.py) (Benchmark runner), [`sales/core.py`](https://github.com/torn1apart/salesreportlab/blob/main/sales/core.py) (Full rebuild), [`data/demo.csv`](https://github.com/torn1apart/salesreportlab/blob/main/data/demo.csv) (Demo CSV)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Interactive reporting"]
  node_ui["Streamlit app<br/>[app.py]"]
  node_demo["Demo CSV<br/>[demo.csv]"]
end

subgraph group_sales["Sales processing"]
  node_csv["CSV batch loader<br/>[data.py]"]
  node_rebuild["Full rebuild<br/>[core.py]"]
  node_incremental["Incremental report<br/>[core.py]"]
end

subgraph group_experiments["Experiments"]
  node_benchmark["Benchmark runner<br/>[experiments.py]"]
  node_streamgen["Stream generator<br/>[experiments.py]"]
  node_verification["Correctness checks<br/>[experiments.py]"]
  node_measurement["Time and memory<br/>[experiments.py]"]
  node_artifacts["Benchmark results"]
end

node_user(("User"))
node_sqlite[("SQLite oracle")]

node_user -->|"uses"| node_ui
node_ui -->|"reads"| node_demo
node_ui -->|"loads batches"| node_csv
node_ui -->|"rebuilds report"| node_rebuild
node_ui -->|"applies batch"| node_incremental
node_benchmark -->|"creates cases"| node_streamgen
node_benchmark -->|"checks results"| node_verification
node_benchmark -->|"measures methods"| node_measurement
node_verification -->|"compares totals"| node_sqlite
node_verification -->|"checks updates"| node_incremental
node_verification -->|"checks rebuild"| node_rebuild
node_measurement -->|"times updates"| node_incremental
node_measurement -->|"times rebuilds"| node_rebuild
node_benchmark -->|"writes results"| node_artifacts

click node_ui "https://github.com/torn1apart/salesreportlab/blob/main/app.py"
click node_demo "https://github.com/torn1apart/salesreportlab/blob/main/data/demo.csv"
click node_csv "https://github.com/torn1apart/salesreportlab/blob/main/sales/data.py"
click node_rebuild "https://github.com/torn1apart/salesreportlab/blob/main/sales/core.py"
click node_incremental "https://github.com/torn1apart/salesreportlab/blob/main/sales/core.py"
click node_benchmark "https://github.com/torn1apart/salesreportlab/blob/main/experiments.py"
click node_streamgen "https://github.com/torn1apart/salesreportlab/blob/main/experiments.py"
click node_verification "https://github.com/torn1apart/salesreportlab/blob/main/experiments.py"
click node_measurement "https://github.com/torn1apart/salesreportlab/blob/main/experiments.py"
click node_artifacts "https://github.com/torn1apart/salesreportlab/tree/main/results"

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_ui,node_demo,node_user toneBlue
class node_csv,node_rebuild,node_incremental,node_sqlite toneAmber
class node_benchmark,node_streamgen,node_verification,node_measurement,node_artifacts toneMint
```

## Components

### Interactive reporting

- [Streamlit app](https://github.com/torn1apart/salesreportlab/blob/main/app.py): `app.py`
- [Demo CSV](https://github.com/torn1apart/salesreportlab/blob/main/data/demo.csv): `data/demo.csv`

### Sales processing

- [CSV batch loader](https://github.com/torn1apart/salesreportlab/blob/main/sales/data.py): `sales/data.py`
- [Full rebuild](https://github.com/torn1apart/salesreportlab/blob/main/sales/core.py): `sales/core.py`
- [Incremental report](https://github.com/torn1apart/salesreportlab/blob/main/sales/core.py): `sales/core.py`

### Experiments

- [Benchmark runner](https://github.com/torn1apart/salesreportlab/blob/main/experiments.py): `experiments.py`
- [Stream generator](https://github.com/torn1apart/salesreportlab/blob/main/experiments.py): `experiments.py`
- [Correctness checks](https://github.com/torn1apart/salesreportlab/blob/main/experiments.py): `experiments.py`
- [Time and memory](https://github.com/torn1apart/salesreportlab/blob/main/experiments.py): `experiments.py`
- [Benchmark results](https://github.com/torn1apart/salesreportlab/tree/main/results): `results`

### Other components

- **User**
- **SQLite oracle**

## Connections

- User → Streamlit app: uses (evidence: `app.py`)
- Streamlit app → Demo CSV: reads (evidence: `app.py`)
- Streamlit app → CSV batch loader: loads batches (evidence: `app.py`)
- Streamlit app → Full rebuild: rebuilds report (evidence: `app.py`)
- Streamlit app → Incremental report: applies batch (evidence: `app.py`)
- Benchmark runner → Stream generator: creates cases (evidence: `experiments.py`)
- Benchmark runner → Correctness checks: checks results (evidence: `experiments.py`)
- Benchmark runner → Time and memory: measures methods (evidence: `experiments.py`)
- Correctness checks → SQLite oracle: compares totals (evidence: `experiments.py`)
- Correctness checks → Incremental report: checks updates (evidence: `experiments.py`)
- Correctness checks → Full rebuild: checks rebuild (evidence: `experiments.py`)
- Time and memory → Incremental report: times updates (evidence: `experiments.py`)
- Time and memory → Full rebuild: times rebuilds (evidence: `experiments.py`)
- Benchmark runner → Benchmark results: writes results (evidence: `experiments.py`)
