# jean-edouard-boulanger/finbot architecture

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

- Interactive diagram: https://gitdiagram.com/jean-edouard-boulanger/finbot
- Repository: https://github.com/jean-edouard-boulanger/finbot

## Overview

##### High-Level Architecture Components

The system should be represented as a multi-tier architecture with these main components:

a. Frontend Layer:
- React Web Application (webapp/)
- REST API interactions with backend
- Features: authentication, dashboard, reports, settings

b. Backend Services Layer (show as separate microservices):
- appwsrv (Main application API)
- finbotwsrv (Financial data fetching service)
- snapwsrv (Snapshot orchestration service)
- histwsrv (Financial reporting service)
- schedsrv (Scheduling service)

c. Data Providers Layer:
- External Financial Services (Plaid, Credit Agricole, Aegon, etc.)
- APIs (Kraken, Binance, etc.)
- Manual Input (Google Sheets)

d. Infrastructure Layer:
- PostgreSQL Database
- RabbitMQ (indicated by rmq.py)
- Docker containers

##### Interaction Flows

a. Data Flow:
- User interactions → Frontend → appwsrv
- schedsrv → finbotwsrv → External Providers
- snapwsrv orchestration flow
- histwsrv reporting workflow

b. Authentication Flow:
- Auth context and user session management
- Security boundaries

##### Key Components Detail

a. Core Services (Rectangle):
- Blue: Web Services
- Green: Data Processing Services
- Yellow: Scheduled Tasks

- Database
- Key-Value Store

c. External Systems (Cloud):
- Third-party Financial Providers
- APIs

##### Additional Elements

Include:

- Component types

b. Security Boundaries:
- Internal network
- External network
- Authentication zones

##### Implementation Details

Implementation aspects:

a. Technology Stack:
- Python Backend
- React Frontend
- SQLAlchemy ORM
- OpenAPI/Swagger Integration

b. Service Communication:
- REST APIs
- Message Queue
- Database Access

##### Deployment Context

Include:

a. Docker Container Boundaries:
- Service isolation
- Network segments

b. Environment Configuration:
- Development vs Production setup
- Configuration management

##### Monitoring & Operations

Include:

a. Health Checks:
- Service status monitoring
- Error handling

b. Data Flow Monitoring:
- Logging points
- Metrics collection

Remember to emphasize the self-hosted nature of the system and the security implications of handling financial credentials, as mentioned in the disclaimer.

## Diagram (Mermaid)

```mermaid
graph TB
    subgraph Frontend
        WA["React Web App"]:::frontend
        API_Client["API Clients"]:::frontend
    end

    subgraph "Backend Services"
        APP["Application API Service"]:::service
        FIN["Financial Data Service"]:::service
        SNAP["Snapshot Service"]:::service
        HIST["History Service"]:::service
        SCHED["Scheduling Service"]:::service
        
        subgraph "Core Services"
            AUTH["Authentication"]:::core
            SPEC["API Specifications"]:::core
            REP["Financial Reports"]:::core
            UAV["User Account Services"]:::core
            VHW["Valuation History"]:::core
            RMQ["Message Queue"]:::infra
        end
    end

    subgraph "Data Storage"
        DB[(PostgreSQL)]:::database
    end

    subgraph "External Providers"
        PLAID["Plaid API"]:::external
        KRAKEN["Kraken API"]:::external
        BINANCE["Binance API"]:::external
        SHEETS["Google Sheets"]:::external
    end

    %% Frontend Connections
    WA --> API_Client
    API_Client --> APP

    %% Core Service Flows
    APP --> AUTH
    APP --> SPEC
    APP --> REP
    APP --> DB
    
    %% Data Service Flows
    SCHED --> RMQ
    RMQ --> FIN
    FIN --> PLAID & KRAKEN & BINANCE
    FIN --> DB
    
    %% Snapshot and History Flows
    SNAP --> UAV
    HIST --> VHW
    UAV & VHW --> DB

    %% Click Events
    click WA "https://github.com/jean-edouard-boulanger/finbot/tree/master/webapp/src/"
    click API_Client "https://github.com/jean-edouard-boulanger/finbot/tree/master/webapp/src/clients/app-client/"
    click APP "https://github.com/jean-edouard-boulanger/finbot/tree/master/finbot/apps/appwsrv/"
    click FIN "https://github.com/jean-edouard-boulanger/finbot/tree/master/finbot/apps/finbotwsrv/"
    click SCHED "https://github.com/jean-edouard-boulanger/finbot/tree/master/finbot/apps/schedsrv/"
    click AUTH "https://github.com/jean-edouard-boulanger/finbot/blob/master/finbot/apps/appwsrv/blueprints/auth.py"
    click SPEC "https://github.com/jean-edouard-boulanger/finbot/blob/master/finbot/apps/appwsrv/spec.py"
    click REP "https://github.com/jean-edouard-boulanger/finbot/tree/master/finbot/apps/appwsrv/reports/"
    click UAV "https://github.com/jean-edouard-boulanger/finbot/tree/master/finbot/services/user_account_valuation/"
    click VHW "https://github.com/jean-edouard-boulanger/finbot/tree/master/finbot/services/valuation_history_writer/"
    click RMQ "https://github.com/jean-edouard-boulanger/finbot/blob/master/finbot/core/rmq.py"
    click DB "https://github.com/jean-edouard-boulanger/finbot/tree/master/finbot/core/db/"
    click PLAID "https://github.com/jean-edouard-boulanger/finbot/blob/master/finbot/core/plaid.py"
    click KRAKEN "https://github.com/jean-edouard-boulanger/finbot/blob/master/finbot/providers/kraken_us.py"
    click BINANCE "https://github.com/jean-edouard-boulanger/finbot/blob/master/finbot/providers/binance_us.py"

    classDef frontend fill:#42A5F5,stroke:#1976D2,color:white
    classDef service fill:#66BB6A,stroke:#388E3C,color:white
    classDef core fill:#FFA726,stroke:#F57C00,color:white
    classDef infra fill:#AB47BC,stroke:#7B1FA2,color:white
    classDef database fill:#78909C,stroke:#455A64,color:white
    classDef external fill:#EF5350,stroke:#D32F2F,color:white

    %% Legend
    subgraph Legend
        F["Frontend Component"]:::frontend
        S["Backend Service"]:::service
        C["Core Service"]:::core
        I["Infrastructure"]:::infra
        D["Database"]:::database
        E["External Provider"]:::external
    end
```
