# nasermaher/p3-collect-comparative architecture

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

- Interactive diagram: https://gitdiagram.com/nasermaher/p3-collect-comparative
- Repository: https://github.com/nasermaher/p3-collect-comparative

## Overview

P3CC is a Windows desktop batch tool that enriches `.p3` card records with matching Excel data. The main workflow starts in the GUI, which invokes the pipeline; the pipeline loads profiles and Excel data, detects the profile, processes source records, and writes one enriched output file. The graph also shows profile management, remembered-folder settings, and record/data transformation. Relationships reflect the shown excerpts, SOURCE INDEX references, and README; unsampled implementation details are not expanded.

Main entry points: [`main.py`](https://github.com/nasermaher/p3-collect-comparative/blob/main/main.py) (Batch pipeline), [`field_map_store.py`](https://github.com/nasermaher/p3-collect-comparative/blob/main/field_map_store.py) (Profile validation and migration), [`gui.py`](https://github.com/nasermaher/p3-collect-comparative/blob/main/gui.py) (Main window), [`settings.py`](https://github.com/nasermaher/p3-collect-comparative/blob/main/settings.py) (Settings persistence)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Desktop interface"]
  node_app["GUI launcher<br/>[app.py]"]
  node_gui["Main window<br/>[gui.py]"]
  node_settings_ui["Folder settings UI<br/>[gui.py]"]
end

subgraph group_processing["Batch processing"]
  node_pipeline["Batch pipeline<br/>[main.py]"]
  node_discovery["Source discovery<br/>[utils.py]"]
  node_excel["Excel loading<br/>[utils.py]"]
  node_profile_detect["Profile detection<br/>[utils.py]"]
  node_record["Record parsing<br/>[utils.py]"]
  node_field_build["Tag construction<br/>[utils.py]"]
end

subgraph group_profiles["Profile configuration"]
  node_profile_ui["Profile management<br/>[gui.py]"]
  node_profile_store["Profile validation and migration<br/>[field_map_store.py]"]
  node_profile_file["field_map.json"]
end

subgraph group_runtime["Runtime support"]
  node_settings["Settings persistence<br/>[settings.py]"]
  node_settings_file["settings.json"]
  node_constants["Format and defaults<br/>[config.py]"]
  node_errors["Domain errors<br/>[exceptions.py]"]
end

node_user(("Desktop user"))
node_source_files["P3 source files"]
node_workbook["Excel workbook"]
node_output["Enriched P3 output"]

node_user -->|"launches"| node_app
node_app -->|"launches"| node_gui
node_user -->|"chooses inputs"| node_gui
node_gui -->|"runs"| node_pipeline
node_pipeline -->|"discovers files"| node_discovery
node_discovery -->|"finds"| node_source_files
node_pipeline -->|"loads workbook"| node_excel
node_excel -->|"reads"| node_workbook
node_pipeline -->|"loads profiles"| node_profile_store
node_pipeline -->|"detects profile"| node_profile_detect
node_pipeline -->|"iterates records"| node_record
node_record -->|"reads records"| node_source_files
node_pipeline -->|"builds tags"| node_field_build
node_pipeline -->|"writes merged output"| node_output
node_gui -->|"opens"| node_profile_ui
node_profile_ui -->|"edits profiles"| node_profile_store
node_profile_store -->|"loads and saves"| node_profile_file
node_profile_store -->|"uses defaults"| node_constants
node_gui -->|"opens"| node_settings_ui
node_settings_ui -->|"loads and saves"| node_settings
node_settings -->|"persists folders"| node_settings_file
node_pipeline -->|"gets app directory"| node_settings
node_profile_store -->|"gets app directory"| node_settings
node_pipeline -->|"uses markers"| node_constants
node_pipeline -->|"raises and handles"| node_errors
node_profile_store -->|"raises validation errors"| node_errors

click node_app "https://github.com/nasermaher/p3-collect-comparative/blob/main/app.py"
click node_gui "https://github.com/nasermaher/p3-collect-comparative/blob/main/gui.py"
click node_pipeline "https://github.com/nasermaher/p3-collect-comparative/blob/main/main.py"
click node_discovery "https://github.com/nasermaher/p3-collect-comparative/blob/main/utils.py"
click node_excel "https://github.com/nasermaher/p3-collect-comparative/blob/main/utils.py"
click node_profile_detect "https://github.com/nasermaher/p3-collect-comparative/blob/main/utils.py"
click node_record "https://github.com/nasermaher/p3-collect-comparative/blob/main/utils.py"
click node_field_build "https://github.com/nasermaher/p3-collect-comparative/blob/main/utils.py"
click node_profile_ui "https://github.com/nasermaher/p3-collect-comparative/blob/main/gui.py"
click node_profile_store "https://github.com/nasermaher/p3-collect-comparative/blob/main/field_map_store.py"
click node_settings_ui "https://github.com/nasermaher/p3-collect-comparative/blob/main/gui.py"
click node_settings "https://github.com/nasermaher/p3-collect-comparative/blob/main/settings.py"
click node_constants "https://github.com/nasermaher/p3-collect-comparative/blob/main/config.py"
click node_errors "https://github.com/nasermaher/p3-collect-comparative/blob/main/exceptions.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_gui,node_settings_ui,node_user toneBlue
class node_pipeline,node_discovery,node_excel,node_profile_detect,node_record,node_field_build toneAmber
class node_profile_ui,node_profile_store,node_profile_file toneMint
class node_settings,node_settings_file,node_constants,node_errors toneRose
class node_source_files,node_workbook,node_output toneIndigo
```

## Components

### Desktop interface

- [GUI launcher](https://github.com/nasermaher/p3-collect-comparative/blob/main/app.py): `app.py`
- [Main window](https://github.com/nasermaher/p3-collect-comparative/blob/main/gui.py): `gui.py`
- [Folder settings UI](https://github.com/nasermaher/p3-collect-comparative/blob/main/gui.py): `gui.py`

### Batch processing

- [Batch pipeline](https://github.com/nasermaher/p3-collect-comparative/blob/main/main.py): `main.py`
- [Source discovery](https://github.com/nasermaher/p3-collect-comparative/blob/main/utils.py): `utils.py`
- [Excel loading](https://github.com/nasermaher/p3-collect-comparative/blob/main/utils.py): `utils.py`
- [Profile detection](https://github.com/nasermaher/p3-collect-comparative/blob/main/utils.py): `utils.py`
- [Record parsing](https://github.com/nasermaher/p3-collect-comparative/blob/main/utils.py): `utils.py`
- [Tag construction](https://github.com/nasermaher/p3-collect-comparative/blob/main/utils.py): `utils.py`

### Profile configuration

- [Profile management](https://github.com/nasermaher/p3-collect-comparative/blob/main/gui.py): `gui.py`
- [Profile validation and migration](https://github.com/nasermaher/p3-collect-comparative/blob/main/field_map_store.py): `field_map_store.py`
- **field_map.json**

### Runtime support

- [Settings persistence](https://github.com/nasermaher/p3-collect-comparative/blob/main/settings.py): `settings.py`
- **settings.json**
- [Format and defaults](https://github.com/nasermaher/p3-collect-comparative/blob/main/config.py): `config.py`
- [Domain errors](https://github.com/nasermaher/p3-collect-comparative/blob/main/exceptions.py): `exceptions.py`

### Other components

- **Desktop user**
- **P3 source files**
- **Excel workbook**
- **Enriched P3 output**

## Connections

- Desktop user → GUI launcher: launches (evidence: `README.md`)
- GUI launcher → Main window: launches (evidence: `app.py`)
- Desktop user → Main window: chooses inputs (evidence: `README.md`)
- Main window → Batch pipeline: runs (evidence: `gui.py`)
- Batch pipeline → Source discovery: discovers files (evidence: `main.py`)
- Source discovery → P3 source files: finds (evidence: `README.md`)
- Batch pipeline → Excel loading: loads workbook (evidence: `main.py`)
- Excel loading → Excel workbook: reads (evidence: `README.md`)
- Batch pipeline → Profile validation and migration: loads profiles (evidence: `main.py`)
- Batch pipeline → Profile detection: detects profile (evidence: `main.py`)
- Batch pipeline → Record parsing: iterates records (evidence: `main.py`)
- Record parsing → P3 source files: reads records (evidence: `README.md`)
- Batch pipeline → Tag construction: builds tags (evidence: `main.py`)
- Batch pipeline → Enriched P3 output: writes merged output (evidence: `README.md`)
- Main window → Profile management: opens (evidence: `gui.py`)
- Profile management → Profile validation and migration: edits profiles (evidence: `README.md`)
- Profile validation and migration → field_map.json: loads and saves (evidence: `field_map_store.py`)
- Profile validation and migration → Format and defaults: uses defaults (evidence: `field_map_store.py`)
- Main window → Folder settings UI: opens (evidence: `gui.py`)
- Folder settings UI → Settings persistence: loads and saves (evidence: `README.md`)
- Settings persistence → settings.json: persists folders (evidence: `settings.py`)
- Batch pipeline → Settings persistence: gets app directory (evidence: `main.py`)
- Profile validation and migration → Settings persistence: gets app directory (evidence: `field_map_store.py`)
- Batch pipeline → Format and defaults: uses markers (evidence: `main.py`)
- Batch pipeline → Domain errors: raises and handles (evidence: `main.py`)
- Profile validation and migration → Domain errors: raises validation errors (evidence: `field_map_store.py`)
