# hieuk09/wallet architecture

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

- Interactive diagram: https://gitdiagram.com/hieuk09/wallet
- Repository: https://github.com/hieuk09/wallet

## Overview

##### Main Components Identification
The system appears to be a monolithic Rails application with the following key components:

a. Web Interface Layer
- Controllers (app/controllers/*)
- Views (app/views/*)
- Assets (app/assets/*)

b. Business Logic Layer
- Models (app/models/*)
- Services (app/services/*)
- Decorators (app/decorators/*)
- Queries (app/queries/*)
- Types (app/types/*)

c. Data Layer
- Database (PostgreSQL/MySQL indicated by database.yml)
- External Services (OpenExchangeRate API)

**[Web Layer]**
- ↓
**[Application Layer]**
- ↓
**[Data Layer]**

**[User Interface]**
- ↓
**[Authentication/Authorization]**
- ↓
**[Core Features]**
- Account Management
- Transaction Processing
- Category Management
- Reporting System
- ↓
**[Services Layer]**
- PDF Processing
- Statement Import
- Exchange Rate Service
- ↓
**[Data Persistence]**
- Database
- External APIs

##### Additional Notes

- Annotations for key business logic flows
- MVC pattern implementation
- Relationship between models (accounts → transactions → categories)
- Background jobs if any
- Points of external service integration

This structure will provide a comprehensive view of the system while maintaining clarity and usefulness for development and maintenance purposes.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Web_Layer
        UI[Web Interface]:::ui
        Assets[Asset Pipeline]:::ui
        Views[View Templates]:::ui
    end

    subgraph Auth_Layer
        Auth[Authentication]:::auth
    end

    subgraph Core_Features
        AM[Account Management]:::core
        TM[Transaction Management]:::core
        CM[Category Management]:::core
        RP[Reporting System]:::core

        click AM "https://github.com/hieuk09/wallet/blob/master/app/controllers/accounts_controller.rb"
        click TM "https://github.com/hieuk09/wallet/blob/master/app/controllers/transactions_controller.rb"
        click CM "https://github.com/hieuk09/wallet/blob/master/app/controllers/categories_controller.rb"
        click RP "https://github.com/hieuk09/wallet/blob/master/app/controllers/reports_controller.rb"
    end

    subgraph Services_Layer
        PDF[PDF Extractor]:::service
        SI[Statement Importer]:::service
        EX[Exchange Rate Service]:::service

        click PDF "https://github.com/hieuk09/wallet/blob/master/app/services/pdf_extractor.rb"
        click SI "https://github.com/hieuk09/wallet/blob/master/app/services/dbs_statement_importer.rb"
        click EX "https://github.com/hieuk09/wallet/blob/master/app/controllers/exchange_rates_controller.rb"
    end

    subgraph Business_Logic
        Models[Models]:::logic
        Decorators[Decorators]:::logic
        Queries[Queries]:::logic

        click Models "https://github.com/hieuk09/wallet/tree/master/app/models"
        click Decorators "https://github.com/hieuk09/wallet/tree/master/app/decorators"
        click Queries "https://github.com/hieuk09/wallet/tree/master/app/queries"
    end

    subgraph Data_Layer
        DB[(Database)]:::data
        Migrations[Migrations]:::data
        Schema[Schema]:::data
        ExternalAPI[OpenExchangeRate API]:::external

        click DB "https://github.com/hieuk09/wallet/blob/master/config/database.yml"
        click Migrations "https://github.com/hieuk09/wallet/tree/master/db/migrate"
        click Schema "https://github.com/hieuk09/wallet/blob/master/db/schema.rb"
    end

    UI --> Auth
    Auth --> Core_Features
    Core_Features --> Services_Layer
    Core_Features --> Business_Logic
    Services_Layer --> Business_Logic
    Business_Logic --> Data_Layer
    EX -.-> ExternalAPI

    %% Component Relationships
    AM --> Models
    TM --> Models
    CM --> Models
    RP --> Queries
    SI --> PDF

    classDef ui fill:#3498db,stroke:#2980b9,color:white
    classDef auth fill:#e74c3c,stroke:#c0392b,color:white
    classDef core fill:#2ecc71,stroke:#27ae60,color:white
    classDef service fill:#9b59b6,stroke:#8e44ad,color:white
    classDef logic fill:#f1c40f,stroke:#f39c12,color:black
    classDef data fill:#e67e22,stroke:#d35400,color:white
    classDef external fill:#95a5a6,stroke:#7f8c8d,color:white

    %% Legend
    subgraph Legend
        L1[UI Components]:::ui
        L2[Authentication]:::auth
        L3[Core Features]:::core
        L4[Services]:::service
        L5[Business Logic]:::logic
        L6[Data Storage]:::data
        L7[External Services]:::external
    end
```
