# ja-perez/mywow architecture

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

- Interactive diagram: https://gitdiagram.com/ja-perez/mywow
- Repository: https://github.com/ja-perez/mywow

## Overview

##### Project Overview
- The project is centered around automated trading and asset management, evident from modules for analysis, trade/portfolio models, and services that integrate with live data (e.g., Coinbase, WebSocket).
- Its purpose is to run a suite of trading functionalities automatically, monitor positions, consolidate assets, and likely display dashboards and charts for user insights.

##### Main Components
a. Entry Point and Core Controller:
- main.py is the application’s starting point.
- Files like controller.py and dashboard.py serve as coordination/cohesion components, managing logic between services and UI.

b. Data and Domain Model Layer:
- The models directory contains business entities like “candles”, “portfolio”, “prediction”, and “trades”. These represent the core data structures for trading and financial information.
- The database module (database directory) includes files for initializing, setting up (database_setup_service.py), and even sample SQL data (coindata.sql). This layer supports persistent storage.

c. Business Logic / Service Layer:
- The services folder implements the operational logic required for trading.
- Specific files like coinbase_services.py, portfolio_service.py, prediction_service.py, websocket_service.py, and even an example file (ws_example.py) encapsulate functionalities such as connecting to external APIs, performing predictions, and handling real-time data via WebSockets.

d. User Interaction Layer:
- Complementing this is inputhandling (input_handler.py) which suggests that user or automated input processing is a dedicated component.

e. Auxiliary Components:
- analysis_service.py and design files (including dummy_data_examples.txt and ideers.md) that help for analysis, proposed ideas/design schemes, and quick prototypes.
- Utility files under utils (e.g., custom_exceptions.py, utils.py) standardize error handling and helper functions across the platform.

##### Relationships and Interactions
- The Controller interacts with the input handling component (inputhandler/input_handler.py) to process incoming commands or automated triggers.
- Data flows from services to and from the database module—in particular, database/database.py serves as the access point for data storage and retrieval.
- Services layer consumes models (from models/) to perform computations, make trade predictions, execute portfolio updates, and communicate with external APIs (like Coinbase) and WebSocket feeds.
- The UI layer (charts and menu modules) presents processed, real-time data to users, with feedback loops going back to the controller and input handler.
- Utilities provide cross-cutting support like exception handling and common helper functions.

