# wakeensito/clearvest architecture

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

- Interactive diagram: https://gitdiagram.com/wakeensito/clearvest
- Repository: https://github.com/wakeensito/clearvest

## Overview

ClearVest is an AI investment companion: users explore markets and learning content, link portfolio holdings, and receive personalized text or voice guidance. The frontend routes users to those experiences and calls a four-domain HTTP API; market history can refresh asynchronously, while shared backend services provide storage, caching, provider access, and advisor context. The graph preserves major README capabilities. Some links are documented or supported only by the SOURCE INDEX; unsampled implementation details are not inferred.

Main entry points: [`frontend/src/api/client.ts`](https://github.com/wakeensito/clearvest/blob/main/frontend/src/api/client.ts) (API client), [`src/portfolio/portfolio/app.py`](https://github.com/wakeensito/clearvest/blob/main/src/portfolio/portfolio/app.py) (Portfolio API), [`src/market/market/app.py`](https://github.com/wakeensito/clearvest/blob/main/src/market/market/app.py) (Market API), [`frontend/src/router.tsx`](https://github.com/wakeensito/clearvest/blob/main/frontend/src/router.tsx) (Page router)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client experience"]
  node_router["Page router<br/>[router.tsx]"]
  node_api_client["API client<br/>[client.ts]"]
  node_portfolio_ui["Portfolio views<br/>[PortfolioPage.tsx]"]
  node_markets_ui["Market views<br/>[MarketsPage.tsx]"]
  node_advisor_ui["Advisor chat<br/>[AdvisorPage.tsx]"]
  node_learn_ui["Learn experience<br/>[LessonPage.tsx]"]
end

subgraph group_portfolio["Portfolio domain"]
  node_portfolio_api["Portfolio API<br/>[app.py]"]
  node_holdings["Holdings and linking<br/>[holdings.py]"]
  node_plaid_routes["Account linking<br/>[plaid.py]"]
  node_exposure["Exposure analysis<br/>[exposure.py]"]
  node_risk["Portfolio risk<br/>[risk.py]"]
end

subgraph group_market["Market research"]
  node_market_api["Market API<br/>[app.py]"]
  node_search["Security search<br/>[search.py]"]
  node_research["Company research<br/>[research.py]"]
  node_fund["Fund analysis<br/>[fund.py]"]
  node_history["Price history<br/>[history.py]"]
  node_refresh["History refresh<br/>[history_refresh.py]"]
  node_refresh_worker["Refresh worker<br/>[refresh_worker.py]"]
end

subgraph group_guidance["Guidance and learning"]
  node_advisor_api["Advisor API<br/>[app.py]"]
  node_chat["Chat route<br/>[chat.py]"]
  node_advisor_core["Grounded advisor<br/>[advisor.py]"]
  node_scout_context["Evidence context<br/>[scout_context.py]"]
  node_voice_api["Voice API<br/>[app.py]"]
  node_voice_turn["Voice turn<br/>[turn.py]"]
  node_learning["Learning content"]
end

subgraph group_platform["Shared backend"]
  node_shared_api["HTTP framework<br/>[api.py]"]
  node_cache["Provider cache<br/>[cache.py]"]
  node_db["Data access<br/>[db.py]"]
end

node_user(("Investor"))
node_dynamodb[("DynamoDB")]
node_bedrock["Bedrock"]
node_plaid["Plaid"]
node_sqs["SQS queue"]
node_market_data["Market data providers"]

node_user -->|"uses"| node_router
node_router -->|"routes to"| node_portfolio_ui
node_router -->|"routes to"| node_markets_ui
node_router -->|"routes to"| node_advisor_ui
node_router -->|"routes to"| node_learn_ui
node_portfolio_ui -.->|"requests data"| node_api_client
node_markets_ui -.->|"requests data"| node_api_client
node_advisor_ui -.->|"requests guidance"| node_api_client
node_learn_ui -.->|"uses"| node_learning
node_api_client -->|"calls HTTP API"| node_portfolio_api
node_api_client -->|"calls HTTP API"| node_market_api
node_api_client -->|"calls HTTP API"| node_advisor_api
node_api_client -->|"calls HTTP API"| node_voice_api
node_portfolio_api -->|"configures"| node_shared_api
node_portfolio_api -->|"registers"| node_holdings
node_portfolio_api -->|"registers"| node_plaid_routes
node_portfolio_api -->|"registers"| node_exposure
node_portfolio_api -->|"registers"| node_risk
node_holdings -->|"reads and writes"| node_db
node_plaid_routes -->|"refreshes snapshot"| node_holdings
node_plaid_routes -->|"calls"| node_plaid
node_market_api -->|"configures"| node_shared_api
node_market_api -->|"registers"| node_search
node_market_api -->|"registers"| node_research
node_market_api -->|"registers"| node_fund
node_market_api -->|"registers"| node_history
node_search -->|"queries providers"| node_market_data
node_history -->|"requests refresh"| node_refresh
node_history -->|"fetches prices"| node_market_data
node_refresh_worker -->|"processes jobs"| node_refresh
node_refresh_worker -->|"consumes jobs"| node_sqs
node_advisor_api -->|"configures"| node_shared_api
node_advisor_api -->|"registers"| node_chat
node_chat -->|"generates reply"| node_advisor_core
node_chat -->|"loads context"| node_scout_context
node_advisor_core -->|"generates response"| node_bedrock
node_advisor_core -->|"reads and stores chat"| node_db
node_scout_context -->|"reads cached evidence"| node_db
node_voice_api -->|"configures"| node_shared_api
node_voice_api -->|"registers"| node_voice_turn
node_voice_turn -->|"gets guidance"| node_advisor_core
node_voice_turn -->|"loads context"| node_scout_context
node_db -->|"reads and writes"| node_dynamodb
node_cache -->|"stores cache rows"| node_db

click node_router "https://github.com/wakeensito/clearvest/blob/main/frontend/src/router.tsx"
click node_api_client "https://github.com/wakeensito/clearvest/blob/main/frontend/src/api/client.ts"
click node_portfolio_ui "https://github.com/wakeensito/clearvest/blob/main/frontend/src/pages/PortfolioPage.tsx"
click node_markets_ui "https://github.com/wakeensito/clearvest/blob/main/frontend/src/pages/MarketsPage.tsx"
click node_advisor_ui "https://github.com/wakeensito/clearvest/blob/main/frontend/src/features/advisor/AdvisorPage.tsx"
click node_learn_ui "https://github.com/wakeensito/clearvest/blob/main/frontend/src/features/learn/LessonPage.tsx"
click node_portfolio_api "https://github.com/wakeensito/clearvest/blob/main/src/portfolio/portfolio/app.py"
click node_holdings "https://github.com/wakeensito/clearvest/blob/main/src/portfolio/portfolio/routes/holdings.py"
click node_plaid_routes "https://github.com/wakeensito/clearvest/blob/main/src/portfolio/portfolio/routes/plaid.py"
click node_exposure "https://github.com/wakeensito/clearvest/blob/main/src/portfolio/portfolio/routes/exposure.py"
click node_risk "https://github.com/wakeensito/clearvest/blob/main/src/portfolio/portfolio/routes/risk.py"
click node_market_api "https://github.com/wakeensito/clearvest/blob/main/src/market/market/app.py"
click node_search "https://github.com/wakeensito/clearvest/blob/main/src/market/market/routes/search.py"
click node_research "https://github.com/wakeensito/clearvest/blob/main/src/market/market/routes/research.py"
click node_fund "https://github.com/wakeensito/clearvest/blob/main/src/market/market/routes/fund.py"
click node_history "https://github.com/wakeensito/clearvest/blob/main/src/market/market/routes/history.py"
click node_refresh "https://github.com/wakeensito/clearvest/blob/main/src/market/market/history_refresh.py"
click node_refresh_worker "https://github.com/wakeensito/clearvest/blob/main/src/market/market/refresh_worker.py"
click node_advisor_api "https://github.com/wakeensito/clearvest/blob/main/src/advisor/advisor/app.py"
click node_chat "https://github.com/wakeensito/clearvest/blob/main/src/advisor/advisor/routes/chat.py"
click node_advisor_core "https://github.com/wakeensito/clearvest/blob/main/src/layer/clearvest/advisor.py"
click node_scout_context "https://github.com/wakeensito/clearvest/blob/main/src/layer/clearvest/scout_context.py"
click node_voice_api "https://github.com/wakeensito/clearvest/blob/main/src/voice/voice/app.py"
click node_voice_turn "https://github.com/wakeensito/clearvest/blob/main/src/voice/voice/routes/turn.py"
click node_learning "https://github.com/wakeensito/clearvest/blob/main/frontend/src/features/learn/LearningPractice.tsx"
click node_shared_api "https://github.com/wakeensito/clearvest/blob/main/src/layer/clearvest/api.py"
click node_cache "https://github.com/wakeensito/clearvest/blob/main/src/layer/clearvest/cache.py"
click node_db "https://github.com/wakeensito/clearvest/blob/main/src/layer/clearvest/db.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_router,node_api_client,node_portfolio_ui,node_markets_ui,node_advisor_ui,node_learn_ui toneBlue
class node_portfolio_api,node_holdings,node_plaid_routes,node_exposure,node_risk,node_dynamodb toneAmber
class node_market_api,node_search,node_research,node_fund,node_history,node_refresh,node_refresh_worker toneMint
class node_advisor_api,node_chat,node_advisor_core,node_scout_context,node_voice_api,node_voice_turn,node_learning,node_sqs toneRose
class node_shared_api,node_cache,node_db,node_user,node_bedrock,node_plaid,node_market_data toneIndigo
```

## Components

### Client experience

- [Page router](https://github.com/wakeensito/clearvest/blob/main/frontend/src/router.tsx): `frontend/src/router.tsx`
- [API client](https://github.com/wakeensito/clearvest/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`
- [Portfolio views](https://github.com/wakeensito/clearvest/blob/main/frontend/src/pages/PortfolioPage.tsx): `frontend/src/pages/PortfolioPage.tsx`
- [Market views](https://github.com/wakeensito/clearvest/blob/main/frontend/src/pages/MarketsPage.tsx): `frontend/src/pages/MarketsPage.tsx`
- [Advisor chat](https://github.com/wakeensito/clearvest/blob/main/frontend/src/features/advisor/AdvisorPage.tsx): `frontend/src/features/advisor/AdvisorPage.tsx`
- [Learn experience](https://github.com/wakeensito/clearvest/blob/main/frontend/src/features/learn/LessonPage.tsx): `frontend/src/features/learn/LessonPage.tsx`

### Portfolio domain

- [Portfolio API](https://github.com/wakeensito/clearvest/blob/main/src/portfolio/portfolio/app.py): `src/portfolio/portfolio/app.py`
- [Holdings and linking](https://github.com/wakeensito/clearvest/blob/main/src/portfolio/portfolio/routes/holdings.py): `src/portfolio/portfolio/routes/holdings.py`
- [Account linking](https://github.com/wakeensito/clearvest/blob/main/src/portfolio/portfolio/routes/plaid.py): `src/portfolio/portfolio/routes/plaid.py`
- [Exposure analysis](https://github.com/wakeensito/clearvest/blob/main/src/portfolio/portfolio/routes/exposure.py): `src/portfolio/portfolio/routes/exposure.py`
- [Portfolio risk](https://github.com/wakeensito/clearvest/blob/main/src/portfolio/portfolio/routes/risk.py): `src/portfolio/portfolio/routes/risk.py`

### Market research

- [Market API](https://github.com/wakeensito/clearvest/blob/main/src/market/market/app.py): `src/market/market/app.py`
- [Security search](https://github.com/wakeensito/clearvest/blob/main/src/market/market/routes/search.py): `src/market/market/routes/search.py`
- [Company research](https://github.com/wakeensito/clearvest/blob/main/src/market/market/routes/research.py): `src/market/market/routes/research.py`
- [Fund analysis](https://github.com/wakeensito/clearvest/blob/main/src/market/market/routes/fund.py): `src/market/market/routes/fund.py`
- [Price history](https://github.com/wakeensito/clearvest/blob/main/src/market/market/routes/history.py): `src/market/market/routes/history.py`
- [History refresh](https://github.com/wakeensito/clearvest/blob/main/src/market/market/history_refresh.py): `src/market/market/history_refresh.py`
- [Refresh worker](https://github.com/wakeensito/clearvest/blob/main/src/market/market/refresh_worker.py): `src/market/market/refresh_worker.py`

### Guidance and learning

- [Advisor API](https://github.com/wakeensito/clearvest/blob/main/src/advisor/advisor/app.py): `src/advisor/advisor/app.py`
- [Chat route](https://github.com/wakeensito/clearvest/blob/main/src/advisor/advisor/routes/chat.py): `src/advisor/advisor/routes/chat.py`
- [Grounded advisor](https://github.com/wakeensito/clearvest/blob/main/src/layer/clearvest/advisor.py): `src/layer/clearvest/advisor.py`
- [Evidence context](https://github.com/wakeensito/clearvest/blob/main/src/layer/clearvest/scout_context.py): `src/layer/clearvest/scout_context.py`
- [Voice API](https://github.com/wakeensito/clearvest/blob/main/src/voice/voice/app.py): `src/voice/voice/app.py`
- [Voice turn](https://github.com/wakeensito/clearvest/blob/main/src/voice/voice/routes/turn.py): `src/voice/voice/routes/turn.py`
- [Learning content](https://github.com/wakeensito/clearvest/blob/main/frontend/src/features/learn/LearningPractice.tsx): `frontend/src/features/learn/LearningPractice.tsx`

### Shared backend

- [HTTP framework](https://github.com/wakeensito/clearvest/blob/main/src/layer/clearvest/api.py): `src/layer/clearvest/api.py`
- [Provider cache](https://github.com/wakeensito/clearvest/blob/main/src/layer/clearvest/cache.py): `src/layer/clearvest/cache.py`
- [Data access](https://github.com/wakeensito/clearvest/blob/main/src/layer/clearvest/db.py): `src/layer/clearvest/db.py`

### Other components

- **Investor**
- **DynamoDB**
- **Bedrock**
- **Plaid**
- **SQS queue**
- **Market data providers**

## Connections

- Investor → Page router: uses (evidence: `README.md`)
- Page router → Portfolio views: routes to (evidence: `frontend/src/router.tsx`)
- Page router → Market views: routes to (evidence: `frontend/src/router.tsx`)
- Page router → Advisor chat: routes to (evidence: `frontend/src/router.tsx`)
- Page router → Learn experience: routes to (evidence: `frontend/src/router.tsx`)
- Portfolio views → API client: requests data
- Market views → API client: requests data
- Advisor chat → API client: requests guidance
- Learn experience → Learning content: uses
- API client → Portfolio API: calls HTTP API (evidence: `README.md`)
- API client → Market API: calls HTTP API (evidence: `README.md`)
- API client → Advisor API: calls HTTP API (evidence: `README.md`)
- API client → Voice API: calls HTTP API (evidence: `README.md`)
- Portfolio API → HTTP framework: configures (evidence: `src/portfolio/portfolio/app.py`)
- Portfolio API → Holdings and linking: registers (evidence: `src/portfolio/portfolio/app.py`)
- Portfolio API → Account linking: registers (evidence: `src/portfolio/portfolio/app.py`)
- Portfolio API → Exposure analysis: registers (evidence: `src/portfolio/portfolio/app.py`)
- Portfolio API → Portfolio risk: registers (evidence: `src/portfolio/portfolio/app.py`)
- Holdings and linking → Data access: reads and writes (evidence: `src/portfolio/portfolio/routes/holdings.py`)
- Account linking → Holdings and linking: refreshes snapshot (evidence: `src/portfolio/portfolio/routes/plaid.py`)
- Account linking → Plaid: calls (evidence: `src/portfolio/portfolio/routes/plaid.py`)
- Market API → HTTP framework: configures (evidence: `src/market/market/app.py`)
- Market API → Security search: registers (evidence: `src/market/market/app.py`)
- Market API → Company research: registers (evidence: `src/market/market/app.py`)
- Market API → Fund analysis: registers (evidence: `src/market/market/app.py`)
- Market API → Price history: registers (evidence: `src/market/market/app.py`)
- Security search → Market data providers: queries providers (evidence: `src/market/market/routes/search.py`)
- Price history → History refresh: requests refresh (evidence: `src/market/market/routes/history.py`)
- Price history → Market data providers: fetches prices (evidence: `src/market/market/routes/history.py`)
- Refresh worker → History refresh: processes jobs (evidence: `src/market/market/refresh_worker.py`)
- Refresh worker → SQS queue: consumes jobs (evidence: `README.md`)
- Advisor API → HTTP framework: configures (evidence: `src/advisor/advisor/app.py`)
- Advisor API → Chat route: registers (evidence: `src/advisor/advisor/app.py`)
- Chat route → Grounded advisor: generates reply (evidence: `src/advisor/advisor/routes/chat.py`)
- Chat route → Evidence context: loads context (evidence: `src/advisor/advisor/routes/chat.py`)
- Grounded advisor → Bedrock: generates response (evidence: `src/layer/clearvest/advisor.py`)
- Grounded advisor → Data access: reads and stores chat (evidence: `src/layer/clearvest/advisor.py`)
- Evidence context → Data access: reads cached evidence (evidence: `src/layer/clearvest/scout_context.py`)
- Voice API → HTTP framework: configures (evidence: `src/voice/voice/app.py`)
- Voice API → Voice turn: registers (evidence: `src/voice/voice/app.py`)
- Voice turn → Grounded advisor: gets guidance (evidence: `src/voice/voice/routes/turn.py`)
- Voice turn → Evidence context: loads context (evidence: `src/voice/voice/routes/turn.py`)
- Data access → DynamoDB: reads and writes (evidence: `src/layer/clearvest/db.py`)
- Provider cache → Data access: stores cache rows (evidence: `src/layer/clearvest/cache.py`)
