# dennislwm/pyledger architecture

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

- Interactive diagram: https://gitdiagram.com/dennislwm/pyledger
- Repository: https://github.com/dennislwm/pyledger

## Overview

##### Project Type Analysis
This is a command-line tool that processes financial transactions for the Ledger accounting system, focusing on file processing and transformation. The architecture should emphasize data flow and processing pipelines.

##### Main Components

a. Input Layer:
- Support for multiple input formats (CSV, XLS)
- Input file reader components

b. Processing Layer:
- Rules Engine (based on schema.json)
- Transaction Processors:
- Base Processor (base_processor.py)
- CSV Processor (csv_processor.py)
- XLS Processor (xls_processor.py)

c. Output Layer:
- Ledger-compatible format output generator

**[Input Sources] → [Processing Pipeline] → [Output Generation]**
- ↓                     ↓                      ↓
**CSV Files         Transaction Loading     Ledger Format**
**XLS Files         Rules Application       Output File**
- Transaction Sorting
- Transaction Transform

##### Component Relationships

- Relationship between schema.json and the processing components

##### Specific Elements

a. Input Section:
- CSV File Input Handler
- XLS File Input Handler
- File Format Detection

b. Core Processing:
- Base Processor Component
- Rules Engine (schema.json)
- Transaction Transformer
- Transaction Sorter

c. Output Section:
- Ledger Format Writer
- Output Validation

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph CLI["Command Line Interface"]
        MAIN["Main Application"]:::entry
    end

    subgraph Input["Input Layer"]
        CSV["CSV Input Handler"]:::input
        XLS["XLS Input Handler"]:::input
        FD["Format Detector"]:::input
    end

    subgraph Process["Processing Layer"]
        BP["Base Processor"]:::process
        RE["Rules Engine"]:::process
        TT["Transaction Transformer"]:::process
        TS["Transaction Sorter"]:::process
        RL["Rules Loader"]:::process
    end

    subgraph Config["Configuration"]
        SCHEMA["schema.json"]:::config
    end

    subgraph Output["Output Layer"]
        LW["Ledger Format Writer"]:::output
        OV["Output Validator"]:::output
    end

    %% Relationships
    MAIN --> FD
    FD --> CSV
    FD --> XLS
    CSV --> BP
    XLS --> BP
    BP --> RL
    RL --> RE
    RE --> TT
    TT --> TS
    TS --> LW
    LW --> OV

    SCHEMA -.-> RE
    SCHEMA -.-> RL

    %% Click Events
    click CSV "https://github.com/dennislwm/pyledger/blob/main/app/common/csv_processor.py"
    click XLS "https://github.com/dennislwm/pyledger/blob/main/app/common/xls_processor.py"
    click BP "https://github.com/dennislwm/pyledger/blob/main/app/common/base_processor.py"
    click SCHEMA "https://github.com/dennislwm/pyledger/blob/main/app/schema.json"
    click MAIN "https://github.com/dennislwm/pyledger/blob/main/app/ledger.py"
    click TS "https://github.com/dennislwm/pyledger/blob/main/app/tests/base_sort_transactions_test.py"
    click TT "https://github.com/dennislwm/pyledger/blob/main/app/tests/base_transform_transactions_test.py"
    click RL "https://github.com/dennislwm/pyledger/blob/main/app/tests/base_load_rules_test.py"
    click LW "https://github.com/dennislwm/pyledger/blob/main/app/ledger.py"

    %% Styles
    classDef input fill:#a8d1f0,stroke:#333,stroke-width:2px
    classDef process fill:#90EE90,stroke:#333,stroke-width:2px
    classDef output fill:#FFB347,stroke:#333,stroke-width:2px
    classDef config fill:#D3D3D3,stroke:#333,stroke-width:2px
    classDef entry fill:#FFE4E1,stroke:#333,stroke-width:2px

    %% Legend
    subgraph Legend
        L1["Input Component"]:::input
        L2["Processing Component"]:::process
        L3["Output Component"]:::output
        L4["Configuration"]:::config
        L5["Entry Point"]:::entry
    end
```
