# daytonhaney/cleaners-app architecture

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

- Interactive diagram: https://gitdiagram.com/daytonhaney/cleaners-app
- Repository: https://github.com/daytonhaney/cleaners-app

## Overview

##### What this project is (type + purpose)
**Cleaners App** is a **single-node, console-based Python application** (not a web app) for a cleaning business to:
- register customers,
- process cleaning transactions (packages, square footage, discounts),
- store/retrieve data from a **local SQLite database**,
- produce daily summaries and exports (likely PDF),
- run with a **Rich TUI/CLI** experience.

It’s packaged to run locally or inside a container (Dockerfile / podman usage). The architecture is therefore best represented as a **modular monolith**: one process, multiple internal modules, one embedded database file.

##### How the file tree maps to architectural components
From the tree:

##### Entrypoints / runtime
- `main.py` (top-level) and `cleaners/main.py`: likely the main entrypoint(s).
- `cleaners/cli.py`, `cleaners/rich_ui.py`: user interaction layer.
- `cleaners/clean.py`: business operations around “cleaning packages” / pricing / labor.
- `cleaners/validation.py`: input/data validation boundary.
- `cleaners/db_stats.py`: reporting/summary computations (daily stats).
- `cleaners/pdf_export.py`: export boundary (PDF output).
- `cleaners/fake_data.py`: seed/demo data generation.
- `examples/demo.py`: usage example / demo run.
- `test_system.py`: end-to-end/system tests.

##### Data access / persistence
- `db/db_functions.py`: SQLite CRUD/data access layer.
- `db/__init__.py`: package.
- README says SQLite file `business_data.db` with auto creation/backup.
- `backup.sh` and `install.sh`: operational scripts (backup/install).
- `Dockerfile`: container packaging and runtime environment.
- `cleaners-app.1`: man page (distribution/documentation artifact).

##### Configuration / packaging
- `pyproject.toml`, `requirements.txt`: Python packaging and dependencies.

**Takeaway for diagramming:** the clean separation is **UI (Rich/CLI)** → **Domain services (pricing/transactions/summary)** → **Persistence (SQLite via db_functions)** plus **export/reporting/ops** side components.

##### What to extract from README (architecture hints)
The README explicitly tells you the “system context” and primary flows:
- Interactive console interface (so your “client” is a terminal user).
- Core domain: customer registration + transaction processing.
- Pricing rules: three packages, labor calculation per square foot, senior discount.
- SQLite DB with automatic creation and backup.
- Rich text UI.

##### System Context (Level 0 / C4 Context)
Show:
- **Actor:** “Office Staff / Operator (Terminal User)”
- **System:** “Cleaners App (Python console application)”
- **External dependencies:**
- “SQLite database file (business_data.db)”
- “Filesystem (backups, PDF exports)”
Optionally:
- “Container runtime (Podman/Docker)” as an environment boundary.

##### Container / Process View (Level 1)
Even though it’s one process, treat these as “logical containers”:
- “Console UI (Rich)” (cleaners/rich_ui.py + cli.py)
- “Application/Domain layer” (clean.py, validation.py, db_stats.py)
- “Persistence layer” (db/db_functions.py)
- “Export/Reporting” (pdf_export.py, fig.py)
- “SQLite DB file”

##### Component View (Level 2)
Break the domain into components aligned to modules/files:
- Transaction processing / package pricing (clean.py)
- Validation (validation.py)
- Summaries/Stats (db_stats.py)
- PDF Export (pdf_export.py)
- Data access gateway (db_functions.py)
- UI orchestrator (cli.py + rich_ui.py)
- App entry/orchestration (cleaners/main.py or top-level main.py)

This level is where you “separate into as many components as possible”.

##### Backup flow
- Terminal User / Ops → `backup.sh` → Filesystem (copy `business_data.db` to backup location)
or
- App → “Backup routine” (if implemented in Python) → Filesystem

##### Architectural patterns/design principles visibly present

- **Layered architecture**: UI → Domain → Persistence.
- **Repository/DAO style DB gateway**: `db/db_functions.py` as the boundary to SQLite.
- **Rule-based pricing engine** (simple): package selection + labor + senior discount.
- **Single-process monolith** with module boundaries (important to show that it is *not* networked).

- “Python 3.11”
- “Rich (TUI)”
- “SQLite (business_data.db)”
- “Container: Podman/Docker (optional runtime)”

## Diagram (Mermaid)

