# monishkumardvs/aihedgenexus architecture

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

- Interactive diagram: https://gitdiagram.com/monishkumardvs/aihedgenexus
- Repository: https://github.com/monishkumardvs/aihedgenexus

## Overview

##### External Entities
- Trader (User)
– Inputs stock tickers, date ranges, and views the dashboard.
- Market Data Providers
– Yahoo Finance API
– Alpaca API
- News & Sentiment Source
– Financial news feed consumed by FinBERT (Hugging Face)
- Gemini LLM Service
– External model endpoint for decision synthesis

##### Main Process
- Process 1.0: “Generate Trading Recommendation”
– Represents the entire AI-driven pipeline (Data Layer → Agent Layer → Synthesis → Output)

##### Data Stores
- D1: Raw Market Data Cache
– Temporarily holds price, volume, and fundamental metrics fetched via `tools/api.py`.
- D2: Agent Scores
– Stores intermediate results from:
· Sentiment Agent (`agents/sentiment.py`)
· Technical Agent (`agents/technicals.py`)
· Fundamental Agent (`agents/fundamental.py`)
· Risk Agent (`agents/risk.py`)
- D3: State Graph / Session State
– LangChain state graph maintained in `utils/state.py` for multi-agent coordination and user session data

##### Data Flows
- F1: “Ticker & Date Range”
– Trader → Process 1.0
- F2: “Data Request”
– Process 1.0 → Yahoo Finance API / Alpaca API
- F3: “Market & News Data”
– Yahoo Finance API / Alpaca API / News Feed → D1
- F4: “Raw Data”
– D1 → Process 1.0
- F5: “Agent Results”
– Process 1.0 → D2
- F6: “Intermediate Scores”
– D2 → Process 1.0
- F7: “Synthesis Prompt”
– Process 1.0 → Gemini LLM Service
- F8: “Recommendation + Rationale”
– Gemini LLM → Process 1.0
- F9: “Session Update”
– Process 1.0 → D3
- F10: “Dashboard Data”
– Process 1.0 → Streamlit UI (Trader)

- One large rounded-rectangle labeled “1.0 Generate Trading Recommendation.”
- Surround it with:
– From Trader → Process with F1.
– Process → APIs with F2.
– APIs → D1 with F3.
– D1 → Process with F4.
– Process → D2 with F5; D2 → Process with F6.
– Process → Gemini LLM with F7; LLM → Process with F8.
– Process → D3 with F9.
– Process → Trader (via Streamlit UI) with F10.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Entities
    Trader["Trader (User)"]:::external
    YahooAPI["Yahoo Finance API"]:::external
    AlpacaAPI["Alpaca API"]:::external
    NewsFeed["News & Sentiment Source"]:::external
    GeminiLLM["Gemini LLM Service"]:::external

    %% Main Process
    Process1["1.0 Generate Trading Recommendation"]:::process

    %% Data Stores
    D1["D1: Raw Market Data Cache"]:::datastore
    D2["D2: Agent Scores"]:::datastore
    D3["D3: State Graph / Session State"]:::datastore

    %% Data Flows
    Trader -->|F1: Ticker & Date Range| Process1
    Process1 -->|F2: Data Request| YahooAPI
    Process1 -->|F2: Data Request| AlpacaAPI
    YahooAPI -->|F3: Market & News Data| D1
    AlpacaAPI -->|F3: Market & News Data| D1
    NewsFeed -->|F3: Market & News Data| D1
    D1 -->|F4: Raw Data| Process1
    Process1 -->|F5: Agent Results| D2
    D2 -->|F6: Intermediate Scores| Process1
    Process1 -->|F7: Synthesis Prompt| GeminiLLM
    GeminiLLM -->|F8: Recommendation + Rationale| Process1
    Process1 -->|F9: Session Update| D3
    Process1 -->|F10: Dashboard Data| Trader

    %% Click Events
    click D1 "https://github.com/monishkumardvs/aihedgenexus/blob/main/project1/tools/api.py"
    click Process1 "https://github.com/monishkumardvs/aihedgenexus/blob/main/project1/main.py"
    click D3 "https://github.com/monishkumardvs/aihedgenexus/blob/main/project1/utils/state.py"
    click Trader "https://github.com/monishkumardvs/aihedgenexus/blob/main/project1/app.py"
    click GeminiLLM "https://github.com/monishkumardvs/aihedgenexus/blob/main/project1/llm/gpt.py"

    %% Styles
    classDef external fill:#cce5ff,stroke:#004085,color:#004085
    classDef datastore fill:#d4edda,stroke:#155724,color:#155724
    classDef process fill:#fff3cd,stroke:#856404,color:#856404
```
