# rpratama180922-byte/uhu architecture

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

- Interactive diagram: https://gitdiagram.com/rpratama180922-byte/uhu
- Repository: https://github.com/rpratama180922-byte/uhu

## Overview

This is an Indonesian investment research and portfolio-management terminal. Users enter through the routed dashboard and workspace, then explore market data, manage portfolios, and use research, valuation, risk, and backtesting tools. The server exposes market, portfolio, and quant APIs backed by PostgreSQL and synchronized provider data; portfolio alerts add a live notification path. Analytics and finance modules form an internal calculation layer. The README is empty, so capability coverage comes from the source index and tree; several page and feature implementations were not sampled, and their internal links are omitted where unverified.

Main entry points: [`src/App.tsx`](https://github.com/rpratama180922-byte/uhu/blob/main/src/App.tsx) (App routing), [`src/services/marketData/syncService.ts`](https://github.com/rpratama180922-byte/uhu/blob/main/src/services/marketData/syncService.ts) (Market synchronization), [`server.ts`](https://github.com/rpratama180922-byte/uhu/blob/main/server.ts) (HTTP server), [`src/db/schema.ts`](https://github.com/rpratama180922-byte/uhu/blob/main/src/db/schema.ts) (PostgreSQL schema)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Terminal experience"]
  node_app["App routing<br/>[App.tsx]"]
  node_workspace["Workspace state"]
  node_terminal["Terminal shell<br/>[TerminalShell.tsx]"]
end

subgraph group_investment["Investment workflows"]
  node_dashboard["Dashboard brief<br/>[DashboardPage.tsx]"]
  node_portfolio["Portfolio management<br/>[PortfolioPages.tsx]"]
  node_portfolio_intelligence["Portfolio intelligence"]
  node_alerts_ui["Portfolio alerts"]
  node_markets["Market exploration<br/>[MarketPages.tsx]"]
  node_heatmaps["Market heatmaps"]
  node_research["Research and valuation"]
  node_research_panels["Research commands"]
  node_risk["Risk analysis<br/>[RiskPage.tsx]"]
  node_backtest_ui["Backtest workflows<br/>[BacktestPages.tsx]"]
end

subgraph group_analysis["Analytics layer"]
  node_backtester["Backtest engine<br/>[backtester.py]"]
  node_analytics["Portfolio analytics<br/>[analytics.ts]"]
  node_wealth["Wealth intelligence"]
  node_institutional["Institutional analytics"]
  node_quant["Quant calculations<br/>[quantExpansion.ts]"]
  node_finance["Finance calculations<br/>[finance.ts]"]
end

subgraph group_services["API and services"]
  node_api_client["API client<br/>[apiClient.ts]"]
  node_server["HTTP server<br/>[server.ts]"]
  node_market_routes["Market API<br/>[market.ts]"]
  node_portfolio_routes["Portfolio API<br/>[portfolio.ts]"]
  node_quant_routes["Quant API<br/>[quant.ts]"]
  node_alert_engine["Alert engine"]
  node_sync["Market synchronization<br/>[syncService.ts]"]
  node_providers["Market providers<br/>[providers.ts]"]
end

subgraph group_persistence["Identity and data"]
  node_auth["Authentication<br/>[auth.ts]"]
  node_user_records["User records<br/>[users.ts]"]
  node_database[("PostgreSQL schema<br/>[schema.ts]")]
end

node_investor(("Investor"))

node_investor -->|"opens terminal"| node_app
node_app -->|"provides state"| node_workspace
node_app -->|"wraps routes"| node_terminal
node_app -->|"routes to"| node_dashboard
node_app -->|"routes to"| node_portfolio
node_app -->|"routes to"| node_markets
node_app -->|"routes to"| node_research
node_app -->|"routes to"| node_risk
node_app -->|"routes to"| node_backtest_ui
node_dashboard -->|"renders"| node_portfolio_intelligence
node_portfolio -->|"renders"| node_portfolio_intelligence
node_portfolio -->|"renders"| node_alerts_ui
node_markets -.->|"renders"| node_heatmaps
node_research -->|"renders"| node_research_panels
node_backtest_ui -.->|"uses engine"| node_backtester
node_dashboard -->|"uses calculations"| node_analytics
node_dashboard -->|"uses insights"| node_wealth
node_portfolio -->|"uses analysis"| node_institutional
node_research -->|"uses models"| node_quant
node_analytics -->|"uses calculations"| node_finance
node_institutional -->|"uses metrics"| node_analytics
node_quant -->|"uses calculations"| node_finance
node_wealth -->|"uses ledger types"| node_finance
node_workspace -->|"fetches API"| node_api_client
node_server -->|"registers middleware"| node_auth
node_server -->|"registers route"| node_market_routes
node_server -->|"registers route"| node_portfolio_routes
node_server -->|"registers route"| node_quant_routes
node_server -->|"starts sync"| node_sync
node_server -->|"starts alerts"| node_alert_engine
node_market_routes -->|"uses market data"| node_sync
node_market_routes -->|"reads and writes"| node_database
node_portfolio_routes -->|"reads and writes"| node_database
node_portfolio_routes -->|"invokes alerts"| node_alert_engine
node_quant_routes -->|"reads and writes"| node_database
node_quant_routes -->|"uses market data"| node_sync
node_sync -->|"fetches prices"| node_providers
node_sync -->|"persists market data"| node_database
node_auth -->|"loads user"| node_user_records
node_auth -->|"seeds workspace"| node_sync
node_user_records -->|"queries schema"| node_database
node_alert_engine -->|"loads prices"| node_sync
node_alert_engine -->|"updates alerts"| node_database

click node_app "https://github.com/rpratama180922-byte/uhu/blob/main/src/App.tsx"
click node_workspace "https://github.com/rpratama180922-byte/uhu/blob/main/src/context/TerminalContext.tsx"
click node_terminal "https://github.com/rpratama180922-byte/uhu/blob/main/src/components/layout/TerminalShell.tsx"
click node_dashboard "https://github.com/rpratama180922-byte/uhu/blob/main/src/pages/DashboardPage.tsx"
click node_portfolio "https://github.com/rpratama180922-byte/uhu/blob/main/src/pages/PortfolioPages.tsx"
click node_portfolio_intelligence "https://github.com/rpratama180922-byte/uhu/blob/main/src/components/intelligence/PortfolioIntelligencePanels.tsx"
click node_alerts_ui "https://github.com/rpratama180922-byte/uhu/blob/main/src/components/portfolio/PortfolioAlertsPanel.tsx"
click node_markets "https://github.com/rpratama180922-byte/uhu/blob/main/src/pages/MarketPages.tsx"
click node_heatmaps "https://github.com/rpratama180922-byte/uhu/blob/main/src/components/market/SectorDistributionHeatmap.tsx"
click node_research "https://github.com/rpratama180922-byte/uhu/blob/main/src/pages/ResearchAndValuationPages.tsx"
click node_research_panels "https://github.com/rpratama180922-byte/uhu/blob/main/src/components/research/ResearchCommandPanels.tsx"
click node_risk "https://github.com/rpratama180922-byte/uhu/blob/main/src/pages/RiskPage.tsx"
click node_backtest_ui "https://github.com/rpratama180922-byte/uhu/blob/main/src/pages/BacktestPages.tsx"
click node_backtester "https://github.com/rpratama180922-byte/uhu/blob/main/python/backtester.py"
click node_analytics "https://github.com/rpratama180922-byte/uhu/blob/main/src/lib/analytics.ts"
click node_wealth "https://github.com/rpratama180922-byte/uhu/blob/main/src/lib/wealthIntelligence.ts"
click node_institutional "https://github.com/rpratama180922-byte/uhu/blob/main/src/lib/institutionalAnalytics.ts"
click node_quant "https://github.com/rpratama180922-byte/uhu/blob/main/src/lib/quantExpansion.ts"
click node_finance "https://github.com/rpratama180922-byte/uhu/blob/main/src/lib/finance.ts"
click node_api_client "https://github.com/rpratama180922-byte/uhu/blob/main/src/lib/apiClient.ts"
click node_server "https://github.com/rpratama180922-byte/uhu/blob/main/server.ts"
click node_market_routes "https://github.com/rpratama180922-byte/uhu/blob/main/src/server/routes/market.ts"
click node_portfolio_routes "https://github.com/rpratama180922-byte/uhu/blob/main/src/server/routes/portfolio.ts"
click node_quant_routes "https://github.com/rpratama180922-byte/uhu/blob/main/src/server/routes/quant.ts"
click node_alert_engine "https://github.com/rpratama180922-byte/uhu/blob/main/src/server/services/portfolioAlertEngine.ts"
click node_sync "https://github.com/rpratama180922-byte/uhu/blob/main/src/services/marketData/syncService.ts"
click node_providers "https://github.com/rpratama180922-byte/uhu/blob/main/src/services/marketData/providers.ts"
click node_auth "https://github.com/rpratama180922-byte/uhu/blob/main/src/middleware/auth.ts"
click node_user_records "https://github.com/rpratama180922-byte/uhu/blob/main/src/db/users.ts"
click node_database "https://github.com/rpratama180922-byte/uhu/blob/main/src/db/schema.ts"

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_workspace,node_terminal toneBlue
class node_dashboard,node_portfolio,node_portfolio_intelligence,node_alerts_ui,node_markets,node_heatmaps,node_research,node_research_panels,node_risk,node_backtest_ui toneAmber
class node_backtester,node_analytics,node_wealth,node_institutional,node_quant,node_finance toneMint
class node_api_client,node_server,node_market_routes,node_portfolio_routes,node_quant_routes,node_alert_engine,node_sync,node_providers toneRose
class node_auth,node_user_records,node_database,node_investor toneIndigo
```

## Components

### Terminal experience

- [App routing](https://github.com/rpratama180922-byte/uhu/blob/main/src/App.tsx): `src/App.tsx`
- [Workspace state](https://github.com/rpratama180922-byte/uhu/blob/main/src/context/TerminalContext.tsx): `src/context/TerminalContext.tsx`
- [Terminal shell](https://github.com/rpratama180922-byte/uhu/blob/main/src/components/layout/TerminalShell.tsx): `src/components/layout/TerminalShell.tsx`

### Investment workflows

- [Dashboard brief](https://github.com/rpratama180922-byte/uhu/blob/main/src/pages/DashboardPage.tsx): `src/pages/DashboardPage.tsx`
- [Portfolio management](https://github.com/rpratama180922-byte/uhu/blob/main/src/pages/PortfolioPages.tsx): `src/pages/PortfolioPages.tsx`
- [Portfolio intelligence](https://github.com/rpratama180922-byte/uhu/blob/main/src/components/intelligence/PortfolioIntelligencePanels.tsx): `src/components/intelligence/PortfolioIntelligencePanels.tsx`
- [Portfolio alerts](https://github.com/rpratama180922-byte/uhu/blob/main/src/components/portfolio/PortfolioAlertsPanel.tsx): `src/components/portfolio/PortfolioAlertsPanel.tsx`
- [Market exploration](https://github.com/rpratama180922-byte/uhu/blob/main/src/pages/MarketPages.tsx): `src/pages/MarketPages.tsx`
- [Market heatmaps](https://github.com/rpratama180922-byte/uhu/blob/main/src/components/market/SectorDistributionHeatmap.tsx): `src/components/market/SectorDistributionHeatmap.tsx`
- [Research and valuation](https://github.com/rpratama180922-byte/uhu/blob/main/src/pages/ResearchAndValuationPages.tsx): `src/pages/ResearchAndValuationPages.tsx`
- [Research commands](https://github.com/rpratama180922-byte/uhu/blob/main/src/components/research/ResearchCommandPanels.tsx): `src/components/research/ResearchCommandPanels.tsx`
- [Risk analysis](https://github.com/rpratama180922-byte/uhu/blob/main/src/pages/RiskPage.tsx): `src/pages/RiskPage.tsx`
- [Backtest workflows](https://github.com/rpratama180922-byte/uhu/blob/main/src/pages/BacktestPages.tsx): `src/pages/BacktestPages.tsx`

### Analytics layer

- [Backtest engine](https://github.com/rpratama180922-byte/uhu/blob/main/python/backtester.py): `python/backtester.py`
- [Portfolio analytics](https://github.com/rpratama180922-byte/uhu/blob/main/src/lib/analytics.ts): `src/lib/analytics.ts`
- [Wealth intelligence](https://github.com/rpratama180922-byte/uhu/blob/main/src/lib/wealthIntelligence.ts): `src/lib/wealthIntelligence.ts`
- [Institutional analytics](https://github.com/rpratama180922-byte/uhu/blob/main/src/lib/institutionalAnalytics.ts): `src/lib/institutionalAnalytics.ts`
- [Quant calculations](https://github.com/rpratama180922-byte/uhu/blob/main/src/lib/quantExpansion.ts): `src/lib/quantExpansion.ts`
- [Finance calculations](https://github.com/rpratama180922-byte/uhu/blob/main/src/lib/finance.ts): `src/lib/finance.ts`

### API and services

- [API client](https://github.com/rpratama180922-byte/uhu/blob/main/src/lib/apiClient.ts): `src/lib/apiClient.ts`
- [HTTP server](https://github.com/rpratama180922-byte/uhu/blob/main/server.ts): `server.ts`
- [Market API](https://github.com/rpratama180922-byte/uhu/blob/main/src/server/routes/market.ts): `src/server/routes/market.ts`
- [Portfolio API](https://github.com/rpratama180922-byte/uhu/blob/main/src/server/routes/portfolio.ts): `src/server/routes/portfolio.ts`
- [Quant API](https://github.com/rpratama180922-byte/uhu/blob/main/src/server/routes/quant.ts): `src/server/routes/quant.ts`
- [Alert engine](https://github.com/rpratama180922-byte/uhu/blob/main/src/server/services/portfolioAlertEngine.ts): `src/server/services/portfolioAlertEngine.ts`
- [Market synchronization](https://github.com/rpratama180922-byte/uhu/blob/main/src/services/marketData/syncService.ts): `src/services/marketData/syncService.ts`
- [Market providers](https://github.com/rpratama180922-byte/uhu/blob/main/src/services/marketData/providers.ts): `src/services/marketData/providers.ts`

### Identity and data

- [Authentication](https://github.com/rpratama180922-byte/uhu/blob/main/src/middleware/auth.ts): `src/middleware/auth.ts`
- [User records](https://github.com/rpratama180922-byte/uhu/blob/main/src/db/users.ts): `src/db/users.ts`
- [PostgreSQL schema](https://github.com/rpratama180922-byte/uhu/blob/main/src/db/schema.ts): `src/db/schema.ts`

### Other components

- **Investor**

## Connections

- Investor → App routing: opens terminal (evidence: `src/App.tsx`)
- App routing → Workspace state: provides state (evidence: `src/App.tsx`)
- App routing → Terminal shell: wraps routes (evidence: `src/App.tsx`)
- App routing → Dashboard brief: routes to (evidence: `src/App.tsx`)
- App routing → Portfolio management: routes to (evidence: `src/App.tsx`)
- App routing → Market exploration: routes to (evidence: `src/App.tsx`)
- App routing → Research and valuation: routes to (evidence: `src/App.tsx`)
- App routing → Risk analysis: routes to (evidence: `src/App.tsx`)
- App routing → Backtest workflows: routes to (evidence: `src/App.tsx`)
- Dashboard brief → Portfolio intelligence: renders (evidence: `src/pages/DashboardPage.tsx`)
- Portfolio management → Portfolio intelligence: renders (evidence: `src/pages/PortfolioPages.tsx`)
- Portfolio management → Portfolio alerts: renders (evidence: `src/pages/PortfolioPages.tsx`)
- Market exploration → Market heatmaps: renders
- Research and valuation → Research commands: renders (evidence: `src/pages/ResearchAndValuationPages.tsx`)
- Backtest workflows → Backtest engine: uses engine
- Dashboard brief → Portfolio analytics: uses calculations (evidence: `src/pages/DashboardPage.tsx`)
- Dashboard brief → Wealth intelligence: uses insights (evidence: `src/pages/DashboardPage.tsx`)
- Portfolio management → Institutional analytics: uses analysis (evidence: `src/pages/PortfolioPages.tsx`)
- Research and valuation → Quant calculations: uses models (evidence: `src/pages/ResearchAndValuationPages.tsx`)
- Portfolio analytics → Finance calculations: uses calculations (evidence: `src/lib/analytics.ts`)
- Institutional analytics → Portfolio analytics: uses metrics (evidence: `src/lib/institutionalAnalytics.ts`)
- Quant calculations → Finance calculations: uses calculations (evidence: `src/lib/quantExpansion.ts`)
- Wealth intelligence → Finance calculations: uses ledger types (evidence: `src/lib/wealthIntelligence.ts`)
- Workspace state → API client: fetches API (evidence: `src/context/TerminalContext.tsx`)
- HTTP server → Authentication: registers middleware (evidence: `server.ts`)
- HTTP server → Market API: registers route (evidence: `server.ts`)
- HTTP server → Portfolio API: registers route (evidence: `server.ts`)
- HTTP server → Quant API: registers route (evidence: `server.ts`)
- HTTP server → Market synchronization: starts sync (evidence: `server.ts`)
- HTTP server → Alert engine: starts alerts (evidence: `server.ts`)
- Market API → Market synchronization: uses market data (evidence: `src/server/routes/market.ts`)
- Market API → PostgreSQL schema: reads and writes (evidence: `src/server/routes/market.ts`)
- Portfolio API → PostgreSQL schema: reads and writes (evidence: `src/server/routes/portfolio.ts`)
- Portfolio API → Alert engine: invokes alerts (evidence: `src/server/routes/portfolio.ts`)
- Quant API → PostgreSQL schema: reads and writes (evidence: `src/server/routes/quant.ts`)
- Quant API → Market synchronization: uses market data (evidence: `src/server/routes/quant.ts`)
- Market synchronization → Market providers: fetches prices (evidence: `src/services/marketData/syncService.ts`)
- Market synchronization → PostgreSQL schema: persists market data (evidence: `src/services/marketData/syncService.ts`)
- Authentication → User records: loads user (evidence: `src/middleware/auth.ts`)
- Authentication → Market synchronization: seeds workspace (evidence: `src/middleware/auth.ts`)
- User records → PostgreSQL schema: queries schema (evidence: `src/db/users.ts`)
- Alert engine → Market synchronization: loads prices (evidence: `src/server/services/portfolioAlertEngine.ts`)
- Alert engine → PostgreSQL schema: updates alerts (evidence: `src/server/services/portfolioAlertEngine.ts`)
