# nileshshah1807-sys/stocks-fairscope architecture

> Architecture diagram of the GitHub repository nileshshah1807-sys/stocks-fairscope, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-27). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/nileshshah1807-sys/stocks-fairscope
- Repository: https://github.com/nileshshah1807-sys/stocks-fairscope

## Overview

FairScope is a desktop stock-valuation research app, with a limited Streamlit version. The main workflow is entering or searching a ticker, retrieving market and company data, evaluating fundamentals, calculating scenario-based fair value, then reviewing and exporting results. Separate product branches cover batch analysis, backtesting, watchlists, corporate monitoring, and diagnostics. The graph follows the README and provided source excerpts/index; links to unsampled modules are included only where documented or indicated by the index, and uncertain runtime links are dashed.

Main entry points: [`app_qt.py`](https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/app_qt.py) (Qt workspace), [`data_provider.py`](https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/data_provider.py) (Market data provider), [`background_processing.py`](https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/background_processing.py) (Background jobs), [`corporate_monitor.py`](https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/corporate_monitor.py) (Corporate monitoring)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["User interfaces"]
  node_desktop["Qt workspace<br/>[app_qt.py]"]
  node_browser["Streamlit view<br/>[streamlit_app.py]"]
  node_search["Ticker search<br/>[stock_search.py]"]
end

subgraph group_analysis["Valuation analysis"]
  node_worker["Background jobs"]
  node_batch["Batch import<br/>[batch_import.py]"]
  node_backtest["Point-in-time backtest<br/>[backtest.py]"]
  node_valuation["Fair-value engine<br/>[valuation.py]"]
  node_fundamentals["Quality analytics<br/>[fundamentals.py]"]
  node_pdf["Valuation PDF<br/>[pdf_report.py]"]
end

subgraph group_data["Market data"]
  node_provider["Market data provider<br/>[data_provider.py]"]
  node_india["India data checks<br/>[india_sources.py]"]
  node_sec["SEC facts<br/>[sec_facts.py]"]
end

subgraph group_operations["Tracking and operations"]
  node_monitor["Corporate monitoring"]
  node_watchlist["Watchlists and alerts<br/>[watchlist_store.py]"]
  node_watchreport["Watchlist report"]
  node_diagnostics["Diagnostics<br/>[diagnostics.py]"]
end

subgraph group_persistence["Local persistence"]
  node_database[("Local database<br/>[local_database.py]")]
  node_secure["Secure storage<br/>[secure_storage.py]"]
  node_cache["TTL cache<br/>[ttl_cache.py]"]
  node_logger["Rotating logs<br/>[logger.py]"]
end

node_analyst(("Analyst"))
node_yahoo["Yahoo Finance"]
node_screener["Screener.in"]
node_exchanges["NSE / BSE sites"]

node_analyst -->|"enters ticker"| node_desktop
node_desktop -->|"searches symbols"| node_search
node_desktop -.->|"starts analysis"| node_worker
node_worker -->|"processes items"| node_batch
node_worker -.->|"retrieves data"| node_provider
node_worker -.->|"calculates value"| node_valuation
node_backtest -->|"loads history"| node_provider
node_backtest -->|"reruns model"| node_valuation
node_valuation -->|"uses analytics"| node_fundamentals
node_provider -->|"fetches data"| node_yahoo
node_provider -->|"checks India data"| node_india
node_provider -->|"uses SEC facts"| node_sec
node_india -->|"verifies metrics"| node_screener
node_india -->|"checks prices"| node_exchanges
node_desktop -.->|"exports report"| node_pdf
node_desktop -.->|"runs backtest"| node_backtest
node_desktop -.->|"manages tracking"| node_watchlist
node_watchlist -.->|"creates report"| node_watchreport
node_desktop -.->|"monitors filings"| node_monitor
node_desktop -.->|"opens diagnostics"| node_diagnostics
node_provider -->|"caches data"| node_database
node_provider -->|"uses cache"| node_cache
node_database -->|"protects files"| node_secure
node_diagnostics -->|"uses secure storage"| node_secure
node_monitor -->|"reads filings"| node_sec
node_monitor -->|"checks India sources"| node_india
node_monitor -->|"uses credentials"| node_secure
node_provider -->|"logs events"| node_logger
node_analyst -->|"uses browser view"| node_browser
node_browser -->|"displays results"| node_valuation
node_browser -->|"exports PDF"| node_pdf

