# monapdx/inbox-archeology architecture

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

- Interactive diagram: https://gitdiagram.com/monapdx/inbox-archeology
- Repository: https://github.com/monapdx/inbox-archeology

## Overview

1. **Overall shape**
   - This is a **local, single-user data exploration app** for Gmail Takeout exports.
   - The architecture is split into a **Streamlit UI**, a **processing pipeline**, and a set of **transform steps** that convert an `.mbox` archive into searchable and visual outputs.

2. **Primary user flow**
   - The user drops `All Mail.mbox` into `input/`.
   - The app discovers available inputs, runs a selected pipeline, and writes results into a **run-specific workspace** under `workspaces/<run-name>/`.
   - The UI then reads those generated artifacts to show dashboards, relationship graphs, and timeline views.

3. **UI layer**
   - `app.py` is the main entry point and is launched with Streamlit.
   - `dashboard.py` appears to own the rendered analytics/dashboard views.
   - The UI boundary is important: it does not appear to process mail directly; it **orchestrates and displays** pipeline outputs.

4. **Pipeline orchestration**
   - `pipeline.py` is the central coordinator for the processing flow.
   - It likely wires together the modules in `steps/`, manages step order, and connects input discovery to output generation.
   - This creates a clear separation between **workflow control** and **per-step data transformations**.

5. **Transformation stages**
   - The `steps/` directory is the core data-processing subsystem.
   - The names indicate a staged ETL-like flow:
     - `extract_headers.py` reads raw message metadata from the mailbox.
     - `extract_relationships.py` derives sender/recipient relationships.
     - `clean_relationships.py` and `filter_relationships.py` normalize and reduce noisy edges.
     - `analyze_relationships.py` and `reanalyze_clean_relationships.py` generate higher-level network analysis.
     - `build_core_timeline.py` constructs a timeline of important events/messages.
     - `plot_core_timeline.py` and `preview_core_timeline.py` render timeline visualizations.
   - The pipeline likely fans out into multiple derived artifacts from the same raw message source.

6. **Data model and artifacts**
   - The project is centered on **derived files**, not a database service.
   - Raw input stays in `input/`; generated artifacts go to `output/` and, more importantly, to per-run folders in `workspaces/`.
   - This suggests an architecture based on **file-backed intermediate results** rather than in-memory state or a server-side datastore.

7. **Workspace boundary**
   - `workspace_utils.py` likely handles run directory creation, artifact lookup, and path consistency.
   - The workspace concept is the key persistence boundary: each execution is isolated so multiple analyses can coexist.
   - That design supports reproducibility and lets the UI reopen previous runs.

8. **Configuration boundary**
   - `config.py` centralizes runtime settings such as folder paths, naming conventions, and possibly toggles for the pipeline/UI.
   - This keeps path logic and environment-specific behavior out of the UI and step modules.
   - `.env` suggests some settings may be overridable without changing code.

9. **Input/output boundaries**
   - `input/` is the only expected place for user-provided source data.
   - `output/` and `workspaces/` are generated/managed by the app and should be treated as derived state.
   - That separation is important for diagramming: **source data enters once**, then is transformed into multiple presentation-ready artifacts.

10. **Distribution and runtime**
   - The app is Python-based and launched locally with Streamlit.
   - `requirements.txt` defines the processing and visualization stack.
   - `launch_inbox_archeology.bat` indicates a Windows-friendly startup path, but the core architecture is still local Python execution.

11. **What to emphasize in an architecture diagram**
   - Show the flow from **Gmail Takeout `.mbox`** into the **pipeline**, then into **workspace artifacts**, then into the **dashboard/visualization layer**.
   - The important subsystems are:
     - user-facing Streamlit app,
     - pipeline coordinator,
     - stepwise extraction/analysis modules,
     - workspace/file management.
   - There are no obvious external network dependencies in the core architecture; the project is designed to be **fully local and privacy-preserving**.

12. **Reusable mental model**
   - Think of this repo as a **local analytics compiler**: raw mailbox input is progressively lowered into normalized relationship data, then raised again into visual summaries and timelines.
   - The architecture is intentionally file-oriented, with each run producing a self-contained archive of outputs under its workspace.

