# deiugarte/tanita architecture

> Architecture diagram of the GitHub repository deiugarte/tanita, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/deiugarte/tanita
- Repository: https://github.com/deiugarte/tanita

## Overview

##### Project Type and Purpose
- This is an open-source Python CLI tool (“tanita”) that:
- Reads raw TANITA SD data (CSV files under data/TANITA/GRAPHV1)
- Parses and maps those measurements
- Combines them with user metadata
- Generates a PDF report (via an intermediate HTML template exp.html)
- Its primary use case: ingest SD data and output a human-readable PDF.

##### File Structure
- Top-level scripts:
- main.py – entry point / orchestrator
- tanita_measures_parser.py – raw CSV → structured records
- mapping.py – maps raw fields to report fields
- user_data.py – loads/validates user profile info
- Data directory:
- data/TANITA/GRAPHV1/{DATA, SYSTEM} – multiple CSVs + SYSTEM.TXT
- Auxiliary:
- exp.html – HTML template for PDF generation
- requirements.txt – PDF engine (e.g., WeasyPrint or ReportLab) + CSV libs

##### README Insights
- Confirms Python 3.12, pip install dependencies

##### Main Components
a. Data Sources
- “Raw CSV Files” node representing data/TANITA/GRAPHV1/DATA/*.CSV and SYSTEM/*.CSV
b. Parsing & Mapping Layer
- tanita_measures_parser.py
- mapping.py
- user_data.py
(group together as the “Processing Pipeline”)
c. Orchestration / CLI
- main.py (coordinates steps, error handling, CLI args)
d. Template & Report Generator
- exp.html (HTML template)
- PDF generator library (e.g., WeasyPrint/ReportLab)
e. Output
- Generated PDF report

##### Relationships and Data Flow
- Parser → Mapper → Enriched Records
- Enriched Records + User Data → HTML Template
- HTML Template → PDF Generator → PDF Output
- main.py stands above, invoking each stage in sequence.

##### Architectural Patterns and Design Principles
- Modular pipeline: separation of concerns (parsing, mapping, templating)
- Pluggable mapping layer: mapping.py can be extended for new fields
- Single responsibility: each Python module does one job
- File-based I/O: no external DB; everything flows via the filesystem

##### Technologies/Frameworks to Annotate
- Python 3.12 runtime
- CSV module or pandas (from requirements.txt)
- PDF engine (e.g., WeasyPrint or ReportLab)
- Jinja2 or built-in templating (if used in exp.html)

##### Detailed Checklist
[ ] Data source node with all CSV paths

- Clearly shows each component’s responsibility
- Captures data flow from raw CSV to final PDF
- Highlights extension points and external dependencies

## Diagram (Mermaid)

```mermaid
flowchart TB
    A["Raw CSV Data Sources"]:::data
    B["main.py (Orchestrator)"]:::processing
    subgraph "Processing Pipeline"
        C["Parser: tanita_measures_parser.py"]:::processing
        D["Mapper: mapping.py"]:::processing
        E["User Loader: user_data.py"]:::processing
    end
    F["HTML Template: exp.html"]:::template
    G["PDF Generator (WeasyPrint/ReportLab)"]:::template
    H["Generated PDF Report"]:::output
    I["requirements.txt"]:::dependency

    A --> B
    B --> C
    C --> D
    D --> E
    E --> F
    F --> G
    G --> H

    click A "https://github.com/deiugarte/tanita/tree/main/data/TANITA/GRAPHV1/"
    click B "https://github.com/deiugarte/tanita/blob/main/main.py"
    click C "https://github.com/deiugarte/tanita/blob/main/tanita_measures_parser.py"
    click D "https://github.com/deiugarte/tanita/blob/main/mapping.py"
    click E "https://github.com/deiugarte/tanita/blob/main/user_data.py"
    click F "https://github.com/deiugarte/tanita/blob/main/exp.html"
    click I "https://github.com/deiugarte/tanita/blob/main/requirements.txt"

    classDef data fill:#D5E8D4,stroke:#82B366,stroke-width:2px
    classDef processing fill:#DAE8FC,stroke:#6C8EBF,stroke-width:2px
    classDef template fill:#F8CECC,stroke:#B85450,stroke-width:2px
    classDef output fill:#FFF2CC,stroke:#D6B656,stroke-width:2px
    classDef dependency fill:#E1D5E7,stroke:#9673A6,stroke-width:2px
```
