# noahlevitt/data-warehouse architecture

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

## Overview

Customer Records is an internal web app for importing customer files into searchable, location- and service-scoped records, finding and tagging records, and exporting unique phone numbers in the main system’s import format. The main workflow runs through the web app, the shared converter’s read/match/clean stages, and a record sink into PostgreSQL; Find and Tags provide the main downstream workflows. The README documents these capabilities and the optional ClickHouse merchant sync. Some internal links are limited to README statements and SOURCE INDEX references; unsampled implementation details are not inferred.

Main entry points: [`app.py`](https://github.com/noahlevitt/data-warehouse/blob/main/app.py) (Web app), [`converter/engine.py`](https://github.com/noahlevitt/data-warehouse/blob/main/converter/engine.py) (Conversion engine), [`records/merchants.py`](https://github.com/noahlevitt/data-warehouse/blob/main/records/merchants.py) (Merchant synchronization), [`records/db.py`](https://github.com/noahlevitt/data-warehouse/blob/main/records/db.py) (Records database)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web application"]
  node_webapp["Web app<br/>[app.py]"]
  node_recordpages["Find and Tags pages<br/>[ui.py]"]
  node_merchantpages["Merchant and service pages<br/>[ui.py]"]
end

subgraph group_conversion["File conversion"]
  node_reader["File reader<br/>[reader.py]"]
  node_mapping["Column mapping<br/>[mapping.py]"]
  node_auto_mapping["Mapping suggestions<br/>[heuristics.py]"]
  node_conversion_services["Mapping orchestration<br/>[services.py]"]
  node_engine["Conversion engine<br/>[engine.py]"]
  node_normalizers["Value normalization<br/>[normalizers.py]"]
  node_target_schema["Record and import fields<br/>[schema.py]"]
end

subgraph group_records["Customer records"]
  node_record_store["Record operations<br/>[store.py]"]
  node_find["Find query builder<br/>[find.py]"]
  node_criteria["Find criteria<br/>[criteria.py]"]
  node_tags["Tag operations and export<br/>[tags.py]"]
  node_merchant_sync["Merchant synchronization<br/>[merchants.py]"]
end

subgraph group_data["Persistence and imports"]
  node_import_runner["Background import runner<br/>[runner.py]"]
  node_record_importer["Record sink<br/>[importer.py]"]
  node_postgres[("Records database<br/>[db.py]")]
  node_converter_store[("Import and template storage<br/>[storage.py]")]
end

node_user(("Staff user"))
node_clickhouse[("Main app ClickHouse")]
node_csv_upload["Merchant CSV upload"]

node_user -->|"uses"| node_webapp
node_webapp -->|"renders"| node_recordpages
node_webapp -->|"renders"| node_merchantpages
node_webapp -->|"reads upload"| node_reader
node_webapp -->|"prepares mapping"| node_conversion_services
node_conversion_services -->|"suggests mapping"| node_auto_mapping
node_conversion_services -->|"normalizes mapping"| node_mapping
node_webapp -->|"starts import"| node_import_runner
node_import_runner -->|"stores rows"| node_record_importer
node_record_importer -->|"converts rows"| node_engine
node_engine -->|"normalizes values"| node_normalizers
node_engine -->|"applies mapping"| node_mapping
node_engine -->|"uses fields"| node_target_schema
node_record_importer -->|"saves records"| node_record_store
node_record_store -->|"reads and writes"| node_postgres
node_webapp -->|"manages imports"| node_converter_store
node_webapp -->|"manages templates"| node_converter_store
node_recordpages -->|"runs searches"| node_find
node_find -->|"builds conditions"| node_criteria
node_find -->|"queries records"| node_postgres
node_recordpages -->|"manages tags"| node_tags
node_tags -->|"reads and writes"| node_postgres
node_tags -->|"formats export"| node_target_schema
node_merchantpages -->|"loads merchants"| node_merchant_sync
node_merchant_sync -.->|"loads merchant data"| node_clickhouse
node_merchant_sync -.->|"accepts CSV"| node_csv_upload
node_merchant_sync -.->|"stores locations"| node_postgres

click node_webapp "https://github.com/noahlevitt/data-warehouse/blob/main/app.py"
click node_recordpages "https://github.com/noahlevitt/data-warehouse/blob/main/records/ui.py"
click node_merchantpages "https://github.com/noahlevitt/data-warehouse/blob/main/records/ui.py"
click node_reader "https://github.com/noahlevitt/data-warehouse/blob/main/converter/reader.py"
click node_mapping "https://github.com/noahlevitt/data-warehouse/blob/main/converter/mapping.py"
click node_auto_mapping "https://github.com/noahlevitt/data-warehouse/blob/main/converter/heuristics.py"
click node_conversion_services "https://github.com/noahlevitt/data-warehouse/blob/main/converter/services.py"
click node_engine "https://github.com/noahlevitt/data-warehouse/blob/main/converter/engine.py"
click node_normalizers "https://github.com/noahlevitt/data-warehouse/blob/main/converter/normalizers.py"
click node_target_schema "https://github.com/noahlevitt/data-warehouse/blob/main/converter/schema.py"
click node_import_runner "https://github.com/noahlevitt/data-warehouse/blob/main/records/runner.py"
click node_record_importer "https://github.com/noahlevitt/data-warehouse/blob/main/records/importer.py"
click node_record_store "https://github.com/noahlevitt/data-warehouse/blob/main/records/store.py"
click node_postgres "https://github.com/noahlevitt/data-warehouse/blob/main/records/db.py"
click node_converter_store "https://github.com/noahlevitt/data-warehouse/blob/main/converter/storage.py"
click node_find "https://github.com/noahlevitt/data-warehouse/blob/main/records/find.py"
click node_criteria "https://github.com/noahlevitt/data-warehouse/blob/main/records/criteria.py"
click node_tags "https://github.com/noahlevitt/data-warehouse/blob/main/records/tags.py"
click node_merchant_sync "https://github.com/noahlevitt/data-warehouse/blob/main/records/merchants.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_webapp,node_recordpages,node_merchantpages,node_user toneBlue
class node_reader,node_mapping,node_auto_mapping,node_conversion_services,node_engine,node_normalizers,node_target_schema,node_clickhouse toneAmber
class node_record_store,node_find,node_criteria,node_tags,node_merchant_sync toneMint
class node_import_runner,node_record_importer,node_postgres,node_converter_store toneRose
class node_csv_upload toneIndigo
```

## Components

### Web application

- [Web app](https://github.com/noahlevitt/data-warehouse/blob/main/app.py): `app.py`
- [Find and Tags pages](https://github.com/noahlevitt/data-warehouse/blob/main/records/ui.py): `records/ui.py`
- [Merchant and service pages](https://github.com/noahlevitt/data-warehouse/blob/main/records/ui.py): `records/ui.py`

### File conversion

- [File reader](https://github.com/noahlevitt/data-warehouse/blob/main/converter/reader.py): `converter/reader.py`
- [Column mapping](https://github.com/noahlevitt/data-warehouse/blob/main/converter/mapping.py): `converter/mapping.py`
- [Mapping suggestions](https://github.com/noahlevitt/data-warehouse/blob/main/converter/heuristics.py): `converter/heuristics.py`
- [Mapping orchestration](https://github.com/noahlevitt/data-warehouse/blob/main/converter/services.py): `converter/services.py`
- [Conversion engine](https://github.com/noahlevitt/data-warehouse/blob/main/converter/engine.py): `converter/engine.py`
- [Value normalization](https://github.com/noahlevitt/data-warehouse/blob/main/converter/normalizers.py): `converter/normalizers.py`
- [Record and import fields](https://github.com/noahlevitt/data-warehouse/blob/main/converter/schema.py): `converter/schema.py`

### Customer records

- [Record operations](https://github.com/noahlevitt/data-warehouse/blob/main/records/store.py): `records/store.py`
- [Find query builder](https://github.com/noahlevitt/data-warehouse/blob/main/records/find.py): `records/find.py`
- [Find criteria](https://github.com/noahlevitt/data-warehouse/blob/main/records/criteria.py): `records/criteria.py`
- [Tag operations and export](https://github.com/noahlevitt/data-warehouse/blob/main/records/tags.py): `records/tags.py`
- [Merchant synchronization](https://github.com/noahlevitt/data-warehouse/blob/main/records/merchants.py): `records/merchants.py`

### Persistence and imports

- [Background import runner](https://github.com/noahlevitt/data-warehouse/blob/main/records/runner.py): `records/runner.py`
- [Record sink](https://github.com/noahlevitt/data-warehouse/blob/main/records/importer.py): `records/importer.py`
- [Records database](https://github.com/noahlevitt/data-warehouse/blob/main/records/db.py): `records/db.py`
- [Import and template storage](https://github.com/noahlevitt/data-warehouse/blob/main/converter/storage.py): `converter/storage.py`

### Other components

- **Staff user**
- **Main app ClickHouse**
- **Merchant CSV upload**

## Connections

- Staff user → Web app: uses
- Web app → Find and Tags pages: renders (evidence: `app.py`)
- Web app → Merchant and service pages: renders (evidence: `app.py`)
- Web app → File reader: reads upload (evidence: `app.py`)
- Web app → Mapping orchestration: prepares mapping (evidence: `app.py`)
- Mapping orchestration → Mapping suggestions: suggests mapping (evidence: `converter/services.py`)
- Mapping orchestration → Column mapping: normalizes mapping (evidence: `converter/services.py`)
- Web app → Background import runner: starts import (evidence: `app.py`)
- Background import runner → Record sink: stores rows (evidence: `records/runner.py`)
- Record sink → Conversion engine: converts rows (evidence: `records/importer.py`)
- Conversion engine → Value normalization: normalizes values (evidence: `converter/engine.py`)
- Conversion engine → Column mapping: applies mapping (evidence: `converter/engine.py`)
- Conversion engine → Record and import fields: uses fields (evidence: `converter/engine.py`)
- Record sink → Record operations: saves records (evidence: `records/importer.py`)
- Record operations → Records database: reads and writes (evidence: `records/store.py`)
- Web app → Import and template storage: manages imports (evidence: `app.py`)
- Web app → Import and template storage: manages templates (evidence: `app.py`)
- Find and Tags pages → Find query builder: runs searches (evidence: `records/ui.py`)
- Find query builder → Find criteria: builds conditions (evidence: `records/find.py`)
- Find query builder → Records database: queries records (evidence: `records/find.py`)
- Find and Tags pages → Tag operations and export: manages tags (evidence: `records/ui.py`)
- Tag operations and export → Records database: reads and writes (evidence: `records/tags.py`)
- Tag operations and export → Record and import fields: formats export (evidence: `records/tags.py`)
- Merchant and service pages → Merchant synchronization: loads merchants (evidence: `records/ui.py`)
- Merchant synchronization → Main app ClickHouse: loads merchant data
- Merchant synchronization → Merchant CSV upload: accepts CSV
- Merchant synchronization → Records database: stores locations
