# tirupathic/stock-analysis architecture

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

- Interactive diagram: https://gitdiagram.com/tirupathic/stock-analysis
- Repository: https://github.com/tirupathic/stock-analysis

## Overview

This repository is a financial-markets analysis web app plus scripts for maintaining its market-data and heatmap assets. A user browses index/period heatmaps or uses comparison, news, and calendar views; the app serves pre-generated images rather than generating them. The data workflow maintains index constituents, downloads normalized OHLCV data, and renders heatmaps for later browsing. The README also documents static HTML generation. app.py is only partially excerpted, so feature routing and internal calls beyond the visible evidence are represented conservatively.

Main entry points: [`app.py`](https://github.com/tirupathic/stock-analysis/blob/main/app.py) (Flask app), [`scripts/download_by_index.py`](https://github.com/tirupathic/stock-analysis/blob/main/scripts/download_by_index.py) (Index downloader), [`scripts/data_sources/yahoo_finance.py`](https://github.com/tirupathic/stock-analysis/blob/main/scripts/data_sources/yahoo_finance.py) (Yahoo adapter), [`scripts/data_sources/__init__.py`](https://github.com/tirupathic/stock-analysis/blob/main/scripts/data_sources/__init__.py) (Source registry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_web["Web experience"]
  node_webapp["Flask app<br/>[app.py]"]
  node_heatmap_views["Heatmap views<br/>[app.py]"]
  node_static_site["Static site generator"]
end

subgraph group_analysis["Market analysis"]
  node_compare["Symbol compare<br/>[app.py]"]
  node_news_calendar["News and calendar<br/>[app.py]"]
  node_charts["Price charts<br/>[app.py]"]
  node_strategy_backtest["Strategy backtest<br/>[app.py]"]
  node_institutions["Institution activity<br/>[app.py]"]
  node_heatmap_generator["Heatmap generator<br/>[returns_heatmap.py]"]
end

subgraph group_ingest["Data acquisition"]
  node_symbol_refresh["Symbol refresh<br/>[update_symbols.py]"]
  node_index_download["Index downloader"]
  node_single_download["Symbol downloader<br/>[download_data.py]"]
  node_source_registry["Source registry<br/>[__init__.py]"]
  node_source_contract["OHLCV contract<br/>[base.py]"]
  node_yahoo_adapter["Yahoo adapter<br/>[yahoo_finance.py]"]
end

subgraph group_assets["Market assets"]
  node_symbol_lists[("Index symbol lists")]
  node_price_data[("Historical prices")]
  node_heatmap_assets[("Heatmap images")]
end

node_visitor(("Visitor"))
node_yfinance_service["Yahoo Finance"]

node_visitor -->|"requests views"| node_webapp
node_webapp -->|"routes heatmaps"| node_heatmap_views
node_heatmap_views -->|"serves images"| node_heatmap_assets
node_visitor -->|"requests compare"| node_compare
node_visitor -->|"requests feeds"| node_news_calendar
node_webapp -.->|"provides view"| node_compare
node_webapp -.->|"provides views"| node_news_calendar
node_visitor -.->|"requests charts"| node_charts
node_visitor -.->|"requests backtest"| node_strategy_backtest
node_visitor -.->|"requests activity"| node_institutions
node_news_calendar -.->|"fetches market data"| node_yfinance_service
node_symbol_refresh -.->|"fetches constituents"| node_yfinance_service
node_symbol_refresh -->|"writes lists"| node_symbol_lists
node_index_download -->|"reads lists"| node_symbol_lists
node_single_download -->|"selects source"| node_source_registry
node_index_download -->|"selects source"| node_source_registry
node_source_registry -->|"creates adapter"| node_yahoo_adapter
node_yahoo_adapter -->|"implements contract"| node_source_contract
node_yahoo_adapter -->|"downloads prices"| node_yfinance_service
node_index_download -->|"writes CSVs"| node_price_data
node_single_download -->|"writes CSVs"| node_price_data
node_price_data -->|"provides inputs"| node_heatmap_generator
node_heatmap_generator -->|"generates images"| node_heatmap_assets
node_static_site -->|"reads images"| node_heatmap_assets

click node_webapp "https://github.com/tirupathic/stock-analysis/blob/main/app.py"
click node_heatmap_views "https://github.com/tirupathic/stock-analysis/blob/main/app.py"
click node_compare "https://github.com/tirupathic/stock-analysis/blob/main/app.py"
click node_news_calendar "https://github.com/tirupathic/stock-analysis/blob/main/app.py"
click node_charts "https://github.com/tirupathic/stock-analysis/blob/main/app.py"
click node_strategy_backtest "https://github.com/tirupathic/stock-analysis/blob/main/app.py"
click node_institutions "https://github.com/tirupathic/stock-analysis/blob/main/app.py"
click node_symbol_refresh "https://github.com/tirupathic/stock-analysis/blob/main/scripts/update_symbols.py"
click node_symbol_lists "https://github.com/tirupathic/stock-analysis/tree/main/symbols"
click node_index_download "https://github.com/tirupathic/stock-analysis/blob/main/scripts/download_by_index.py"
click node_single_download "https://github.com/tirupathic/stock-analysis/blob/main/scripts/download_data.py"
click node_source_registry "https://github.com/tirupathic/stock-analysis/blob/main/scripts/data_sources/__init__.py"
click node_source_contract "https://github.com/tirupathic/stock-analysis/blob/main/scripts/data_sources/base.py"
click node_yahoo_adapter "https://github.com/tirupathic/stock-analysis/blob/main/scripts/data_sources/yahoo_finance.py"
click node_price_data "https://github.com/tirupathic/stock-analysis/tree/main/data"
click node_heatmap_generator "https://github.com/tirupathic/stock-analysis/blob/main/scripts/returns_heatmap.py"
click node_heatmap_assets "https://github.com/tirupathic/stock-analysis/tree/main/heatmaps"
click node_static_site "https://github.com/tirupathic/stock-analysis/blob/main/scripts/generate_static_web.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_webapp,node_heatmap_views,node_static_site toneBlue
class node_compare,node_news_calendar,node_charts,node_strategy_backtest,node_institutions,node_heatmap_generator toneAmber
class node_symbol_refresh,node_index_download,node_single_download,node_source_registry,node_source_contract,node_yahoo_adapter toneMint
class node_symbol_lists,node_price_data,node_heatmap_assets toneRose
class node_visitor,node_yfinance_service toneIndigo
```

## Components

### Web experience

- [Flask app](https://github.com/tirupathic/stock-analysis/blob/main/app.py): `app.py`
- [Heatmap views](https://github.com/tirupathic/stock-analysis/blob/main/app.py): `app.py`
- [Static site generator](https://github.com/tirupathic/stock-analysis/blob/main/scripts/generate_static_web.py): `scripts/generate_static_web.py`

### Market analysis

- [Symbol compare](https://github.com/tirupathic/stock-analysis/blob/main/app.py): `app.py`
- [News and calendar](https://github.com/tirupathic/stock-analysis/blob/main/app.py): `app.py`
- [Price charts](https://github.com/tirupathic/stock-analysis/blob/main/app.py): `app.py`
- [Strategy backtest](https://github.com/tirupathic/stock-analysis/blob/main/app.py): `app.py`
- [Institution activity](https://github.com/tirupathic/stock-analysis/blob/main/app.py): `app.py`
- [Heatmap generator](https://github.com/tirupathic/stock-analysis/blob/main/scripts/returns_heatmap.py): `scripts/returns_heatmap.py`

### Data acquisition

- [Symbol refresh](https://github.com/tirupathic/stock-analysis/blob/main/scripts/update_symbols.py): `scripts/update_symbols.py`
- [Index downloader](https://github.com/tirupathic/stock-analysis/blob/main/scripts/download_by_index.py): `scripts/download_by_index.py`
- [Symbol downloader](https://github.com/tirupathic/stock-analysis/blob/main/scripts/download_data.py): `scripts/download_data.py`
- [Source registry](https://github.com/tirupathic/stock-analysis/blob/main/scripts/data_sources/__init__.py): `scripts/data_sources/__init__.py`
- [OHLCV contract](https://github.com/tirupathic/stock-analysis/blob/main/scripts/data_sources/base.py): `scripts/data_sources/base.py`
- [Yahoo adapter](https://github.com/tirupathic/stock-analysis/blob/main/scripts/data_sources/yahoo_finance.py): `scripts/data_sources/yahoo_finance.py`

### Market assets

- [Index symbol lists](https://github.com/tirupathic/stock-analysis/tree/main/symbols): `symbols`
- [Historical prices](https://github.com/tirupathic/stock-analysis/tree/main/data): `data`
- [Heatmap images](https://github.com/tirupathic/stock-analysis/tree/main/heatmaps): `heatmaps`

### Other components

- **Visitor**
- **Yahoo Finance**

## Connections

- Visitor → Flask app: requests views (evidence: `README.md`)
- Flask app → Heatmap views: routes heatmaps (evidence: `README.md`)
- Heatmap views → Heatmap images: serves images (evidence: `README.md`)
- Visitor → Symbol compare: requests compare (evidence: `README.md`)
- Visitor → News and calendar: requests feeds (evidence: `README.md`)
- Flask app → Symbol compare: provides view (evidence: `app.py`)
- Flask app → News and calendar: provides views (evidence: `app.py`)
- Visitor → Price charts: requests charts
- Visitor → Strategy backtest: requests backtest
- Visitor → Institution activity: requests activity
- News and calendar → Yahoo Finance: fetches market data
- Symbol refresh → Yahoo Finance: fetches constituents
- Symbol refresh → Index symbol lists: writes lists (evidence: `scripts/update_symbols.py`)
- Index downloader → Index symbol lists: reads lists (evidence: `scripts/download_by_index.py`)
- Symbol downloader → Source registry: selects source (evidence: `scripts/download_data.py`)
- Index downloader → Source registry: selects source (evidence: `scripts/download_by_index.py`)
- Source registry → Yahoo adapter: creates adapter (evidence: `scripts/data_sources/__init__.py`)
- Yahoo adapter → OHLCV contract: implements contract (evidence: `scripts/data_sources/yahoo_finance.py`)
- Yahoo adapter → Yahoo Finance: downloads prices (evidence: `scripts/data_sources/yahoo_finance.py`)
- Index downloader → Historical prices: writes CSVs (evidence: `scripts/download_by_index.py`)
- Symbol downloader → Historical prices: writes CSVs (evidence: `scripts/download_data.py`)
- Historical prices → Heatmap generator: provides inputs (evidence: `README.md`)
- Heatmap generator → Heatmap images: generates images (evidence: `README.md`)
- Static site generator → Heatmap images: reads images (evidence: `scripts/generate_static_web.py`)
