# bbalabuya/stockmarket architecture

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

- Interactive diagram: https://gitdiagram.com/bbalabuya/stockmarket
- Repository: https://github.com/bbalabuya/stockmarket

## Overview

This is a stock-market information app: users view market indices, search for a company, then inspect its stock details, historical data and live price/order book. The React client combines REST data with a WebSocket feed; FastAPI registers separate routes for stock search, market indices, stock metrics, time-based data and live feeds. The sampled code shows the combined live-feed relay and KIS authentication. Some route implementations and the REST hook were not excerpted, so their internal calls and external data sources are not asserted.

Main entry points: [`client/src/pages/company/companyMain.js`](https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/company/companyMain.js) (Stock page), [`server/main.py`](https://github.com/bbalabuya/stockmarket/blob/main/server/main.py) (FastAPI app), [`server/auth.py`](https://github.com/bbalabuya/stockmarket/blob/main/server/auth.py) (Token and approval), [`client/src/pages/landing.js`](https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/landing.js) (Landing page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["React client"]
  node_app["App router<br/>[App.js]"]
  node_landing["Landing page<br/>[landing.js]"]
  node_findclient["Code lookup client<br/>[findStockCode.js]"]
  node_resthook["Historical REST hook<br/>[RestCall.js]"]
  node_marketutils["Market utilities<br/>[marketUtils.js]"]
  node_indices["Index display<br/>[call_index.js]"]
end

subgraph group_views["Stock views"]
  node_company["Stock page<br/>[companyMain.js]"]
  node_searchbar["Stock search<br/>[SearchBar.js]"]
  node_header["Quote header<br/>[StockHeader.js]"]
  node_chart["Price chart<br/>[ChartArea.js]"]
  node_datasection["Stock metrics<br/>[DataSection.js]"]
  node_datatable["Trade table<br/>[dataTable.js]"]
  node_offer["Order book<br/>[Offer.js]"]
end

subgraph group_api["FastAPI routes"]
  node_server["FastAPI app<br/>[main.py]"]
  node_searchapi["Stock code search<br/>[findStockCode.py]"]
  node_indexapi["Korea index API<br/>[index.py]"]
  node_naverindex["Naver index API<br/>[index_naver.py]"]
  node_historyapi["Time data API<br/>[time_conclusion.py]"]
  node_metricsapi["PER/PBR API<br/>[per_pbr.py]"]
end

subgraph group_live["Live feeds"]
  node_wshook["Live data hook<br/>[WSCall.js]"]
  node_pricews["Price WebSocket<br/>[ws_price.py]"]
  node_offerws["Offer WebSocket<br/>[ws_offer.py]"]
  node_allws["Combined live relay<br/>[ws_all.py]"]
end

subgraph group_auth["KIS authentication"]
  node_auth["Token and approval<br/>[auth.py]"]
end

node_user(("Investor"))
node_kis{{"KIS services"}}

node_user -->|"opens"| node_app
node_app -->|"routes to"| node_landing
node_app -->|"routes to"| node_company
node_landing -->|"submits search"| node_findclient
node_landing -->|"renders"| node_indices
node_landing -->|"fetches index"| node_indexapi
node_company -->|"renders"| node_searchbar
node_company -->|"looks up code"| node_findclient
node_company -->|"loads history"| node_resthook
node_company -->|"loads live data"| node_wshook
node_company -->|"renders"| node_header
node_company -->|"renders"| node_chart
node_company -->|"renders"| node_datasection
node_company -->|"renders"| node_datatable
node_company -->|"renders"| node_offer
node_company -->|"renders"| node_indices
node_resthook -->|"imports"| node_marketutils
node_wshook -->|"imports"| node_marketutils
node_wshook -->|"opens WebSocket"| node_allws
node_indices -->|"requests indices"| node_naverindex
node_findclient -.->|"requests code"| node_searchapi
node_server -->|"registers route"| node_historyapi
node_server -->|"registers route"| node_metricsapi
node_server -->|"registers route"| node_indexapi
node_server -->|"registers route"| node_naverindex
node_server -->|"registers route"| node_searchapi
node_server -->|"registers route"| node_pricews
node_server -->|"registers route"| node_offerws
node_server -->|"registers route"| node_allws
node_indexapi -->|"gets token"| node_auth
node_historyapi -->|"uses auth"| node_auth
node_metricsapi -->|"uses auth"| node_auth
node_pricews -->|"uses auth"| node_auth
node_offerws -->|"uses auth"| node_auth
node_allws -->|"issues approval"| node_auth
node_auth -->|"requests credentials"| node_kis
node_indexapi -->|"requests index data"| node_kis
node_allws -->|"relays live feed"| node_kis

click node_app "https://github.com/bbalabuya/stockmarket/blob/main/client/src/App.js"
click node_landing "https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/landing.js"
click node_company "https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/company/companyMain.js"
click node_searchbar "https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/company/SearchBar.js"
click node_findclient "https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/findStockCode.js"
click node_resthook "https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/RestCall.js"
click node_wshook "https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/WSCall.js"
click node_marketutils "https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/marketUtils.js"
click node_header "https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/company/StockHeader.js"
click node_chart "https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/company/ChartArea.js"
click node_datasection "https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/company/DataSection.js"
click node_datatable "https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/company/dataTable.js"
click node_offer "https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/company/Offer.js"
click node_indices "https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/call_index.js"
click node_server "https://github.com/bbalabuya/stockmarket/blob/main/server/main.py"
click node_searchapi "https://github.com/bbalabuya/stockmarket/blob/main/server/findStockCode.py"
click node_indexapi "https://github.com/bbalabuya/stockmarket/blob/main/server/index.py"
click node_naverindex "https://github.com/bbalabuya/stockmarket/blob/main/server/index_naver.py"
click node_historyapi "https://github.com/bbalabuya/stockmarket/blob/main/server/time_conclusion.py"
click node_metricsapi "https://github.com/bbalabuya/stockmarket/blob/main/server/per_pbr.py"
click node_pricews "https://github.com/bbalabuya/stockmarket/blob/main/server/ws_price.py"
click node_offerws "https://github.com/bbalabuya/stockmarket/blob/main/server/ws_offer.py"
click node_allws "https://github.com/bbalabuya/stockmarket/blob/main/server/ws_all.py"
click node_auth "https://github.com/bbalabuya/stockmarket/blob/main/server/auth.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_app,node_landing,node_findclient,node_resthook,node_marketutils,node_indices toneBlue
class node_company,node_searchbar,node_header,node_chart,node_datasection,node_datatable,node_offer toneAmber
class node_server,node_searchapi,node_indexapi,node_naverindex,node_historyapi,node_metricsapi toneMint
class node_wshook,node_pricews,node_offerws,node_allws toneRose
class node_auth,node_user,node_kis toneIndigo
```

## Components

### React client

- [App router](https://github.com/bbalabuya/stockmarket/blob/main/client/src/App.js): `client/src/App.js`
- [Landing page](https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/landing.js): `client/src/pages/landing.js`
- [Code lookup client](https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/findStockCode.js): `client/src/pages/findStockCode.js`
- [Historical REST hook](https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/RestCall.js): `client/src/pages/RestCall.js`
- [Market utilities](https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/marketUtils.js): `client/src/pages/marketUtils.js`
- [Index display](https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/call_index.js): `client/src/pages/call_index.js`

### Stock views

- [Stock page](https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/company/companyMain.js): `client/src/pages/company/companyMain.js`
- [Stock search](https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/company/SearchBar.js): `client/src/pages/company/SearchBar.js`
- [Quote header](https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/company/StockHeader.js): `client/src/pages/company/StockHeader.js`
- [Price chart](https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/company/ChartArea.js): `client/src/pages/company/ChartArea.js`
- [Stock metrics](https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/company/DataSection.js): `client/src/pages/company/DataSection.js`
- [Trade table](https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/company/dataTable.js): `client/src/pages/company/dataTable.js`
- [Order book](https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/company/Offer.js): `client/src/pages/company/Offer.js`

### FastAPI routes

- [FastAPI app](https://github.com/bbalabuya/stockmarket/blob/main/server/main.py): `server/main.py`
- [Stock code search](https://github.com/bbalabuya/stockmarket/blob/main/server/findStockCode.py): `server/findStockCode.py`
- [Korea index API](https://github.com/bbalabuya/stockmarket/blob/main/server/index.py): `server/index.py`
- [Naver index API](https://github.com/bbalabuya/stockmarket/blob/main/server/index_naver.py): `server/index_naver.py`
- [Time data API](https://github.com/bbalabuya/stockmarket/blob/main/server/time_conclusion.py): `server/time_conclusion.py`
- [PER/PBR API](https://github.com/bbalabuya/stockmarket/blob/main/server/per_pbr.py): `server/per_pbr.py`

### Live feeds

- [Live data hook](https://github.com/bbalabuya/stockmarket/blob/main/client/src/pages/WSCall.js): `client/src/pages/WSCall.js`
- [Price WebSocket](https://github.com/bbalabuya/stockmarket/blob/main/server/ws_price.py): `server/ws_price.py`
- [Offer WebSocket](https://github.com/bbalabuya/stockmarket/blob/main/server/ws_offer.py): `server/ws_offer.py`
- [Combined live relay](https://github.com/bbalabuya/stockmarket/blob/main/server/ws_all.py): `server/ws_all.py`

### KIS authentication

- [Token and approval](https://github.com/bbalabuya/stockmarket/blob/main/server/auth.py): `server/auth.py`

### Other components

- **Investor**
- **KIS services**

## Connections

- Investor → App router: opens
- App router → Landing page: routes to (evidence: `client/src/App.js`)
- App router → Stock page: routes to (evidence: `client/src/App.js`)
- Landing page → Code lookup client: submits search (evidence: `client/src/pages/landing.js`)
- Landing page → Index display: renders (evidence: `client/src/pages/landing.js`)
- Landing page → Korea index API: fetches index (evidence: `client/src/pages/landing.js`)
- Stock page → Stock search: renders (evidence: `client/src/pages/company/companyMain.js`)
- Stock page → Code lookup client: looks up code (evidence: `client/src/pages/company/companyMain.js`)
- Stock page → Historical REST hook: loads history (evidence: `client/src/pages/company/companyMain.js`)
- Stock page → Live data hook: loads live data (evidence: `client/src/pages/company/companyMain.js`)
- Stock page → Quote header: renders (evidence: `client/src/pages/company/companyMain.js`)
- Stock page → Price chart: renders (evidence: `client/src/pages/company/companyMain.js`)
- Stock page → Stock metrics: renders (evidence: `client/src/pages/company/companyMain.js`)
- Stock page → Trade table: renders (evidence: `client/src/pages/company/companyMain.js`)
- Stock page → Order book: renders (evidence: `client/src/pages/company/companyMain.js`)
- Stock page → Index display: renders (evidence: `client/src/pages/company/companyMain.js`)
- Historical REST hook → Market utilities: imports (evidence: `client/src/pages/RestCall.js`)
- Live data hook → Market utilities: imports (evidence: `client/src/pages/WSCall.js`)
- Live data hook → Combined live relay: opens WebSocket (evidence: `client/src/pages/WSCall.js`)
- Index display → Naver index API: requests indices (evidence: `client/src/pages/call_index.js`)
- Code lookup client → Stock code search: requests code
- FastAPI app → Time data API: registers route (evidence: `server/main.py`)
- FastAPI app → PER/PBR API: registers route (evidence: `server/main.py`)
- FastAPI app → Korea index API: registers route (evidence: `server/main.py`)
- FastAPI app → Naver index API: registers route (evidence: `server/main.py`)
- FastAPI app → Stock code search: registers route (evidence: `server/main.py`)
- FastAPI app → Price WebSocket: registers route (evidence: `server/main.py`)
- FastAPI app → Offer WebSocket: registers route (evidence: `server/main.py`)
- FastAPI app → Combined live relay: registers route (evidence: `server/main.py`)
- Korea index API → Token and approval: gets token (evidence: `server/index.py`)
- Time data API → Token and approval: uses auth (evidence: `server/time_conclusion.py`)
- PER/PBR API → Token and approval: uses auth (evidence: `server/per_pbr.py`)
- Price WebSocket → Token and approval: uses auth (evidence: `server/ws_price.py`)
- Offer WebSocket → Token and approval: uses auth (evidence: `server/ws_offer.py`)
- Combined live relay → Token and approval: issues approval (evidence: `server/ws_all.py`)
- Token and approval → KIS services: requests credentials (evidence: `server/auth.py`)
- Korea index API → KIS services: requests index data (evidence: `server/index.py`)
- Combined live relay → KIS services: relays live feed (evidence: `server/ws_all.py`)