click node_desktop "https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/app_qt.py"
click node_browser "https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/web/streamlit_app.py"
click node_search "https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/stock_search.py"
click node_worker "https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/background_processing.py"
click node_batch "https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/batch_import.py"
click node_backtest "https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/backtest.py"
click node_valuation "https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/valuation.py"
click node_fundamentals "https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/fundamentals.py"
click node_pdf "https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/pdf_report.py"
click node_provider "https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/data_provider.py"
click node_india "https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/india_sources.py"
click node_sec "https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/sec_facts.py"
click node_monitor "https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/corporate_monitor.py"
click node_watchlist "https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/watchlist_store.py"
click node_watchreport "https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/watchlist_report.py"
click node_diagnostics "https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/diagnostics.py"
click node_database "https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/local_database.py"
click node_secure "https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/secure_storage.py"
click node_cache "https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/ttl_cache.py"
click node_logger "https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/logger.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_desktop,node_browser,node_search,node_screener toneBlue
class node_worker,node_batch,node_backtest,node_valuation,node_fundamentals,node_pdf toneAmber
class node_provider,node_india,node_sec toneMint
class node_monitor,node_watchlist,node_watchreport,node_diagnostics toneRose
class node_database,node_secure,node_cache,node_logger,node_analyst,node_yahoo,node_exchanges toneIndigo
```

## Components

### User interfaces

- [Qt workspace](https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/app_qt.py): `app_qt.py`
- [Streamlit view](https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/web/streamlit_app.py): `web/streamlit_app.py`
- [Ticker search](https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/stock_search.py): `stock_search.py`

### Valuation analysis

- [Background jobs](https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/background_processing.py): `background_processing.py`
- [Batch import](https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/batch_import.py): `batch_import.py`
- [Point-in-time backtest](https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/backtest.py): `backtest.py`
- [Fair-value engine](https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/valuation.py): `valuation.py`
- [Quality analytics](https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/fundamentals.py): `fundamentals.py`
- [Valuation PDF](https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/pdf_report.py): `pdf_report.py`

### Market data

- [Market data provider](https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/data_provider.py): `data_provider.py`
- [India data checks](https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/india_sources.py): `india_sources.py`
- [SEC facts](https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/sec_facts.py): `sec_facts.py`

### Tracking and operations

- [Corporate monitoring](https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/corporate_monitor.py): `corporate_monitor.py`
- [Watchlists and alerts](https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/watchlist_store.py): `watchlist_store.py`
- [Watchlist report](https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/watchlist_report.py): `watchlist_report.py`
- [Diagnostics](https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/diagnostics.py): `diagnostics.py`

### Local persistence

- [Local database](https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/local_database.py): `local_database.py`
- [Secure storage](https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/secure_storage.py): `secure_storage.py`
- [TTL cache](https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/ttl_cache.py): `ttl_cache.py`
- [Rotating logs](https://github.com/nileshshah1807-sys/stocks-fairscope/blob/main/logger.py): `logger.py`

### Other components

- **Analyst**
- **Yahoo Finance**
- **Screener.in**
- **NSE / BSE sites**

## Connections

- Analyst → Qt workspace: enters ticker (evidence: `README.md`)
- Qt workspace → Ticker search: searches symbols (evidence: `app_qt.py`)
- Qt workspace → Background jobs: starts analysis (evidence: `app_qt.py`)
- Background jobs → Batch import: processes items (evidence: `background_processing.py`)
- Background jobs → Market data provider: retrieves data (evidence: `background_processing.py`)
- Background jobs → Fair-value engine: calculates value (evidence: `background_processing.py`)
- Point-in-time backtest → Market data provider: loads history (evidence: `backtest.py`)
- Point-in-time backtest → Fair-value engine: reruns model (evidence: `backtest.py`)
- Fair-value engine → Quality analytics: uses analytics (evidence: `valuation.py`)
- Market data provider → Yahoo Finance: fetches data (evidence: `README.md`)
- Market data provider → India data checks: checks India data (evidence: `data_provider.py`)
- Market data provider → SEC facts: uses SEC facts (evidence: `data_provider.py`)
- India data checks → Screener.in: verifies metrics (evidence: `README.md`)
- India data checks → NSE / BSE sites: checks prices (evidence: `README.md`)
- Qt workspace → Valuation PDF: exports report (evidence: `app_qt.py`)
- Qt workspace → Point-in-time backtest: runs backtest (evidence: `app_qt.py`)
- Qt workspace → Watchlists and alerts: manages tracking (evidence: `app_qt.py`)
- Watchlists and alerts → Watchlist report: creates report
- Qt workspace → Corporate monitoring: monitors filings (evidence: `app_qt.py`)
- Qt workspace → Diagnostics: opens diagnostics (evidence: `app_qt.py`)
- Market data provider → Local database: caches data (evidence: `data_provider.py`)
- Market data provider → TTL cache: uses cache (evidence: `data_provider.py`)
- Local database → Secure storage: protects files (evidence: `local_database.py`)
- Diagnostics → Secure storage: uses secure storage (evidence: `diagnostics.py`)
- Corporate monitoring → SEC facts: reads filings (evidence: `corporate_monitor.py`)
- Corporate monitoring → India data checks: checks India sources (evidence: `corporate_monitor.py`)
- Corporate monitoring → Secure storage: uses credentials (evidence: `corporate_monitor.py`)
- Market data provider → Rotating logs: logs events (evidence: `data_provider.py`)
- Analyst → Streamlit view: uses browser view (evidence: `README.md`)
- Streamlit view → Fair-value engine: displays results (evidence: `web/streamlit_app.py`)
- Streamlit view → Valuation PDF: exports PDF (evidence: `web/streamlit_app.py`)
