# khiemdoan/market-today architecture

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

- Interactive diagram: https://gitdiagram.com/khiemdoan/market-today
- Repository: https://github.com/khiemdoan/market-today

## Overview

##### Project Overview & Type
- This is a lightweight, automation-focused notifier written in Python. Its purpose is to fetch or process cryptocurrency-related data (from sources like Bybit and others) and automatically send notifications to a Telegram channel.
- GitHub Actions are central to its functioning, serving as the automation runner to trigger update scripts.

##### Main Components
a. GitHub Actions Workflows:
- .github/workflows directory which contains several YAML files (e.g., update_fgi.yml, update_launchpool.yml, update_p2p.yml, update_tops.yml, update_vnindex.yml). Each workflow is responsible for triggering a specific update process.
b. Update Script Modules:
- Update script in the src/ directory (update_fgi.py, update_launchpool.py, update_p2p.py, update_tops.py, update_vnindex.py) that are executed by the workflows.
c. Client & DTO Layers:
- A module layer labeled “Clients” (e.g., src/clients/bybit.py) that likely handles external API interactions with crypto exchanges/services.
- “DTOs” (Data Transfer Objects) from src/dtos (files like base.py, bybit.py, fgi.py, tops.py) responsible for formatting and normalizing the data.
d. Templates:
- “Templates” module (files with .j2 extension found in src/templates, such as launchpool.j2, p2p.j2, top.j2) which formats data into messages.
e. Telegram Integration:
- Telegram notification component (contained in src/telegram.py) that sends the formatted notifications.
f. Additional Utilities:
- Supplementary components like src/trading_view.py and src/utils.py, which could represent additional functionalities or data sources.
g. Data Persistence:
- Data directory (data/p2p.csv) that might be used to store intermediate or fetched data.

##### Relationships and Data Flow
- Each update script uses:
- The corresponding DTO to process data.
- A Client module to fetch or interact with external crypto APIs.
- The Template module to structure the message.
- Final output: The data flows to the Telegram module which sends notifications to a Telegram chat.
- Optionally, indicate any logging or data persistence (via the data folder).

##### Architectural Patterns & Design Principles
- Separation of Concerns: Different modules (Clients, DTOs, Templates, Update Scripts) clearly separate responsibilities.
- Automation via GitHub Actions: Highlight how CI/CD (or scheduled jobs) trigger the update processes.
- Modular and Extensible Design: New update scripts or templates can easily be added for new data sources or notifications.

##### Relevant Technologies & Frameworks
- Python as the primary language with well-defined modules.
- GitHub Actions for orchestration/automation.
- Telegram’s API (accessed via src/telegram.py) to deliver notifications.
- Jinja2-like templating system (judging by the .j2 extensions in the templates folder).

## Diagram (Mermaid)

```mermaid
flowchart TD
    A["GitHub Actions Workflows"]:::actions
    A --> U

    subgraph "Update Script Modules"
        B1["update_fgi.py"]:::script
        B2["update_launchpool.py"]:::script
        B3["update_p2p.py"]:::script
        B4["update_tops.py"]:::script
        B5["update_vnindex.py"]:::script
    end

    U --> C["Clients Module (bybit)"]:::client
    
    C --> D_A["base.py"]:::dto
    D_A --> D_B["bybit.py"]:::dto
    D_B --> D_C["fgi.py"]:::dto
    D_C --> D_D["tops.py"]:::dto
    
    D_D --> T_A["launchpool.j2"]:::template
    T_A --> T_B["p2p.j2"]:::template
    T_B --> T_C["top.j2"]:::template
    
    T_C --> F["Telegram Notifier"]:::telegram

    U --> U1["trading_view.py"]:::utils
    U --> U2["utils.py"]:::utils

    U --> H["CSV Data Storage"]:::database

    %% Click Events
    click A "https://github.com/khiemdoan/market-today/tree/main/.github/workflows/"
    click B1 "https://github.com/khiemdoan/market-today/blob/main/src/update_fgi.py"
    click B2 "https://github.com/khiemdoan/market-today/blob/main/src/update_launchpool.py"
    click B3 "https://github.com/khiemdoan/market-today/blob/main/src/update_p2p.py"
    click B4 "https://github.com/khiemdoan/market-today/blob/main/src/update_tops.py"
    click B5 "https://github.com/khiemdoan/market-today/blob/main/src/update_vnindex.py"
    click C "https://github.com/khiemdoan/market-today/blob/main/src/clients/bybit.py"
    click D_A "https://github.com/khiemdoan/market-today/blob/main/src/dtos/base.py"
    click D_B "https://github.com/khiemdoan/market-today/blob/main/src/dtos/bybit.py"
    click D_C "https://github.com/khiemdoan/market-today/blob/main/src/dtos/fgi.py"
    click D_D "https://github.com/khiemdoan/market-today/blob/main/src/dtos/tops.py"
    click T_A "https://github.com/khiemdoan/market-today/blob/main/src/templates/launchpool.j2"
    click T_B "https://github.com/khiemdoan/market-today/blob/main/src/templates/p2p.j2"
    click T_C "https://github.com/khiemdoan/market-today/blob/main/src/templates/top.j2"
    click F "https://github.com/khiemdoan/market-today/blob/main/src/telegram.py"
    click U1 "https://github.com/khiemdoan/market-today/blob/main/src/trading_view.py"
    click U2 "https://github.com/khiemdoan/market-today/blob/main/src/utils.py"
    click H "https://github.com/khiemdoan/market-today/blob/main/data/p2p.csv"

    %% Styles
    classDef actions fill:#ffdd99,stroke:#d35400,stroke-width:2px;
    classDef script fill:#cce5ff,stroke:#2980b9,stroke-width:2px;
    classDef client fill:#d5f5e3,stroke:#27ae60,stroke-width:2px;
    classDef dto fill:#fad7a0,stroke:#e67e22,stroke-width:2px;
    classDef template fill:#f9e79f,stroke:#f1c40f,stroke-width:2px;
    classDef telegram fill:#f5b7b1,stroke:#c0392b,stroke-width:2px;
    classDef utils fill:#d7bde2,stroke:#8e44ad,stroke-width:2px;
    classDef database fill:#d1f2eb,stroke:#16a085,stroke-width:2px;
```
