How sanchitkumar18/risklens works
RiskLens is a market-risk analytics platform with a Streamlit dashboard and FastAPI service. Users ingest market data, create portfolios, and request valuation, risk metrics, stress tests, anomaly scans, and alerts; the API-backed dashboard presents the results. A grounded assistant retrieves analytical results through service-wrapping tools and explains them. The graph preserves the documented ingestion stages and analytics branches. Some route and assistant internals were not sampled, so those links rely on README statements or are omitted where wiring is uncertain.
Main entry points: main.py FastAPI app · risk_service.py Risk service · anomaly_service.py Anomaly service · portfolio_service.py Portfolio service
Components 34
User experience
- Dashboard
dashboard/app.py - Dashboard views
dashboard/views - HTTP client
dashboard/api_client.py
API layer
- FastAPI app
app/main.py - Service wiring
app/api/dependencies.py - Market-data routes
app/api/routes/market_data.py - Portfolio routes
app/api/routes/portfolios.py - Risk routes
app/api/routes/risk.py - Stress routes
app/api/routes/stress.py - Anomaly routes
app/api/routes/anomalies.py - Alert routes
app/api/routes/alerts.py - Assistant route
app/api/routes/assistant.py
Market data
- Market-data service
app/services/market_data_service.py - Ingestion pipeline
app/pipelines/ingestion.py - Validation and cleaning
app/pipelines/validation.py - Feature transformation
app/pipelines/transformation.py
Portfolio and storage
- Portfolio service
app/services/portfolio_service.py - Relational database
app/db/database.py - Market-data repository
app/db/repositories/market_data_repo.py
Risk analytics
- Risk service
app/services/risk_service.py - Risk calculations
app/risk - Stress service
app/services/stress_service.py - Stress engine
app/risk/stress_testing.py - Anomaly service
app/services/anomaly_service.py - Anomaly detection
app/analytics/anomaly_detection.py - Alert service
app/services/alert_service.py - Alert rules
app/analytics/alert_rules.py
Grounded assistant
- Assistant service
app/services/assistant_service.py - Assistant graph
app/llm/graph.py - Grounded tools
app/llm/tools.py - Tool retrieval
app/llm/nodes/retrieve.py - Answer explanation
app/llm/nodes/explain.py - Grounding validation
app/llm/nodes/validate.py
Other components
- User
Connections 48
- User → Dashboard: uses
README.md - Dashboard → Dashboard views: renders
dashboard/app.py - Dashboard → HTTP client: creates
dashboard/app.py - Dashboard views → HTTP client: requests data
dashboard/views/alerts.py - HTTP client → FastAPI app: HTTP requests
dashboard/api_client.py - FastAPI app → Market-data routes: registers
app/main.py - FastAPI app → Portfolio routes: registers
app/main.py - FastAPI app → Risk routes: registers
app/main.py - FastAPI app → Stress routes: registers
app/main.py - FastAPI app → Anomaly routes: registers
app/main.py - FastAPI app → Alert routes: registers
app/main.py - FastAPI app → Assistant route: registers
app/main.py - Market-data routes → Service wiring: gets service
app/api/routes/market_data.py - Portfolio routes → Service wiring: gets service
app/api/routes/portfolios.py - Risk routes → Service wiring: gets service
app/api/routes/risk.py - Market-data routes → Market-data service: calls
app/api/routes/market_data.py - Portfolio routes → Portfolio service: calls
app/api/routes/portfolios.py - Risk routes → Risk service: calls
app/api/routes/risk.py - Market-data service → Ingestion pipeline: ingests
app/services/market_data_service.py - Market-data service → Validation and cleaning: validates
app/services/market_data_service.py - Market-data service → Market-data repository: upserts bars
app/services/market_data_service.py - Portfolio service → Market-data repository: reads prices
app/services/portfolio_service.py - Portfolio service → Relational database: stores portfolio data
README.md - Risk service → Portfolio service: values portfolio
app/services/risk_service.py - Risk service → Market-data repository: loads prices
app/services/risk_service.py - Risk service → Feature transformation: builds features
app/services/risk_service.py - Risk service → Risk calculations: computes metrics
app/services/risk_service.py - Stress routes → Stress service: runs tests
README.md - Stress service → Portfolio service: values portfolio
app/services/stress_service.py - Stress service → Stress engine: applies shocks
app/services/stress_service.py - Anomaly routes → Anomaly service: scans
app/api/routes/anomalies.py - Anomaly service → Portfolio service: gets holdings
app/services/anomaly_service.py - Anomaly service → Market-data repository: loads bars
app/services/anomaly_service.py - Anomaly service → Feature transformation: engineers features
app/services/anomaly_service.py - Anomaly service → Anomaly detection: detects anomalies
app/services/anomaly_service.py - Alert routes → Alert service: evaluates
app/api/routes/alerts.py - Alert service → Risk service: computes risk
app/services/alert_service.py - Alert service → Anomaly service: scans anomalies
app/services/alert_service.py - Alert service → Stress service: runs scenarios
app/services/alert_service.py - Alert service → Alert rules: grades breaches
app/services/alert_service.py - Assistant route → Assistant service: handles query
README.md - Assistant service → Assistant graph: runs graph
- Assistant graph → Tool retrieval: retrieves
- Tool retrieval → Grounded tools: invokes tools
app/llm/nodes/retrieve.py - Grounded tools → Risk service: queries risk
app/llm/tools.py - Grounded tools → Portfolio service: queries portfolio
app/llm/tools.py - Grounded tools → Stress service: runs stress
app/llm/tools.py - Grounded tools → Anomaly service: queries anomalies
app/llm/tools.py