```mermaid
flowchart TD

%% =======================
%% System Context (Vertical)
%% =======================
U["Terminal User\n(Office Staff / Operator)"]:::actor

subgraph "Runtime Environment"
  R1["Local Machine\n(or Container Runtime)"]:::env
  DKR["Container Image\n(Docker/Podman)"]:::ops
end

subgraph "Cleaners App (Single Python Process)\nPython 3.11 • Console + Rich TUI"
  EP0["Entrypoint\nmain.py"]:::entry
  EP1["Package Entrypoint\ncleaners/main.py"]:::entry

  subgraph "UI Layer"
    CLI["CLI Orchestrator\n(cleaners/cli.py)"]:::ui
    RICH["Rich TUI Views\n(cleaners/rich_ui.py)"]:::ui
  end

  subgraph "Domain / Application Services"
    VAL["Input Validation\n(cleaners/validation.py)"]:::domain
    CLEAN["Transaction + Pricing Service\n(cleaners/clean.py)\n(packages • sqft • discounts)"]:::domain
    STATS["Daily Summary Service\n(cleaners/db_stats.py)"]:::domain
  end

  subgraph "Export / Reporting"
    PDF["PDF Export Service\n(cleaners/pdf_export.py)"]:::export
    FIG["Chart/Figure Helper\n(cleaners/fig.py)"]:::export
  end

  subgraph "Persistence Layer"
    DBFUN["SQLite DAO/Repository\n(db/db_functions.py)"]:::data
    DBPKG["DB Package\n(db/__init__.py)"]:::data
    APPPKG["App Package\n(cleaners/__init__.py)"]:::pkg
  end

  subgraph "Demo / Test Utilities"
    FAKE["Fake/Seed Data Generator\n(cleaners/fake_data.py)"]:::support
    DEMO["Demo Runner\n(examples/demo.py)"]:::support
    TESTS["System / E2E Tests\n(test_system.py)"]:::test
  end
end

DB[("SQLite DB File\nbusiness_data.db")]:::database
FS["Filesystem\n(PDF exports • backups)"]:::fs

subgraph "Ops / Packaging / Docs"
  BACKUP["Backup Script\n(backup.sh)"]:::ops
  INSTALL["Install/Setup Script\n(install.sh)"]:::ops
  MAN["Man Page\n(cleaners-app.1)"]:::docs
  PYPROJ["Build/Packaging Config\n(pyproject.toml)"]:::docs
  REQS["Dependencies\n(requirements.txt)"]:::docs
  README["Project Documentation\n(readme.md)"]:::docs
  TRES["Test Results Artifact\n(TEST_RESULTS.md)"]:::docs
end

%% =======================
%% Primary Flows
%% =======================
U -->|"run_interactive_console"| EP0
U -->|"run_interactive_console"| EP1

EP0 -->|"start_app"| CLI
EP1 -->|"start_app"| CLI

CLI -->|"render_views"| RICH

%% Transaction flow
CLI -->|"validate_input"| VAL
CLI -->|"process_transaction"| CLEAN
VAL -->|"validated_data"| CLEAN
CLEAN -->|"create_customer/insert_transaction"| DBFUN
DBFUN -->|"SQL_CRUD"| DB
DBFUN -->|"return_receipt_data"| CLEAN
CLEAN -->|"confirmation/receipt"| CLI
RICH -->|"display_receipt/confirmation"| U

%% Daily summary/reporting flow
CLI -->|"request_daily_summary"| STATS
STATS -->|"query_stats"| DBFUN
STATS -->|"summary_results"| CLI
RICH -->|"display_daily_summary"| U
STATS -->|"export_daily_summary"| PDF
PDF -->|"write_PDF"| FS
FIG -->|"generate_figures"| PDF

%% Persistence package structure
DBPKG -->|"exposes"| DBFUN
APPPKG -->|"contains"| CLI
APPPKG -->|"contains"| RICH
APPPKG -->|"contains"| CLEAN
APPPKG -->|"contains"| VAL
APPPKG -->|"contains"| STATS
APPPKG -->|"contains"| PDF
APPPKG -->|"contains"| FIG
APPPKG -->|"contains"| FAKE

%% Demo & tests
DEMO -->|"seed_or_demo_data"| FAKE
FAKE -->|"insert_demo_records"| DBFUN
TESTS -->|"exercise_flows"| EP0
TESTS -->|"assert_persistence"| DB
TESTS -->|"produces_results"| TRES

%% Ops
BACKUP -->|"copy_db_file"| DB
BACKUP -->|"write_backup_files"| FS
INSTALL -->|"install_dependencies"| REQS
INSTALL -->|"setup_app"| PYPROJ

%% Packaging/docs associations
README -->|"documents_usage_architecture"| EP0
MAN -->|"documents_cli"| CLI
DKR -->|"packages_runtime"| EP0
R1 -->|"hosts"| FS
R1 -->|"hosts"| DB
DKR -->|"optional_environment"| R1

%% =======================
%% Click Events (Paths)
%% =======================
click EP0 "https://github.com/daytonhaney/cleaners-app/blob/main/main.py"
click EP1 "https://github.com/daytonhaney/cleaners-app/blob/main/cleaners/main.py"
click CLI "https://github.com/daytonhaney/cleaners-app/blob/main/cleaners/cli.py"
click RICH "https://github.com/daytonhaney/cleaners-app/blob/main/cleaners/rich_ui.py"
click CLEAN "https://github.com/daytonhaney/cleaners-app/blob/main/cleaners/clean.py"
click VAL "https://github.com/daytonhaney/cleaners-app/blob/main/cleaners/validation.py"
click STATS "https://github.com/daytonhaney/cleaners-app/blob/main/cleaners/db_stats.py"
click PDF "https://github.com/daytonhaney/cleaners-app/blob/main/cleaners/pdf_export.py"
click FIG "https://github.com/daytonhaney/cleaners-app/blob/main/cleaners/fig.py"
click FAKE "https://github.com/daytonhaney/cleaners-app/blob/main/cleaners/fake_data.py"
click DBFUN "https://github.com/daytonhaney/cleaners-app/blob/main/db/db_functions.py"
click DBPKG "https://github.com/daytonhaney/cleaners-app/blob/main/db/__init__.py"
click APPPKG "https://github.com/daytonhaney/cleaners-app/blob/main/cleaners/__init__.py"
click DEMO "https://github.com/daytonhaney/cleaners-app/blob/main/examples/demo.py"
click TESTS "https://github.com/daytonhaney/cleaners-app/blob/main/test_system.py"
click DKR "https://github.com/daytonhaney/cleaners-app/tree/main/Dockerfile"
click BACKUP "https://github.com/daytonhaney/cleaners-app/blob/main/backup.sh"
click INSTALL "https://github.com/daytonhaney/cleaners-app/blob/main/install.sh"
click MAN "https://github.com/daytonhaney/cleaners-app/blob/main/cleaners-app.1"
click PYPROJ "https://github.com/daytonhaney/cleaners-app/blob/main/pyproject.toml"
click REQS "https://github.com/daytonhaney/cleaners-app/blob/main/requirements.txt"
click README "https://github.com/daytonhaney/cleaners-app/blob/main/readme.md"
click TRES "https://github.com/daytonhaney/cleaners-app/blob/main/TEST_RESULTS.md"

%% =======================
%% Styles
%% =======================
classDef actor fill:#FFF3BF,stroke:#B08900,stroke-width:1.5px,color:#2B2B2B
classDef env fill:#E7F5FF,stroke:#1C7ED6,stroke-width:1.2px,color:#102A43
classDef entry fill:#D0EBFF,stroke:#1971C2,stroke-width:1.4px,color:#0B1F33
classDef ui fill:#E3FAFC,stroke:#0B7285,stroke-width:1.4px,color:#04313A
classDef domain fill:#E6FCF5,stroke:#087F5B,stroke-width:1.4px,color:#063B2D
classDef export fill:#F3F0FF,stroke:#5F3DC4,stroke-width:1.4px,color:#24124D
classDef data fill:#FFF5F5,stroke:#C92A2A,stroke-width:1.4px,color:#3B0A0A
classDef database fill:#FFE3E3,stroke:#A61E4D,stroke-width:1.6px,color:#3B0A0A
classDef fs fill:#FFF9DB,stroke:#F08C00,stroke-width:1.4px,color:#3D2B00
classDef ops fill:#F1F3F5,stroke:#495057,stroke-width:1.2px,color:#212529
classDef docs fill:#F8F9FA,stroke:#868E96,stroke-width:1.1px,color:#343A40
classDef support fill:#E5DBFF,stroke:#6741D9,stroke-width:1.2px,color:#1F1450
classDef test fill:#FFEC99,stroke:#D9480F,stroke-width:1.2px,color:#3B220A
classDef pkg fill:#E9ECEF,stroke:#343A40,stroke-width:1.2px,color:#212529
```