##### Architectural Patterns and Design Principles
- Modular separation of concerns: Distinct directories (models, services, database, ui, inputhandling) suggest a clear division of responsibility.
- Layered architecture: Separation between presentation (UI), business logic (services, controller), and data storage (database, models).
- Domain-driven design: Models capture the core domain of trading and prediction.
- Emphasis on external integration points: Services layer integrates with external systems (Coinbase, WebSocket) which are clearly represented.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "Entry & Core Controller"
        nodeMain["main.py"]:::entry
        nodeController["controller.py"]:::controller
        nodeDashboard["dashboard.py"]:::controller
        nodeInput["input_handler.py"]:::controller
    end

    subgraph "Business Logic / Services"
        s1["coinbase_services.py"]:::service
        s2["portfolio_service.py"]:::service
        s3["prediction_service.py"]:::service
        s4["websocket_service.py"]:::service
        s5["ws_example.py"]:::service
        s6["analysis_service.py"]:::service
    end

    subgraph "Data & Domain Models"
        m1["models/candles.py"]:::model
        m2["models/portfolio.py"]:::model
        m3["models/prediction.py"]:::model
        m4["models/trades.py"]:::model
    end

    subgraph "Database Layer"
        d1["database.py"]:::db
        d2["database_setup_service.py"]:::db
        d3["coindata.sql"]:::db
    end

    subgraph "User Interface"
        ui1["charts.py"]:::ui
        ui2["menu.py"]:::ui
    end

    subgraph "Auxiliary & Utilities"
        aux1["dummy_data_examples.txt"]:::aux
        aux2["ideers.md"]:::aux
        aux3["menus.md"]:::aux
        aux4["custom_exceptions.py"]:::aux
        aux5["utils.py"]:::aux
        aux6["TODO.md"]:::aux
        aux7["README.md"]:::aux
        aux8[".env.example"]:::aux
    end

    %% Relationships
    nodeMain -->|"init"| nodeController
    nodeMain -->|"init"| nodeDashboard

    nodeController -->|"process"| nodeInput

    nodeController -->|"invoke"| s1
    nodeController -->|"invoke"| s2
    nodeController -->|"invoke"| s3
    nodeController -->|"invoke"| s4
    nodeController -->|"invoke"| s6

    nodeDashboard -->|"display"| ui1
    nodeDashboard -->|"display"| ui2

    ui2 -->|"command"| nodeInput

    %% Services to Domain Models interactions
    s1 -->|"feeds"| m1
    s2 -->|"updates"| m2
    s3 -->|"analyzes"| m3
    s4 -->|"trades"| m4

    %% Services and Database interactions
    s1 -->|"store"| d1
    s3 -->|"store"| d1
    d1 -->|"fetch"| s2

    %% Auxiliary interactions (dotted lines)
    nodeController -.->|"error_handling"| aux4
    s6 -.->|"helpers"| aux5

    %% Click events for Entry & Core Controller
    click nodeMain "https://github.com/ja-perez/mywow/blob/main/main.py"
    click nodeController "https://github.com/ja-perez/mywow/blob/main/controller.py"
    click nodeDashboard "https://github.com/ja-perez/mywow/blob/main/dashboard.py"
    click nodeInput "https://github.com/ja-perez/mywow/blob/main/inputhandling/input_handler.py"

    %% Click events for Business Logic / Services
    click s1 "https://github.com/ja-perez/mywow/blob/main/services/coinbase_services.py"
    click s2 "https://github.com/ja-perez/mywow/blob/main/services/portfolio_service.py"
    click s3 "https://github.com/ja-perez/mywow/blob/main/services/prediction_service.py"
    click s4 "https://github.com/ja-perez/mywow/blob/main/services/websocket_service.py"
    click s5 "https://github.com/ja-perez/mywow/blob/main/services/ws_example.py"
    click s6 "https://github.com/ja-perez/mywow/blob/main/analysis_service.py"

    %% Click events for Data & Domain Models
    click m1 "https://github.com/ja-perez/mywow/blob/main/models/candles.py"
    click m2 "https://github.com/ja-perez/mywow/blob/main/models/portfolio.py"
    click m3 "https://github.com/ja-perez/mywow/blob/main/models/prediction.py"
    click m4 "https://github.com/ja-perez/mywow/blob/main/models/trades.py"

    %% Click events for Database Layer
    click d1 "https://github.com/ja-perez/mywow/blob/main/database/database.py"
    click d2 "https://github.com/ja-perez/mywow/blob/main/database/database_setup_service.py"
    click d3 "https://github.com/ja-perez/mywow/blob/main/database/coindata.sql"

    %% Click events for User Interface
    click ui1 "https://github.com/ja-perez/mywow/blob/main/ui/charts.py"
    click ui2 "https://github.com/ja-perez/mywow/blob/main/ui/menu.py"

    %% Click events for Auxiliary & Utilities
    click aux1 "https://github.com/ja-perez/mywow/blob/main/design/dummy_data_examples.txt"
    click aux2 "https://github.com/ja-perez/mywow/blob/main/design/ideers.md"
    click aux3 "https://github.com/ja-perez/mywow/blob/main/design/menus.md"
    click aux4 "https://github.com/ja-perez/mywow/blob/main/utils/custom_exceptions.py"
    click aux5 "https://github.com/ja-perez/mywow/blob/main/utils/utils.py"
    click aux6 "https://github.com/ja-perez/mywow/blob/main/TODO.md"
    click aux7 "https://github.com/ja-perez/mywow/blob/main/README.md"
    click aux8 "https://github.com/ja-perez/mywow/blob/main/.env.example"

    %% Styles: colors and shapes
    classDef entry fill:#F1C40F,stroke:#000,stroke-width:1px;
    classDef controller fill:#3498DB,stroke:#000,stroke-width:1px;
    classDef service fill:#2ECC71,stroke:#000,stroke-width:1px;
    classDef model fill:#E67E22,stroke:#000,stroke-width:1px;
    classDef db fill:#E74C3C,stroke:#000,stroke-width:1px;
    classDef ui fill:#9B59B6,stroke:#000,stroke-width:1px;
    classDef aux fill:#95A5A6,stroke:#000,stroke-width:1px;
```
