# fromtaoyuanhsinchuuuu/cryptoledger architecture

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

- Interactive diagram: https://gitdiagram.com/fromtaoyuanhsinchuuuu/cryptoledger
- Repository: https://github.com/fromtaoyuanhsinchuuuu/cryptoledger

## Overview

##### Main Components
a. User Interfaces:
- Web Interface: Represented by app.py (Streamlit based).
- Command-Line Interface: Represented by cli.py.
b. Business Logic and Core Functionalities:
- Transaction Management: transaction_manager.py (handles transaction operations).
- Financial Calculations: calculator.py.
- Portfolio Analysis: portfolio.py.
- Tax Reporting: tax_reporter.py.
c. Data Layer:
- Models: models.py, which defines the data entities (transactions, wallets, etc.).
- Database: database.py, which handles storage and retrieval.
d. External Services:
- Crypto API Integration: crypto_api.py, which fetches real-time cryptocurrency data.
e. Utilities:
- utils.py, which contains helper functions that support various components.

##### Architectural Patterns and Design Principles
- Separation of Concerns: Different files separate UI handling, business logic, and data persistence. Each module is responsible for a specific functionality.
- Modularity: Each component (CLI, web, API, calculations) is self-contained, making it easier to manage, test, and extend.
- Integration Points: Highlight how the system integrates with an external cryptocurrency API and uses internal modules to generate outputs (portfolio summaries and tax reports).

- Clearly labeled components:
- “Web Interface (app.py)”
- “CLI Interface (cli.py)”
- “Transaction Manager (transaction_manager.py)”
- “Financial Calculator (calculator.py)”
- “Portfolio Analysis (portfolio.py)”
- “Tax Reporter (tax_reporter.py)”
- “Data Models (models.py)”
- “Database (database.py)”
- “Crypto API Connector (crypto_api.py)”
- “Utilities (utils.py)”
- User Interface modules and Business Logic.
- Business Logic and both the Database and External Crypto API.
- Middleware or shared utility connectors that might be relevant (e.g., the use of utils.py across multiple modules).

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Interfaces
    subgraph "User Interfaces"
        web["Web Interface (app.py)"]
        cli["CLI Interface (cli.py)"]
    end

    %% Business Logic Components
    subgraph "Business Logic"
        tm(("Transaction Manager (transaction_manager.py)"))
        calc(("Financial Calculator (calculator.py)"))
        port(("Portfolio Analysis (portfolio.py)"))
        tax(("Tax Reporter (tax_reporter.py)"))
    end

    %% Data & External Services
    subgraph "Data & External Services"
        models["Data Models (models.py)"]
        db[("Database Module (database.py)")]
        crypto["Crypto API Connector (crypto_api.py)"]
        utils["Utilities (utils.py)"]
    end

    %% UI to Business Logic
    web -->|"calls"| tm
    cli -->|"calls"| tm

    %% Business Logic delegation
    tm -->|"delegates_to"| calc
    tm -->|"delegates_to"| port
    tm -->|"delegates_to"| tax

    %% Business Logic uses Data Models and Database
    tm -->|"uses"| models
    calc -->|"uses"| models
    port -->|"uses"| models
    tax -->|"uses"| models

    tm -->|"persists_to"| db
    calc -->|"persists_to"| db
    port -->|"persists_to"| db
    tax -->|"persists_to"| db

    %% Business Logic fetch external data
    tm -->|"fetches"| crypto
    port -->|"fetches"| crypto

    %% Business Logic utilizes Utilities
    tm -->|"utilizes"| utils
    calc -->|"utilizes"| utils
    port -->|"utilizes"| utils
    tax -->|"utilizes"| utils

    %% Click Events
    click web "https://github.com/fromtaoyuanhsinchuuuu/cryptoledger/blob/main/app.py"
    click cli "https://github.com/fromtaoyuanhsinchuuuu/cryptoledger/blob/main/cli.py"
    click tm "https://github.com/fromtaoyuanhsinchuuuu/cryptoledger/blob/main/transaction_manager.py"
    click calc "https://github.com/fromtaoyuanhsinchuuuu/cryptoledger/blob/main/calculator.py"
    click port "https://github.com/fromtaoyuanhsinchuuuu/cryptoledger/blob/main/portfolio.py"
    click tax "https://github.com/fromtaoyuanhsinchuuuu/cryptoledger/blob/main/tax_reporter.py"
    click models "https://github.com/fromtaoyuanhsinchuuuu/cryptoledger/blob/main/models.py"
    click db "https://github.com/fromtaoyuanhsinchuuuu/cryptoledger/blob/main/database.py"
    click crypto "https://github.com/fromtaoyuanhsinchuuuu/cryptoledger/blob/main/crypto_api.py"
    click utils "https://github.com/fromtaoyuanhsinchuuuu/cryptoledger/blob/main/utils.py"

    %% Styles
    classDef ui fill:#AED6F1,stroke:#1B4F72,stroke-width:2px;
    classDef logic fill:#F9E79F,stroke:#B7950B,stroke-width:2px;
    classDef database fill:#D5F5E3,stroke:#27AE60,stroke-width:2px;
    classDef external fill:#F5B7B1,stroke:#C0392B,stroke-width:2px;
    classDef dataModel fill:#E8DAEF,stroke:#8E44AD,stroke-width:2px;
    classDef utility fill:#FAD7A0,stroke:#AF601A,stroke-width:2px;

    class web,cli ui;
    class tm,calc,port,tax logic;
    class models dataModel;
    class db database;
    class crypto external;
    class utils utility;
```
