# maddmdr/invise-ihsg-intelligence-platform architecture

> Architecture diagram of the GitHub repository maddmdr/invise-ihsg-intelligence-platform, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-07-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/maddmdr/invise-ihsg-intelligence-platform
- Repository: https://github.com/maddmdr/invise-ihsg-intelligence-platform

## Overview

##### Project type and purpose
- This is a full-stack, single‐page dashboard application built in Python using Streamlit for the UI and a modular “hybrid AI” backend for data ingestion, ML prediction, and LLM-powered narrative. It combines real-time financial data (IHSG and correlated assets) with ensemble models (XGBoost/LightGBM) and Ollama LLM reasoning to drive a predictive analytics dashboard.

##### File structure
- Top level:
- app.py             → Streamlit entry-point (Presentation Layer)
- css.py             → UI styling helpers
- chart_utils.py     → Plotly chart helper functions
- ihsg_platform.py   → Quantitative ML pipeline (feature engineering, model training/inference)
- ollama_chat.py     → Adapter for Ollama LLM calls (narrative analysis & chat)
- requirements.txt   → Dependency manifest
- __pycache__        → compiled Python bytecode
- No separate “frontend” folder—UI lives in app.py + helper modules.
- No persistent database; data is fetched on the fly via yfinance (Data Acquisition Layer).
- External service integration via ollama_chat.py (Ollama API).

##### README for architectural insights
- The README explicitly calls out a 3-layer architecture:
1. Presentation Layer (Streamlit)
2. Hybrid AI Engine (Quant ML pipeline + LLM Reasoning)
3. Data Acquisition Layer (yfinance)
- Technologies: Python 3.10+, Streamlit, Pandas, NumPy, Scikit-learn, XGBoost, LightGBM, Plotly, Ollama.

- Presentation Layer
- app.py (Streamlit server)
- css.py (styles)
- chart_utils.py (visualizations)
- Hybrid AI Engine
- Quantitative Pipeline (ihsg_platform.py)
- LLM Reasoner (ollama_chat.py)
- Data Acquisition Layer
- Yahoo Finance API adapter (inside ihsg_platform.py)
- External Services
- Ollama (local LLM server)
- Yahoo Finance REST API
- User → Streamlit UI (app.py)
- UI → Data Acquisition Layer (fetch raw time-series via yfinance)
- UI → Quantitative Pipeline (train/infer calls to ihsg_platform.py)
- Quantitative Pipeline ↔ LLM Reasoner (pass model outputs to ollama_chat.py for narrative)
- LLM Reasoner → External Ollama service → returns narrative
- AI Engine results → Streamlit UI → rendered via chart_utils.py & css.py
c. Architectural patterns & principles:
- Three-tier layered architecture (separation of concerns)
- Adapter pattern for external services (ollama_chat.py for LLM, direct calls to yfinance)
- Pipeline pattern in ihsg_platform.py (feature engineering → ensemble models → recursive forecasting)
- Modular monolith: all code in a single repo but logically separated by function
d. Key technologies & libraries:
- Python 3.10+, Streamlit (UI), Pandas/NumPy (data manip), Plotly (charts)
- Scikit-learn, XGBoost, LightGBM (ML)
- Ollama local LLM server (LLM reasoning)
- yfinance (data ingestion)

## Diagram (Mermaid)

```mermaid
graph TD
    %% External Services
    User["User"]:::external
    Yahoo["Yahoo Finance API"]:::external
    OllamaServ["Ollama LLM Service"]:::external

    %% Presentation Layer
    subgraph "Presentation Layer"
        direction TB
        App["app.py"]:::frontend
        CSS["css.py"]:::frontend
        Charts["chart_utils.py"]:::frontend
    end

    %% Data Acquisition Layer
    subgraph "Data Acquisition Layer"
        direction TB
        YfAdapter["yfinance adapter\n(ihsg_platform.py)"]:::data
    end

    %% Hybrid AI Engine
    subgraph "Hybrid AI Engine"
        direction TB
        Quant["Quant Pipeline\n(ihsg_platform.py)"]:::ai
        LLM["LLM Reasoner\n(ollama_chat.py)"]:::ai
    end

    %% Data Flows and Control Flows
    User -->|"Interacts"| App
    App -->|"loads styles"| CSS
    App -->|"renders charts"| Charts
    App -->|"requests OHLC data"| YfAdapter
    YfAdapter -->|"OHLC data stream"| App
    App -->|"calls train/infer"| Quant
    Quant -->|"model predictions"| App
    Quant -->|"passes outputs"| LLM
    LLM -->|"sends narrative request"| OllamaServ
    OllamaServ -->|"returns narrative text"| LLM
    LLM -->|"narrative output"| App

    %% External Integrations
    YfAdapter -->|"HTTP requests"| Yahoo

    %% Click Events
    click App "https://github.com/maddmdr/invise-ihsg-intelligence-platform/blob/main/app.py"
    click CSS "https://github.com/maddmdr/invise-ihsg-intelligence-platform/blob/main/css.py"
    click Charts "https://github.com/maddmdr/invise-ihsg-intelligence-platform/blob/main/chart_utils.py"
    click YfAdapter "https://github.com/maddmdr/invise-ihsg-intelligence-platform/blob/main/ihsg_platform.py"
    click Quant "https://github.com/maddmdr/invise-ihsg-intelligence-platform/blob/main/ihsg_platform.py"
    click LLM "https://github.com/maddmdr/invise-ihsg-intelligence-platform/blob/main/ollama_chat.py"

    %% Styles
    classDef frontend fill:#ebf4ff,stroke:#0366d6,color:#0366d6;
    classDef ai fill:#e6ffed,stroke:#28a745,color:#28a745;
    classDef data fill:#fff5e6,stroke:#d73a49,color:#d73a49;
    classDef external fill:#f6f8fa,stroke:#959da5,color:#959da5;
```
