How psxdata/psxdata-api works
psxdata-api is a FastAPI service that exposes PSX stock, index, sector, screener, and market data over HTTP. Callers enter through the application’s registered routes; handlers fetch or assemble data, validate it into response envelopes, and return it. Historical stock data follows a separate cache-first path, with freshness rules and optional Redis persistence; proxy passthrough can alter the route to PSX when enabled. The graph reflects the supplied excerpts, SOURCE INDEX references, and README; some subsystem wiring is documented but its implementation was not sampled.
Main entry points: __init__.py Route Registry · proxy.py Proxy Passthrough · historical.py History Service · schemas.py Response Models
Components 21
HTTP API
- FastAPI App
api/main.py - Route Registry
api/routers/__init__.py - Health Endpoint
api/routers/health.py - Response Models
api/schemas.py
Market Data
- Stock Endpoints
api/routers/stocks.py - Index Endpoints
api/routers/indices.py - Sector Endpoints
api/routers/sectors.py - Screener Endpoint
api/routers/screener.py - Market Endpoints
api/routers/market.py
Historical Cache
- History Service
api/cache/historical.py - Freshness Rules
api/cache/freshness.py - Cache Codec
api/cache/codec.py - Cache Factory
api/cache/factory.py - Tiered Store
api/cache/store.py - Memory LRU
api/cache/store.py - Redis Store
api/cache/store.py
Integrations
- Redis Service
- Proxy Passthrough
api/proxy.py - psxdata SDK
- Telemetry
api/telemetry.py
Other components
- API Caller
Connections 34
- API Caller → FastAPI App: sends request
README.md - FastAPI App → Route Registry: registers routes
api/main.py - Route Registry → Health Endpoint: registers
api/routers/__init__.py - Route Registry → Stock Endpoints: registers
api/routers/__init__.py - Route Registry → Index Endpoints: registers
api/routers/__init__.py - Route Registry → Sector Endpoints: registers
api/routers/__init__.py - Route Registry → Screener Endpoint: registers
api/routers/__init__.py - Route Registry → Market Endpoints: registers
api/routers/__init__.py - Stock Endpoints → Response Models: validates responses
api/routers/stocks.py - Index Endpoints → Response Models: validates responses
api/routers/indices.py - Sector Endpoints → Response Models: validates responses
api/routers/sectors.py - Screener Endpoint → Response Models: validates responses
api/routers/screener.py - Market Endpoints → Response Models: validates responses
api/routers/market.py - Health Endpoint → Response Models: uses models
api/routers/health.py - Stock Endpoints → History Service: gets history
api/routers/stocks.py - Stock Endpoints → Proxy Passthrough: uses PSX source
api/routers/stocks.py - Index Endpoints → Proxy Passthrough: uses PSX source
api/routers/indices.py - Sector Endpoints → Proxy Passthrough: uses PSX source
api/routers/sectors.py - Screener Endpoint → Proxy Passthrough: uses PSX source
api/routers/screener.py - Market Endpoints → Proxy Passthrough: uses PSX source
api/routers/market.py - Proxy Passthrough → psxdata SDK: fetches data
api/proxy.py - History Service → psxdata SDK: fetches on miss
README.md - History Service → Tiered Store: reads and writes
api/cache/historical.py - History Service → Freshness Rules: checks freshness
api/cache/historical.py - History Service → Cache Codec: encodes entries
api/cache/historical.py - Cache Factory → History Service: builds service
api/cache/factory.py - Cache Factory → Tiered Store: constructs store
api/cache/factory.py - Cache Factory → Freshness Rules: uses default TTL
api/cache/factory.py - FastAPI App → Cache Factory: builds cache
api/main.py - FastAPI App → Proxy Passthrough: configures passthrough
api/main.py - FastAPI App → Telemetry: flushes telemetry
api/main.py - Tiered Store → Memory LRU: checks first
api/cache/store.py - Tiered Store → Redis Store: falls back
api/cache/store.py - Redis Store → Redis Service: reads and writes
api/cache/store.py