# noczero/idx-fundamental-analysis architecture

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

- Interactive diagram: https://gitdiagram.com/noczero/idx-fundamental-analysis
- Repository: https://github.com/noczero/idx-fundamental-analysis

## Overview

IDX Fundamental Analysis is a stock-data retrieval and analysis application. Its principal workflow is a CLI run: obtain listed stocks from IDX, enrich them with Stockbit statistics, prices and stream sentiment, generate spreadsheet or Excel output, and persist the results in SQLite. The repository also contains API and Svelte UI subsystems; their detailed request flow is not established by the sampled source. Google Sheets and Stockbit token refresh are separate integrations. Dashed, uncited links mark relationships not verified in the excerpts.

Main entry points: [`builders/analysers/__init__.py`](https://github.com/noczero/idx-fundamental-analysis/blob/master/builders/analysers/__init__.py) (Analysis coordinator), [`main.py`](https://github.com/noczero/idx-fundamental-analysis/blob/master/main.py) (Analysis runner), [`builders/database_builder.py`](https://github.com/noczero/idx-fundamental-analysis/blob/master/builders/database_builder.py) (Database writer), [`services/stockbit_api_client.py`](https://github.com/noczero/idx-fundamental-analysis/blob/master/services/stockbit_api_client.py) (Stockbit API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Retrieval and analysis"]
  node_runner["Analysis runner<br/>[main.py]"]
  node_analyser["Analysis coordinator<br/>[__init__.py]"]
  node_fundamentals["Fundamental analysis"]
  node_key_analysis["Key analysis"]
  node_price_analysis["Price analysis"]
  node_sentiment_analysis["Sentiment analysis"]
end

subgraph group_output["Reporting and storage"]
  node_spreadsheet["Google Sheets output<br/>[spreadsheet.py]"]
  node_excel["Excel output<br/>[excel.py]"]
  node_db_builder["Database writer"]
  node_session[("SQLite sessions<br/>[session.py]")]
  node_repositories["Data repositories"]
end

subgraph group_integrations["External integrations"]
  node_idx["IDX stock retrieval<br/>[idx.py]"]
  node_stockbit["Stockbit enrichment<br/>[stockbit.py]"]
  node_stockbit_client["Stockbit API client"]
  node_token_fetcher["Browser token capture"]
  node_yfinance["YFinance provider<br/>[yfinance.py]"]
  node_webcrawler["IDX web crawler<br/>[webcrawler.py]"]
  node_drive["Google Drive service"]
  node_google_sheets["Google Sheets"]
  node_stockbit_service["Stockbit service"]
end

subgraph group_api["API and UI"]
  node_api["HTTP API"]
  node_api_registry["API registration<br/>[registrar.py]"]
  node_ui["Svelte interface<br/>[+page.svelte]"]
end

subgraph group_domain["Data model"]
  node_schemas["Stock data schemas<br/>[stock.py]"]
  node_fundamental_schema["Fundamental schema<br/>[fundamental.py]"]
  node_fundamental_models[("Fundamental records<br/>[fundamental.py]")]
end

node_operator(("CLI operator"))

node_operator -->|"starts run"| node_runner
node_runner -->|"retrieves stocks"| node_idx
node_runner -->|"enriches stocks"| node_stockbit
node_runner -->|"builds output"| node_analyser
node_runner -->|"persists results"| node_db_builder
node_stockbit -->|"sends requests"| node_stockbit_client
node_stockbit_client -->|"captures tokens"| node_token_fetcher
node_stockbit_client -.->|"calls API"| node_stockbit_service
node_analyser -->|"uses analyser"| node_fundamentals
node_analyser -->|"uses analyser"| node_key_analysis
node_analyser -->|"uses analyser"| node_price_analysis
node_analyser -->|"uses analyser"| node_sentiment_analysis
node_analyser -.->|"selects output"| node_spreadsheet
node_analyser -.->|"selects output"| node_excel
node_spreadsheet -->|"writes sheets"| node_drive
node_drive -->|"updates spreadsheets"| node_google_sheets
node_db_builder -->|"opens sessions"| node_session
node_db_builder -->|"creates records"| node_fundamental_models
node_db_builder -->|"reads stock data"| node_schemas
node_repositories -.->|"uses database"| node_session
node_schemas -->|"embeds schema"| node_fundamental_schema
node_api_registry -->|"registers routers"| node_api
node_ui -.->|"requests data"| node_api

click node_runner "https://github.com/noczero/idx-fundamental-analysis/blob/master/main.py"
click node_idx "https://github.com/noczero/idx-fundamental-analysis/blob/master/providers/idx.py"
click node_stockbit "https://github.com/noczero/idx-fundamental-analysis/blob/master/providers/stockbit.py"
click node_stockbit_client "https://github.com/noczero/idx-fundamental-analysis/blob/master/services/stockbit_api_client.py"
click node_token_fetcher "https://github.com/noczero/idx-fundamental-analysis/blob/master/services/stockbit_token_fetcher.py"
click node_yfinance "https://github.com/noczero/idx-fundamental-analysis/blob/master/providers/yfinance.py"
click node_webcrawler "https://github.com/noczero/idx-fundamental-analysis/blob/master/providers/webcrawler.py"
click node_analyser "https://github.com/noczero/idx-fundamental-analysis/blob/master/builders/analysers/__init__.py"
click node_fundamentals "https://github.com/noczero/idx-fundamental-analysis/blob/master/builders/analysers/fundamental_analyser.py"
click node_key_analysis "https://github.com/noczero/idx-fundamental-analysis/blob/master/builders/analysers/key_analysis_analyser.py"
click node_price_analysis "https://github.com/noczero/idx-fundamental-analysis/blob/master/builders/analysers/stock_price_analyser.py"
click node_sentiment_analysis "https://github.com/noczero/idx-fundamental-analysis/blob/master/builders/analysers/sentiment_analyser.py"
click node_spreadsheet "https://github.com/noczero/idx-fundamental-analysis/blob/master/builders/spreadsheet.py"
click node_excel "https://github.com/noczero/idx-fundamental-analysis/blob/master/builders/excel.py"
click node_drive "https://github.com/noczero/idx-fundamental-analysis/blob/master/services/google_drive_service.py"
click node_db_builder "https://github.com/noczero/idx-fundamental-analysis/blob/master/builders/database_builder.py"
click node_session "https://github.com/noczero/idx-fundamental-analysis/blob/master/db/session.py"
click node_repositories "https://github.com/noczero/idx-fundamental-analysis/tree/master/repositories"
click node_schemas "https://github.com/noczero/idx-fundamental-analysis/blob/master/schemas/stock.py"
click node_fundamental_schema "https://github.com/noczero/idx-fundamental-analysis/blob/master/schemas/fundamental.py"
click node_fundamental_models "https://github.com/noczero/idx-fundamental-analysis/blob/master/db/models/fundamental.py"
click node_api "https://github.com/noczero/idx-fundamental-analysis/tree/master/app/api"
click node_api_registry "https://github.com/noczero/idx-fundamental-analysis/blob/master/core/registrar.py"
click node_ui "https://github.com/noczero/idx-fundamental-analysis/blob/master/app/ui/src/routes/%2Bpage.svelte"

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_runner,node_analyser,node_fundamentals,node_key_analysis,node_price_analysis,node_sentiment_analysis toneBlue
class node_spreadsheet,node_excel,node_db_builder,node_session,node_repositories toneAmber
class node_idx,node_stockbit,node_stockbit_client,node_token_fetcher,node_yfinance,node_webcrawler,node_drive,node_google_sheets,node_stockbit_service toneMint
class node_api,node_api_registry,node_ui toneRose
class node_schemas,node_fundamental_schema,node_fundamental_models,node_operator toneIndigo
```

## Components

### Retrieval and analysis

- [Analysis runner](https://github.com/noczero/idx-fundamental-analysis/blob/master/main.py): `main.py`
- [Analysis coordinator](https://github.com/noczero/idx-fundamental-analysis/blob/master/builders/analysers/__init__.py): `builders/analysers/__init__.py`
- [Fundamental analysis](https://github.com/noczero/idx-fundamental-analysis/blob/master/builders/analysers/fundamental_analyser.py): `builders/analysers/fundamental_analyser.py`
- [Key analysis](https://github.com/noczero/idx-fundamental-analysis/blob/master/builders/analysers/key_analysis_analyser.py): `builders/analysers/key_analysis_analyser.py`
- [Price analysis](https://github.com/noczero/idx-fundamental-analysis/blob/master/builders/analysers/stock_price_analyser.py): `builders/analysers/stock_price_analyser.py`
- [Sentiment analysis](https://github.com/noczero/idx-fundamental-analysis/blob/master/builders/analysers/sentiment_analyser.py): `builders/analysers/sentiment_analyser.py`

### Reporting and storage

- [Google Sheets output](https://github.com/noczero/idx-fundamental-analysis/blob/master/builders/spreadsheet.py): `builders/spreadsheet.py`
- [Excel output](https://github.com/noczero/idx-fundamental-analysis/blob/master/builders/excel.py): `builders/excel.py`
- [Database writer](https://github.com/noczero/idx-fundamental-analysis/blob/master/builders/database_builder.py): `builders/database_builder.py`
- [SQLite sessions](https://github.com/noczero/idx-fundamental-analysis/blob/master/db/session.py): `db/session.py`
- [Data repositories](https://github.com/noczero/idx-fundamental-analysis/tree/master/repositories): `repositories`

### External integrations

- [IDX stock retrieval](https://github.com/noczero/idx-fundamental-analysis/blob/master/providers/idx.py): `providers/idx.py`
- [Stockbit enrichment](https://github.com/noczero/idx-fundamental-analysis/blob/master/providers/stockbit.py): `providers/stockbit.py`
- [Stockbit API client](https://github.com/noczero/idx-fundamental-analysis/blob/master/services/stockbit_api_client.py): `services/stockbit_api_client.py`
- [Browser token capture](https://github.com/noczero/idx-fundamental-analysis/blob/master/services/stockbit_token_fetcher.py): `services/stockbit_token_fetcher.py`
- [YFinance provider](https://github.com/noczero/idx-fundamental-analysis/blob/master/providers/yfinance.py): `providers/yfinance.py`
- [IDX web crawler](https://github.com/noczero/idx-fundamental-analysis/blob/master/providers/webcrawler.py): `providers/webcrawler.py`
- [Google Drive service](https://github.com/noczero/idx-fundamental-analysis/blob/master/services/google_drive_service.py): `services/google_drive_service.py`
- **Google Sheets**
- **Stockbit service**

### API and UI

- [HTTP API](https://github.com/noczero/idx-fundamental-analysis/tree/master/app/api): `app/api`
- [API registration](https://github.com/noczero/idx-fundamental-analysis/blob/master/core/registrar.py): `core/registrar.py`
- [Svelte interface](https://github.com/noczero/idx-fundamental-analysis/blob/master/app/ui/src/routes/%2Bpage.svelte): `app/ui/src/routes/+page.svelte`

### Data model

- [Stock data schemas](https://github.com/noczero/idx-fundamental-analysis/blob/master/schemas/stock.py): `schemas/stock.py`
- [Fundamental schema](https://github.com/noczero/idx-fundamental-analysis/blob/master/schemas/fundamental.py): `schemas/fundamental.py`
- [Fundamental records](https://github.com/noczero/idx-fundamental-analysis/blob/master/db/models/fundamental.py): `db/models/fundamental.py`

### Other components

- **CLI operator**

## Connections

- CLI operator → Analysis runner: starts run (evidence: `main.py`)
- Analysis runner → IDX stock retrieval: retrieves stocks (evidence: `main.py`)
- Analysis runner → Stockbit enrichment: enriches stocks (evidence: `main.py`)
- Analysis runner → Analysis coordinator: builds output (evidence: `main.py`)
- Analysis runner → Database writer: persists results (evidence: `main.py`)
- Stockbit enrichment → Stockbit API client: sends requests (evidence: `providers/stockbit.py`)
- Stockbit API client → Browser token capture: captures tokens (evidence: `services/stockbit_api_client.py`)
- Stockbit API client → Stockbit service: calls API
- Analysis coordinator → Fundamental analysis: uses analyser (evidence: `builders/analysers/__init__.py`)
- Analysis coordinator → Key analysis: uses analyser (evidence: `builders/analysers/__init__.py`)
- Analysis coordinator → Price analysis: uses analyser (evidence: `builders/analysers/__init__.py`)
- Analysis coordinator → Sentiment analysis: uses analyser (evidence: `builders/analysers/__init__.py`)
- Analysis coordinator → Google Sheets output: selects output (evidence: `builders/analysers/__init__.py`)
- Analysis coordinator → Excel output: selects output (evidence: `builders/analysers/__init__.py`)
- Google Sheets output → Google Drive service: writes sheets (evidence: `builders/spreadsheet.py`)
- Google Drive service → Google Sheets: updates spreadsheets (evidence: `services/google_drive_service.py`)
- Database writer → SQLite sessions: opens sessions (evidence: `builders/database_builder.py`)
- Database writer → Fundamental records: creates records (evidence: `builders/database_builder.py`)
- Database writer → Stock data schemas: reads stock data (evidence: `builders/database_builder.py`)
- Data repositories → SQLite sessions: uses database
- Stock data schemas → Fundamental schema: embeds schema (evidence: `schemas/stock.py`)
- API registration → HTTP API: registers routers (evidence: `core/registrar.py`)
- Svelte interface → HTTP API: requests data
