# tsiparinda/capitalbank architecture

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

- Interactive diagram: https://gitdiagram.com/tsiparinda/capitalbank
- Repository: https://github.com/tsiparinda/capitalbank

## Overview

##### Component Details

a. Data Sources Layer:
- PrivatBank API (represented as an external system)
- iBank2UA CSV Files (represented as file storage)

b. Integration Layer (Core Application):
- API Interface Module (from /api)
- This as an abstract interface layer
- Bank-Specific Implementations:
- PrivatBank Module (/pbapi)
- CSV Processing Module (/csv)
- Logic Module (/logic)
- Subcomponents for:
- Payment Exchange
- Transaction Exchange
- Balance Updates
- Store Module (/store)
- Data operations components

c. Storage Layer:
- Capital ERP Database (show as a database symbol)

##### Flow Connections

- Data ingestion flows from PrivatBank API and CSV files
- Processing flows through the integration layer
- Storage flows to the database

##### Technical Details

Annotations for:
- Go-based implementation
- Database connection requirements
- File system dependencies
- API specifications

Key Architectural Patterns to Highlight:
- Interface-based design (api/interfaces.go)
- Modular architecture with clear separation of concerns
- Plugin-style bank integration system
- Data transformation pipeline

Remember to:
- Use consistent symbols throughout
- Version information
- Notes about scalability for new bank integrations

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Styles and Classes
    classDef external fill:#gray,stroke:#333,stroke-width:2px
    classDef core fill:#blue,stroke:#333,stroke-width:2px
    classDef database fill:#green,stroke:#333,stroke-width:2px
    classDef interface fill:#yellow,stroke:#333,stroke-width:2px

    %% Data Sources Layer
    subgraph DataSources
        PB["PrivatBank API"]:::external
        IB["iBank2UA CSV Files"]:::external
    end

    %% Integration Layer
    subgraph Integration
        %% API Interface
        API["API Interface"]:::interface
        click API "https://github.com/tsiparinda/capitalbank/blob/master/api/interfaces.go"

        %% Bank Implementations
        PBAPI["PrivatBank Module"]:::core
        click PBAPI "https://github.com/tsiparinda/capitalbank/blob/master/pbapi/privatbankAPI.go"
        CSV["CSV Processing"]:::core
        click CSV "https://github.com/tsiparinda/capitalbank/blob/master/csv/files_csv.go"
        IBCSV["iBank CSV Module"]:::core
        click IBCSV "https://github.com/tsiparinda/capitalbank/blob/master/ibcsvapi/ibcsvapi.go"

        %% Logic Module
        subgraph Logic
            PE["Payment Exchange"]:::core
            click PE "https://github.com/tsiparinda/capitalbank/blob/master/logic/exchangepayments.go"
            TE["Transaction Exchange"]:::core
            click TE "https://github.com/tsiparinda/capitalbank/blob/master/logic/exchangetran.go"
            BU["Balance Updates"]:::core
            click BU "https://github.com/tsiparinda/capitalbank/blob/master/logic/updatebalance.go"
        end

        %% Store Module
        subgraph Store
            AM["Account Management"]:::core
            click AM "https://github.com/tsiparinda/capitalbank/blob/master/store/load_accounts.go"
            PP["Payment Processing"]:::core
            click PP "https://github.com/tsiparinda/capitalbank/blob/master/store/load_payments.go"
            BM["Balance Management"]:::core
            click BM "https://github.com/tsiparinda/capitalbank/blob/master/store/save_balance.go"
            TM["Transaction Management"]:::core
            click TM "https://github.com/tsiparinda/capitalbank/blob/master/store/save_transactions.go"
            SM["State Management"]:::core
            click SM "https://github.com/tsiparinda/capitalbank/blob/master/store/save_state.go"
        end

        %% Support Components
        CONFIG["Configuration"]:::core
        click CONFIG "https://github.com/tsiparinda/capitalbank/blob/master/config/config.go"
        LOGGER["Logging System"]:::core
        click LOGGER "https://github.com/tsiparinda/capitalbank/blob/master/logger/logger.go"
        UTILS["Utilities"]:::core
        click UTILS "https://github.com/tsiparinda/capitalbank/blob/master/utils/convert.go"

        %% PB API Components
        subgraph PBComponents
            BO["Balance Operations"]:::core
            click BO "https://github.com/tsiparinda/capitalbank/blob/master/pbapi/getbalance.go"
            TO["Transaction Operations"]:::core
            click TO "https://github.com/tsiparinda/capitalbank/blob/master/pbapi/gettransactions.go"
            PO["Payment Operations"]:::core
            click PO "https://github.com/tsiparinda/capitalbank/blob/master/pbapi/sendpayment.go"
            SO["State Operations"]:::core
            click SO "https://github.com/tsiparinda/capitalbank/blob/master/pbapi/getstate.go"
        end
    end

    %% Storage Layer
    DB["Capital ERP Database"]:::database
    click DB "https://github.com/tsiparinda/capitalbank/blob/master/db/init.go"

    %% Connections
    PB --> PBAPI
    IB --> CSV
    IB --> IBCSV
    
    PBAPI --> API
    CSV --> API
    IBCSV --> API
    
    API --> Logic
    Logic --> Store
    Store --> DB

    %% Support Component Connections
    CONFIG -.-> Integration
    LOGGER -.-> Integration
    UTILS -.-> Integration

    %% PB API Component Connections
    PBAPI --> PBComponents
    PBComponents --> Logic

    %% Legend
    subgraph Legend
        L1["External Systems"]:::external
        L2["Core Components"]:::core
        L3["Database"]:::database
        L4["Interfaces"]:::interface
    end
```
