# ezcanor1/stock-price-agent architecture

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

- Interactive diagram: https://gitdiagram.com/ezcanor1/stock-price-agent
- Repository: https://github.com/ezcanor1/stock-price-agent

## Overview

##### Project Type and Purpose
- It’s essentially a tool/agent that aggregates external data (from yFinance) and presents it using both a web interface (Streamlit) and a programmatic API (Flask).

##### File Structure
- Top-level files include:
- README.md (describing the project details and usage),
- requirements.txt (listing dependencies like LangChain, yFinance, Streamlit, Flask),
- stocks.py (presumably the main application that contains both UI and API code, integration with LangChain agent, and logic for stock price fetching and conversion),
- test.py (unit tests or integration tests).

##### Main Components & Their Relationships
- Core Components:
A. Stock Price Fetcher Tool:
- Uses yFinance to collect real-time stock data.
B. LangChain-based LlamaCPP Agent:
- Acts as the orchestrator, integrating the stock price tool and possibly further processing (e.g., conversion and visualization prep).
C. Data Processing:
- Handles the USD to INR conversion and the aggregation of data for the 7-day trend.
D. Visualization Component:
- Generates the 7-day trend graph (likely encapsulated in the code, possibly with libraries such as matplotlib, plotly, or Streamlit’s native plotting).
E. User Interfaces:
- Streamlit-based UI that displays the stock info and trend.
- Flask API endpoint to allow external systems to access the tool’s functionality.
F. Test Suite:
- Represented by test.py which tests the functionality of the above components.

##### Architectural Patterns & Design Principles
- Separation of concerns: The code likely distinguishes between core business logic (agent, stock fetching, conversions) and presentation layer (Streamlit UI and Flask API).
- Integration with external services: yFinance for live data, and possibly an external conversion service if needed.
- The design can be seen as a mini service that responds to both interactive (UI) and programmatic (API) clients.

## Diagram (Mermaid)

```mermaid
graph TD
    SDF["Stock Data Fetcher (yFinance)"]:::external --> L["LangChain LlamaCPP Agent Integration"]:::core

    subgraph "Application Core (stocks.py)"
        direction TB
        L
        DC["Data Conversion & Processing Module"]:::core
        VG["Visualization Generator (7-day trend graph)"]:::core
        UI["Streamlit-based UI Component"]:::ui
        API["Flask API Endpoint Component"]:::api

        L --> DC
        DC --> VG
        VG --> UI
        VG --> API
    end

    T["Test Suite for Functionality"]:::test --- L

    click SDF "https://github.com/ezcanor1/stock-price-agent/blob/master/stocks.py"
    click L "https://github.com/ezcanor1/stock-price-agent/blob/master/stocks.py"
    click DC "https://github.com/ezcanor1/stock-price-agent/blob/master/stocks.py"
    click VG "https://github.com/ezcanor1/stock-price-agent/blob/master/stocks.py"
    click UI "https://github.com/ezcanor1/stock-price-agent/blob/master/stocks.py"
    click API "https://github.com/ezcanor1/stock-price-agent/blob/master/stocks.py"
    click T "https://github.com/ezcanor1/stock-price-agent/blob/master/test.py"

    classDef external fill:#ADD8E6,stroke:#000,stroke-width:2px;
    classDef core fill:#FFFACD,stroke:#000,stroke-width:2px;
    classDef ui fill:#98FB98,stroke:#000,stroke-width:2px;
    classDef api fill:#FFA07A,stroke:#000,stroke-width:2px;
    classDef test fill:#D3D3D3,stroke:#000,stroke-width:2px;
```
