# thinh-vu/vnstock architecture

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

- Interactive diagram: https://gitdiagram.com/thinh-vu/vnstock
- Repository: https://github.com/thinh-vu/vnstock

## Overview

##### Main System Components

The system architecture should be organized into these key components:

a) Core Layer
- Configuration management (/core/config)
- Utility functions (/core/utils)
- Data conversion (/core/converter)

b) Data Explorer Layer
- Multiple data source connectors:
- TCBS Explorer
- VCI Explorer
- MSN Explorer
- FMarket Explorer
- Misc Explorer (exchange rates, gold prices)

c) Common Layer
- Data exploration tools
- Plotting capabilities
- CLI interface

d) Bot Builder Layer
- Notification system

##### Component Relationships

**[External Data Sources] → [Data Connectors] → [Core Layer] → [Common Layer] → [End User Interface]**
- ↑
- [Bot Builder Layer]

##### Specific Implementation Details

a) Data Flow
- How data flows from external sources through the connectors
- Data transformation through the core layer
- Demonstrate how processed data reaches end-users

b) Component Integration
- How the bot builder integrates with the core system
- How different explorers interact with their respective data sources

##### Key Technologies to Highlight

- Python as the primary language
- Data processing libraries
- API integrations with various data sources
- Visualization capabilities

##### Architecture Patterns

Emphasize:
- Modular design with clear separation of concerns
- Plugin-style architecture for data sources
- Service-oriented approach for data retrieval

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph External["External Data Sources"]
        TCBS_SRC["TCBS API"]
        VCI_SRC["VCI API"]
        MSN_SRC["MSN API"]
        FM_SRC["FMarket API"]
        MISC_SRC["Misc Sources"]
    end

    subgraph DataExplorer["Data Explorer Layer"]
        TCBS["TCBS Explorer"]:::explorer
        VCI["VCI Explorer"]:::explorer
        MSN["MSN Explorer"]:::explorer
        FM["FMarket Explorer"]:::explorer
        MISC["Misc Explorer"]:::explorer
    end

    subgraph Core["Core Layer"]
        CONFIG["Configuration Management"]:::core
        UTILS["Utility Functions"]:::core
        CONV["Data Conversion"]:::core
        AUTH["Authentication"]:::core
    end

    subgraph Common["Common Layer"]
        DATA_EX["Data Exploration Tools"]:::common
        PLOT["Plotting Capabilities"]:::common
        CLI["CLI Interface"]:::common
    end

    subgraph BotBuilder["Bot Builder Layer"]
        NOTI["Notification System"]:::botbuilder
    end

    subgraph Models["Data Models"]
        TCBS_M["TCBS Models"]:::model
        VCI_M["VCI Models"]:::model
        MSN_M["MSN Models"]:::model
    end

    subgraph Constants["Constants & Configs"]
        TCBS_C["TCBS Constants"]:::const
        VCI_C["VCI Constants"]:::const
        MSN_C["MSN Constants"]:::const
        FM_C["FMarket Constants"]:::const
    end

    %% Relationships
    TCBS_SRC --> TCBS
    VCI_SRC --> VCI
    MSN_SRC --> MSN
    FM_SRC --> FM
    MISC_SRC --> MISC

    TCBS --> CONFIG
    VCI --> CONFIG
    MSN --> CONFIG
    FM --> CONFIG
    MISC --> CONFIG

    CONFIG --> UTILS
    UTILS --> CONV
    AUTH --> CONFIG

    CONV --> DATA_EX
    DATA_EX --> PLOT
    DATA_EX --> CLI

    CONFIG --> NOTI
    UTILS --> NOTI

    TCBS --> TCBS_M
    VCI --> VCI_M
    MSN --> MSN_M

    TCBS --> TCBS_C
    VCI --> VCI_C
    MSN --> MSN_C
    FM --> FM_C

    %% Click Events
    click CONFIG "https://github.com/thinh-vu/vnstock/tree/main/vnstock/core/config/"
    click UTILS "https://github.com/thinh-vu/vnstock/tree/main/vnstock/core/utils/"
    click CONV "https://github.com/thinh-vu/vnstock/tree/main/vnstock/core/converter/"
    click TCBS "https://github.com/thinh-vu/vnstock/tree/main/vnstock/explorer/tcbs/"
    click VCI "https://github.com/thinh-vu/vnstock/tree/main/vnstock/explorer/vci/"
    click MSN "https://github.com/thinh-vu/vnstock/tree/main/vnstock/explorer/msn/"
    click FM "https://github.com/thinh-vu/vnstock/tree/main/vnstock/explorer/fmarket/"
    click MISC "https://github.com/thinh-vu/vnstock/tree/main/vnstock/explorer/misc/"
    click DATA_EX "https://github.com/thinh-vu/vnstock/blob/main/vnstock/common/data/data_explorer.py"
    click PLOT "https://github.com/thinh-vu/vnstock/blob/main/vnstock/common/plot/chart_wrapper.py"
    click CLI "https://github.com/thinh-vu/vnstock/blob/main/vnstock/common/cli.py"
    click NOTI "https://github.com/thinh-vu/vnstock/blob/main/vnstock/botbuilder/noti.py"
    click AUTH "https://github.com/thinh-vu/vnstock/blob/main/vnstock/core/config/auth.py"
    click TCBS_M "https://github.com/thinh-vu/vnstock/blob/main/vnstock/explorer/tcbs/models.py"
    click VCI_M "https://github.com/thinh-vu/vnstock/blob/main/vnstock/explorer/vci/models.py"
    click MSN_M "https://github.com/thinh-vu/vnstock/blob/main/vnstock/explorer/msn/models.py"
    click TCBS_C "https://github.com/thinh-vu/vnstock/blob/main/vnstock/explorer/tcbs/const.py"
    click VCI_C "https://github.com/thinh-vu/vnstock/blob/main/vnstock/explorer/vci/const.py"
    click MSN_C "https://github.com/thinh-vu/vnstock/blob/main/vnstock/explorer/msn/const.py"
    click FM_C "https://github.com/thinh-vu/vnstock/blob/main/vnstock/explorer/fmarket/const.py"

    %% Styles
    classDef core fill:#2196F3,stroke:#1565C0,color:white
    classDef explorer fill:#4CAF50,stroke:#2E7D32,color:white
    classDef common fill:#FF9800,stroke:#EF6C00,color:white
    classDef botbuilder fill:#9C27B0,stroke:#6A1B9A,color:white
    classDef model fill:#795548,stroke:#4E342E,color:white
    classDef const fill:#607D8B,stroke:#37474F,color:white

    %% Legend
    subgraph Legend
        L1["Core Components"]:::core
        L2["Data Explorers"]:::explorer
        L3["Common Tools"]:::common
        L4["Bot Builder"]:::botbuilder
        L5["Data Models"]:::model
        L6["Constants"]:::const
    end
```
