# tharun750/stock_analysis architecture

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

- Interactive diagram: https://gitdiagram.com/tharun750/stock_analysis
- Repository: https://github.com/tharun750/stock_analysis

## Overview

This is an intraday stock-analysis application with a dashboard and API. Users select a stock and request market data or analysis; the central pipeline coordinates market, technical, news, genetic-optimization, prediction, risk, and decision agents, then exposes results for display. Separate capabilities include stock lookup, strategy optimization, historical backtesting, and persisted records. The graph follows documented imports and shown calls; several agent and route internals were not excerpted, so their detailed behavior and any unshown integrations are not inferred.

Main entry points: [`IOC/agentic-stock-ai/backend/services/pipeline_service.py`](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/services/pipeline_service.py) (Analysis Pipeline), [`IOC/agentic-stock-ai/frontend/app.py`](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/frontend/app.py) (Analysis Dashboard), [`IOC/agentic-stock-ai/backend/api/routes.py`](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/api/routes.py) (HTTP API), [`IOC/agentic-stock-ai/backend/database/db_manager.py`](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/database/db_manager.py) (Database Manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User Experience"]
  node_dashboard["Analysis Dashboard<br/>[app.py]"]
  node_charts["Charts<br/>[chart_view.py]"]
  node_agent_ui["Agent Status View<br/>[agent_status.py]"]
  node_ga_ui["Optimization View<br/>[ga_view.py]"]
  node_backtest_ui["Backtest View<br/>[backtest_view.py]"]
end

subgraph group_api["API and Orchestration"]
  node_api_routes["HTTP API<br/>[routes.py]"]
  node_pipeline["Analysis Pipeline"]
  node_settings["Runtime Settings<br/>[settings.py]"]
end

subgraph group_analysis["Analysis Agents"]
  node_market_agent["Market Agent<br/>[market_agent.py]"]
  node_technical_agent["Technical Analysis<br/>[technical_agent.py]"]
  node_news_agent["News Sentiment<br/>[news_agent.py]"]
  node_prediction_agent["AI Prediction"]
  node_feature_engineering["Feature Engineering"]
  node_ml_engine["ML Model Selection<br/>[ml_engine.py]"]
  node_risk_agent["Risk Management<br/>[risk_agent.py]"]
  node_decision_agent["Decision Agent<br/>[decision_agent.py]"]
end

subgraph group_market["Market Data and Storage"]
  node_stock_universe["Stock Universe<br/>[stock_universe.py]"]
  node_provider["Yahoo Finance Provider"]
  node_database_manager["Database Manager<br/>[db_manager.py]"]
  node_db_models[("Stored Records<br/>[models.py]")]
end

subgraph group_strategy["Strategy and Evaluation"]
  node_genetic_agent["Genetic Optimization<br/>[genetic_agent.py]"]
  node_ga_engine["Genetic Algorithm<br/>[ga_engine.py]"]
  node_chromosome["Strategy Parameters<br/>[chromosome.py]"]
  node_fitness["Fitness Evaluation<br/>[fitness.py]"]
  node_backtest["Backtest Engine<br/>[backtest_engine.py]"]
  node_metrics["Performance Metrics<br/>[metrics.py]"]
end

node_user(("Investor"))

node_user -->|"uses"| node_dashboard
node_user -->|"requests"| node_api_routes
node_dashboard -->|"requests analysis"| node_pipeline
node_dashboard -->|"looks up stocks"| node_stock_universe
node_dashboard -->|"runs backtests"| node_backtest
node_dashboard -->|"renders"| node_charts
node_dashboard -->|"renders"| node_agent_ui
node_dashboard -->|"renders"| node_ga_ui
node_dashboard -->|"renders"| node_backtest_ui
node_api_routes -->|"runs analysis"| node_pipeline
node_api_routes -->|"fetches data"| node_provider
node_api_routes -->|"queries stocks"| node_stock_universe
node_api_routes -->|"runs backtest"| node_backtest
node_api_routes -->|"uses parameters"| node_chromosome
node_pipeline -->|"executes"| node_market_agent
node_pipeline -->|"executes"| node_technical_agent
node_pipeline -->|"executes"| node_news_agent
node_pipeline -->|"executes"| node_genetic_agent
node_pipeline -->|"executes"| node_prediction_agent
node_pipeline -->|"executes"| node_risk_agent
node_pipeline -->|"executes"| node_decision_agent
node_pipeline -->|"persists results"| node_database_manager
node_market_agent -->|"requests market data"| node_provider
node_provider -->|"formats ticker"| node_stock_universe
node_stock_universe -->|"queries records"| node_database_manager
node_database_manager -->|"creates and queries"| node_db_models
node_database_manager -->|"reads configuration"| node_settings
node_prediction_agent -->|"predicts with"| node_ml_engine
node_ml_engine -->|"builds features"| node_feature_engineering
node_genetic_agent -->|"optimizes with"| node_ga_engine
node_ga_engine -->|"evolves parameters"| node_chromosome
node_ga_engine -->|"evaluates candidates"| node_fitness
node_backtest -->|"uses parameters"| node_chromosome
node_backtest -->|"calculates metrics"| node_metrics

click node_dashboard "https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/frontend/app.py"
click node_charts "https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/frontend/components/chart_view.py"
click node_agent_ui "https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/frontend/components/agent_status.py"
click node_ga_ui "https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/frontend/components/ga_view.py"
click node_backtest_ui "https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/frontend/components/backtest_view.py"
click node_api_routes "https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/api/routes.py"
click node_pipeline "https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/services/pipeline_service.py"
click node_settings "https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/config/settings.py"
click node_market_agent "https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/agents/market_agent.py"
click node_technical_agent "https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/agents/technical_agent.py"
click node_news_agent "https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/agents/news_agent.py"
click node_prediction_agent "https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/agents/prediction_agent.py"
click node_feature_engineering "https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/models/feature_engineering.py"
click node_ml_engine "https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/models/ml_engine.py"
click node_risk_agent "https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/agents/risk_agent.py"
click node_decision_agent "https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/agents/decision_agent.py"
click node_stock_universe "https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/data/stock_universe.py"
click node_provider "https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/data/yfinance_provider.py"
click node_database_manager "https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/database/db_manager.py"
click node_db_models "https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/database/models.py"
click node_genetic_agent "https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/agents/genetic_agent.py"
click node_ga_engine "https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/genetic/ga_engine.py"
click node_chromosome "https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/genetic/chromosome.py"
click node_fitness "https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/genetic/fitness.py"
click node_backtest "https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/backtesting/backtest_engine.py"
click node_metrics "https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/backtesting/metrics.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_dashboard,node_charts,node_agent_ui,node_ga_ui,node_backtest_ui toneBlue
class node_api_routes,node_pipeline,node_settings toneAmber
class node_market_agent,node_technical_agent,node_news_agent,node_prediction_agent,node_feature_engineering,node_ml_engine,node_risk_agent,node_decision_agent toneMint
class node_stock_universe,node_provider,node_database_manager,node_db_models toneRose
class node_genetic_agent,node_ga_engine,node_chromosome,node_fitness,node_backtest,node_metrics,node_user toneIndigo
```

## Components

### User Experience

- [Analysis Dashboard](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/frontend/app.py): `IOC/agentic-stock-ai/frontend/app.py`
- [Charts](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/frontend/components/chart_view.py): `IOC/agentic-stock-ai/frontend/components/chart_view.py`
- [Agent Status View](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/frontend/components/agent_status.py): `IOC/agentic-stock-ai/frontend/components/agent_status.py`
- [Optimization View](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/frontend/components/ga_view.py): `IOC/agentic-stock-ai/frontend/components/ga_view.py`
- [Backtest View](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/frontend/components/backtest_view.py): `IOC/agentic-stock-ai/frontend/components/backtest_view.py`

### API and Orchestration

- [HTTP API](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/api/routes.py): `IOC/agentic-stock-ai/backend/api/routes.py`
- [Analysis Pipeline](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/services/pipeline_service.py): `IOC/agentic-stock-ai/backend/services/pipeline_service.py`
- [Runtime Settings](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/config/settings.py): `IOC/agentic-stock-ai/config/settings.py`

### Analysis Agents

- [Market Agent](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/agents/market_agent.py): `IOC/agentic-stock-ai/backend/agents/market_agent.py`
- [Technical Analysis](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/agents/technical_agent.py): `IOC/agentic-stock-ai/backend/agents/technical_agent.py`
- [News Sentiment](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/agents/news_agent.py): `IOC/agentic-stock-ai/backend/agents/news_agent.py`
- [AI Prediction](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/agents/prediction_agent.py): `IOC/agentic-stock-ai/backend/agents/prediction_agent.py`
- [Feature Engineering](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/models/feature_engineering.py): `IOC/agentic-stock-ai/backend/models/feature_engineering.py`
- [ML Model Selection](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/models/ml_engine.py): `IOC/agentic-stock-ai/backend/models/ml_engine.py`
- [Risk Management](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/agents/risk_agent.py): `IOC/agentic-stock-ai/backend/agents/risk_agent.py`
- [Decision Agent](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/agents/decision_agent.py): `IOC/agentic-stock-ai/backend/agents/decision_agent.py`

### Market Data and Storage

- [Stock Universe](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/data/stock_universe.py): `IOC/agentic-stock-ai/backend/data/stock_universe.py`
- [Yahoo Finance Provider](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/data/yfinance_provider.py): `IOC/agentic-stock-ai/backend/data/yfinance_provider.py`
- [Database Manager](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/database/db_manager.py): `IOC/agentic-stock-ai/backend/database/db_manager.py`
- [Stored Records](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/database/models.py): `IOC/agentic-stock-ai/backend/database/models.py`

### Strategy and Evaluation

- [Genetic Optimization](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/agents/genetic_agent.py): `IOC/agentic-stock-ai/backend/agents/genetic_agent.py`
- [Genetic Algorithm](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/genetic/ga_engine.py): `IOC/agentic-stock-ai/backend/genetic/ga_engine.py`
- [Strategy Parameters](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/genetic/chromosome.py): `IOC/agentic-stock-ai/backend/genetic/chromosome.py`
- [Fitness Evaluation](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/genetic/fitness.py): `IOC/agentic-stock-ai/backend/genetic/fitness.py`
- [Backtest Engine](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/backtesting/backtest_engine.py): `IOC/agentic-stock-ai/backend/backtesting/backtest_engine.py`
- [Performance Metrics](https://github.com/tharun750/stock_analysis/blob/main/IOC/agentic-stock-ai/backend/backtesting/metrics.py): `IOC/agentic-stock-ai/backend/backtesting/metrics.py`

### Other components

- **Investor**

## Connections

- Investor → Analysis Dashboard: uses (evidence: `IOC/agentic-stock-ai/frontend/app.py`)
- Investor → HTTP API: requests (evidence: `IOC/agentic-stock-ai/backend/api/routes.py`)
- Analysis Dashboard → Analysis Pipeline: requests analysis (evidence: `IOC/agentic-stock-ai/frontend/app.py`)
- Analysis Dashboard → Stock Universe: looks up stocks (evidence: `IOC/agentic-stock-ai/frontend/app.py`)
- Analysis Dashboard → Backtest Engine: runs backtests (evidence: `IOC/agentic-stock-ai/frontend/app.py`)
- Analysis Dashboard → Charts: renders (evidence: `IOC/agentic-stock-ai/frontend/app.py`)
- Analysis Dashboard → Agent Status View: renders (evidence: `IOC/agentic-stock-ai/frontend/app.py`)
- Analysis Dashboard → Optimization View: renders (evidence: `IOC/agentic-stock-ai/frontend/app.py`)
- Analysis Dashboard → Backtest View: renders (evidence: `IOC/agentic-stock-ai/frontend/app.py`)
- HTTP API → Analysis Pipeline: runs analysis (evidence: `IOC/agentic-stock-ai/backend/api/routes.py`)
- HTTP API → Yahoo Finance Provider: fetches data (evidence: `IOC/agentic-stock-ai/backend/api/routes.py`)
- HTTP API → Stock Universe: queries stocks (evidence: `IOC/agentic-stock-ai/backend/api/routes.py`)
- HTTP API → Backtest Engine: runs backtest (evidence: `IOC/agentic-stock-ai/backend/api/routes.py`)
- HTTP API → Strategy Parameters: uses parameters (evidence: `IOC/agentic-stock-ai/backend/api/routes.py`)
- Analysis Pipeline → Market Agent: executes (evidence: `IOC/agentic-stock-ai/backend/services/pipeline_service.py`)
- Analysis Pipeline → Technical Analysis: executes (evidence: `IOC/agentic-stock-ai/backend/services/pipeline_service.py`)
- Analysis Pipeline → News Sentiment: executes (evidence: `IOC/agentic-stock-ai/backend/services/pipeline_service.py`)
- Analysis Pipeline → Genetic Optimization: executes (evidence: `IOC/agentic-stock-ai/backend/services/pipeline_service.py`)
- Analysis Pipeline → AI Prediction: executes (evidence: `IOC/agentic-stock-ai/backend/services/pipeline_service.py`)
- Analysis Pipeline → Risk Management: executes (evidence: `IOC/agentic-stock-ai/backend/services/pipeline_service.py`)
- Analysis Pipeline → Decision Agent: executes (evidence: `IOC/agentic-stock-ai/backend/services/pipeline_service.py`)
- Analysis Pipeline → Database Manager: persists results (evidence: `IOC/agentic-stock-ai/backend/services/pipeline_service.py`)
- Market Agent → Yahoo Finance Provider: requests market data (evidence: `IOC/agentic-stock-ai/backend/agents/market_agent.py`)
- Yahoo Finance Provider → Stock Universe: formats ticker (evidence: `IOC/agentic-stock-ai/backend/data/yfinance_provider.py`)
- Stock Universe → Database Manager: queries records (evidence: `IOC/agentic-stock-ai/backend/data/stock_universe.py`)
- Database Manager → Stored Records: creates and queries (evidence: `IOC/agentic-stock-ai/backend/database/db_manager.py`)
- Database Manager → Runtime Settings: reads configuration (evidence: `IOC/agentic-stock-ai/backend/database/db_manager.py`)
- AI Prediction → ML Model Selection: predicts with (evidence: `IOC/agentic-stock-ai/backend/agents/prediction_agent.py`)
- ML Model Selection → Feature Engineering: builds features (evidence: `IOC/agentic-stock-ai/backend/models/ml_engine.py`)
- Genetic Optimization → Genetic Algorithm: optimizes with (evidence: `IOC/agentic-stock-ai/backend/agents/genetic_agent.py`)
- Genetic Algorithm → Strategy Parameters: evolves parameters (evidence: `IOC/agentic-stock-ai/backend/genetic/ga_engine.py`)
- Genetic Algorithm → Fitness Evaluation: evaluates candidates (evidence: `IOC/agentic-stock-ai/backend/genetic/ga_engine.py`)
- Backtest Engine → Strategy Parameters: uses parameters (evidence: `IOC/agentic-stock-ai/backend/backtesting/backtest_engine.py`)
- Backtest Engine → Performance Metrics: calculates metrics (evidence: `IOC/agentic-stock-ai/backend/backtesting/backtest_engine.py`)