Main entry points: [`pipeline.py`](https://github.com/monapdx/inbox-archeology/blob/main/pipeline.py) (pipeline.py), [`steps/extract_headers.py`](https://github.com/monapdx/inbox-archeology/blob/main/steps/extract_headers.py) (extract headers), [`steps/clean_relationships.py`](https://github.com/monapdx/inbox-archeology/blob/main/steps/clean_relationships.py) (clean rels), [`steps/build_core_timeline.py`](https://github.com/monapdx/inbox-archeology/blob/main/steps/build_core_timeline.py) (build timeline)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["UI layer"]
  node_app["app.py<br/>streamlit entry<br/>[app.py]"]
  node_dashboard["dashboard.py<br/>dashboard views<br/>[dashboard.py]"]
end

subgraph group_pipeline["Pipeline"]
  node_pipeline["pipeline.py<br/>orchestrator<br/>[pipeline.py]"]
  node_extract_headers["extract headers<br/>step<br/>[extract_headers.py]"]
  node_extract_relationships["extract rels<br/>step"]
  node_clean_relationships["clean rels<br/>step"]
  node_filter_relationships["filter rels<br/>step"]
  node_analyze_relationships["analyze rels<br/>step"]
  node_reanalyze_clean_relationships["reanalyze rels<br/>step"]
  node_build_core_timeline["build timeline<br/>step"]
  node_plot_core_timeline["plot timeline<br/>visualization step"]
  node_preview_core_timeline["preview timeline<br/>preview step"]
end

subgraph group_storage["Storage"]
  node_workspace_utils["workspace_utils.py<br/>workspace manager<br/>[workspace_utils.py]"]
  node_input_dir[("input/<br/>source folder")]
  node_mbox["All Mail.mbox<br/>mailbox source<br/>[file.txt]"]
  node_workspace_dir[("workspaces/<br/>run artifacts")]
  node_output_dir[("output/<br/>derived output")]
end

subgraph group_runtime["Runtime"]
  node_config["config.py<br/>settings<br/>[config.py]"]
end

node_app -->|"orchestrates"| node_pipeline
node_app -->|"renders"| node_dashboard
node_pipeline -->|"uses"| node_workspace_utils
node_pipeline -->|"reads"| node_config
node_input_dir -->|"contains"| node_mbox
node_pipeline -->|"discovers"| node_input_dir
node_mbox -->|"feeds"| node_extract_headers
node_extract_headers -->|"passes"| node_extract_relationships
node_extract_relationships -->|"refines"| node_clean_relationships
node_clean_relationships -->|"reduces"| node_filter_relationships
node_filter_relationships -->|"analyzes"| node_analyze_relationships
node_clean_relationships -->|"reprocesses"| node_reanalyze_clean_relationships
node_extract_headers -->|"supports"| node_build_core_timeline
node_build_core_timeline -->|"visualizes"| node_plot_core_timeline
node_build_core_timeline -->|"previews"| node_preview_core_timeline
node_pipeline -->|"writes"| node_workspace_dir
node_workspace_dir -->|"reads"| node_dashboard
node_output_dir -->|"supplies"| node_dashboard
node_config -->|"configures"| node_input_dir
node_config -->|"configures"| node_workspace_dir

click node_app "https://github.com/monapdx/inbox-archeology/blob/main/app.py"
click node_dashboard "https://github.com/monapdx/inbox-archeology/blob/main/dashboard.py"
click node_pipeline "https://github.com/monapdx/inbox-archeology/blob/main/pipeline.py"
click node_workspace_utils "https://github.com/monapdx/inbox-archeology/blob/main/workspace_utils.py"
click node_config "https://github.com/monapdx/inbox-archeology/blob/main/config.py"
click node_input_dir "https://github.com/monapdx/inbox-archeology/tree/main/input"
click node_mbox "https://github.com/monapdx/inbox-archeology/blob/main/input/file.txt"
click node_workspace_dir "https://github.com/monapdx/inbox-archeology/tree/main/workspaces"
click node_output_dir "https://github.com/monapdx/inbox-archeology/tree/main/output"
click node_extract_headers "https://github.com/monapdx/inbox-archeology/blob/main/steps/extract_headers.py"
click node_extract_relationships "https://github.com/monapdx/inbox-archeology/blob/main/steps/extract_relationships.py"
click node_clean_relationships "https://github.com/monapdx/inbox-archeology/blob/main/steps/clean_relationships.py"
click node_filter_relationships "https://github.com/monapdx/inbox-archeology/blob/main/steps/filter_relationships.py"
click node_analyze_relationships "https://github.com/monapdx/inbox-archeology/blob/main/steps/analyze_relationships.py"
click node_reanalyze_clean_relationships "https://github.com/monapdx/inbox-archeology/blob/main/steps/reanalyze_clean_relationships.py"
click node_build_core_timeline "https://github.com/monapdx/inbox-archeology/blob/main/steps/build_core_timeline.py"
click node_plot_core_timeline "https://github.com/monapdx/inbox-archeology/blob/main/steps/plot_core_timeline.py"
click node_preview_core_timeline "https://github.com/monapdx/inbox-archeology/blob/main/steps/preview_core_timeline.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_app,node_dashboard toneBlue
class node_pipeline,node_extract_headers,node_extract_relationships,node_clean_relationships,node_filter_relationships,node_analyze_relationships,node_reanalyze_clean_relationships,node_build_core_timeline,node_plot_core_timeline,node_preview_core_timeline toneAmber
class node_workspace_utils,node_input_dir,node_mbox,node_workspace_dir,node_output_dir toneMint
class node_config toneRose
```

## Components

### UI layer

Streamlit entrypoint and rendered analytics views.

- [app.py](https://github.com/monapdx/inbox-archeology/blob/main/app.py): streamlit entry · Main local UI entrypoint launched with Streamlit. · `app.py`
- [dashboard.py](https://github.com/monapdx/inbox-archeology/blob/main/dashboard.py): dashboard views · Renders analytics, graphs, and timeline views from generated artifacts. · `dashboard.py`

### Pipeline

Workflow coordination and staged mailbox processing.

- [pipeline.py](https://github.com/monapdx/inbox-archeology/blob/main/pipeline.py): orchestrator · Coordinates the end-to-end processing flow and step ordering. · `pipeline.py`
- [extract headers](https://github.com/monapdx/inbox-archeology/blob/main/steps/extract_headers.py): step · Reads raw message metadata from the mailbox. · `steps/extract_headers.py`
- [extract rels](https://github.com/monapdx/inbox-archeology/blob/main/steps/extract_relationships.py): step · Derives sender and recipient relationships from headers. · `steps/extract_relationships.py`
- [clean rels](https://github.com/monapdx/inbox-archeology/blob/main/steps/clean_relationships.py): step · Normalizes relationship data and removes noise. · `steps/clean_relationships.py`
- [filter rels](https://github.com/monapdx/inbox-archeology/blob/main/steps/filter_relationships.py): step · Reduces relationships to the more relevant edges. · `steps/filter_relationships.py`
- [analyze rels](https://github.com/monapdx/inbox-archeology/blob/main/steps/analyze_relationships.py): step · Produces higher-level network analysis from the cleaned graph. · `steps/analyze_relationships.py`
- [reanalyze rels](https://github.com/monapdx/inbox-archeology/blob/main/steps/reanalyze_clean_relationships.py): step · Re-runs analysis on cleaned relationship data for refined outputs. · `steps/reanalyze_clean_relationships.py`
- [build timeline](https://github.com/monapdx/inbox-archeology/blob/main/steps/build_core_timeline.py): step · Constructs a timeline of key events and messages. · `steps/build_core_timeline.py`
- [plot timeline](https://github.com/monapdx/inbox-archeology/blob/main/steps/plot_core_timeline.py): visualization step · Generates timeline visualizations for the UI. · `steps/plot_core_timeline.py`
- [preview timeline](https://github.com/monapdx/inbox-archeology/blob/main/steps/preview_core_timeline.py): preview step · Creates lightweight timeline previews for rapid inspection. · `steps/preview_core_timeline.py`

### Storage

Input, output, and run workspace boundaries.

- [workspace_utils.py](https://github.com/monapdx/inbox-archeology/blob/main/workspace_utils.py): workspace manager · Creates run directories and resolves artifact paths for each analysis. · `workspace_utils.py`
- [input/](https://github.com/monapdx/inbox-archeology/tree/main/input): source folder · Drop location for Gmail Takeout mailbox input. · `input`
- [All Mail.mbox](https://github.com/monapdx/inbox-archeology/blob/main/input/file.txt): mailbox source · Raw Gmail Takeout archive consumed by the pipeline. · `input/file.txt`
- [workspaces/](https://github.com/monapdx/inbox-archeology/tree/main/workspaces): run artifacts · Per-run isolated workspace root for generated outputs. · `workspaces`
- [output/](https://github.com/monapdx/inbox-archeology/tree/main/output): derived output · General generated output area for processed artifacts. · `output`

### Runtime

Configuration and launch support for local execution.

- [config.py](https://github.com/monapdx/inbox-archeology/blob/main/config.py): settings · Centralizes paths, naming, and runtime configuration. · `config.py`

## Connections

- app.py → pipeline.py: orchestrates · The UI triggers processing through the pipeline coordinator.
- app.py → dashboard.py: renders · The app presents the dashboard views to the user.
- pipeline.py → workspace_utils.py: uses · Workflow execution relies on workspace creation and artifact lookup.
- pipeline.py → config.py: reads · The coordinator uses centralized configuration.
- input/ → All Mail.mbox: contains · User-provided mailbox lives in the input folder.
- pipeline.py → input/: discovers · The pipeline finds available source inputs.
- All Mail.mbox → extract headers: feeds · Raw mailbox data begins the transformation flow.
- extract headers → extract rels: passes · Headers are transformed into relationship candidates.
- extract rels → clean rels: refines · Relationship data is normalized and cleaned.
- clean rels → filter rels: reduces · Cleaned relationships are filtered to the important subset.
- filter rels → analyze rels: analyzes · Filtered relationships are analyzed for higher-level structure.
- clean rels → reanalyze rels: reprocesses · Cleaned relationships can be reanalyzed for alternate outputs.
- extract headers → build timeline: supports · Message metadata also feeds timeline construction.
- build timeline → plot timeline: visualizes · Timeline data is rendered into plots.
- build timeline → preview timeline: previews · Timeline data is also prepared for quick previewing.
- pipeline.py → workspaces/: writes · Each run produces isolated artifacts in a workspace.
- workspaces/ → dashboard.py: reads · The dashboard loads generated run artifacts.
- output/ → dashboard.py: supplies · Derived outputs are available for presentation.
- config.py → input/: configures · Configuration defines path conventions and boundaries.
- config.py → workspaces/: configures · Configuration controls workspace layout and naming.
