From 4a40e6c765eb4386f0509d1db5d90b9c9c47f35e Mon Sep 17 00:00:00 2001 From: kevinBell Date: Fri, 17 Jul 2026 15:33:54 -0600 Subject: [PATCH] diagram of the entire architecture --- docs/architecture.mmd | 115 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 115 insertions(+) create mode 100644 docs/architecture.mmd diff --git a/docs/architecture.mmd b/docs/architecture.mmd new file mode 100644 index 0000000..8f07467 --- /dev/null +++ b/docs/architecture.mmd @@ -0,0 +1,115 @@ +graph TD + %% Data Sources + PG[(PostgreSQL
countydata)] + DMV[("DMV Data
~18M records
2011-2024")] + INSP[("Inspection Data
~19.3M records
2010-2026")] + + PG --- DMV + PG --- INSP + + %% Extraction + PG -->|"export_history_sample.py
(VIN hashing, page sampling)"| CSV["history_sample_10000.csv.gz
+ manifest"] + + %% Feature Mart Build + CSV -->|"build_feature_mart.py"| DUCKDB + + subgraph DuckDB["DuckDB Local Warehouse"] + direction TB + SQL20["20_stage_events.sql
Normalize & validate"] + SQL21["21_build_episodes.sql
Group episodes (30-day gap)"] + SQL22["22_build_features.sql
Point-in-time feature windows"] + SQL20 --> SQL21 --> SQL22 + end + + DUCKDB --> MART["inspection_feature_mart.parquet
(episode × features, temporal partitions)"] + + %% Temporal Partitions + subgraph Partitions["Temporal Splits"] + TRAIN["Train: 2016–2022"] + TUNE["Tune: 2023"] + CAL["Calibrate: 2024"] + TEST["Locked Test: 2025"] + DRIFT["Shadow Drift: 2026"] + end + MART -.- Partitions + + %% Model Training + MART -->|"train_baselines.py"| BL["artifacts/baselines/baseline_v1/
Logistic Regression +
Prevalence & Prior-Outcome"] + MART -->|"train_tree_model.py"| TREE["artifacts/tree/hist_gradient_boosting_v1/
Histogram Gradient Boosting"] + + %% Model Outputs + BL --> ARTIFACTS["Model Artifacts
manifest.json, metrics.json,
model.joblib, calibration_bins.csv"] + TREE --> ARTIFACTS + + %% Dashboard Export + MART -->|"export_dashboard_data.py
(privacy suppression, aggregation)"| JSON + + subgraph JSON["dashboard/public/data/"] + direction TB + DM["data_manifest.json"] + OV["overview_period_county.json"] + CS["cohort_scorecard.json"] + ARC["age_risk_curve.json"] + CQ["coverage_quality.json"] + FC["filter_catalog.json"] + MD["model_diagnostics.json"] + end + + ARTIFACTS -.->|metrics & manifest| JSON + + %% Dashboard Frontend + JSON --> SERVER["server.mjs
Node.js HTTP server"] + + subgraph Dashboard["Browser SPA"] + direction TB + APP["app.js
Routing & pages"] + CHARTS["charts.js
D3 visualizations"] + DATA["data.js
Data loading & filters"] + APP --- CHARTS + APP --- DATA + end + + SERVER --> Dashboard + + subgraph Pages["Dashboard Pages"] + P1["Overview
KPIs, trends, county map"] + P2["Reliability Explorer
Make/model comparison"] + P3["Next-Test Estimator
Risk prediction"] + P4["Data & Methods
Coverage, limitations"] + end + + Dashboard --> Pages + + %% Privacy Controls + subgraph Privacy["Privacy Controls"] + direction LR + S1["≥100 inspections per cell"] + S2["≥100 distinct vehicles"] + S3["≥10 outcome records"] + S4["No VINs/plates/ZIPs"] + end + + JSON -.- Privacy + + %% Testing + subgraph Tests["Test Suite"] + direction LR + PT["Python unittest
(feature mart, models,
export, baselines)"] + CT["Node.js contract tests
(dashboard JSON schemas)"] + end + + MART -.- PT + JSON -.- CT + + %% Styling + classDef source fill:#e1f5fe,stroke:#0288d1 + classDef process fill:#fff3e0,stroke:#f57c00 + classDef storage fill:#e8f5e9,stroke:#388e3c + classDef dashboard fill:#fce4ec,stroke:#c62828 + classDef test fill:#f3e5f5,stroke:#7b1fa2 + + class PG,DMV,INSP source + class CSV,MART,ARTIFACTS,DUCKDB storage + class BL,TREE process + class SERVER,Dashboard,Pages,JSON dashboard + class Tests test