# dunking99/meridian architecture

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

- Interactive diagram: https://gitdiagram.com/dunking99/meridian
- Repository: https://github.com/dunking99/meridian

## Overview

Meridian is a local, single-user markets and portfolio terminal. The user workflow runs from price/news history ingestion and SQLite persistence, through portfolio, performance and risk analysis, to API-backed Overview, Holdings, Performance and Analysis screens. It also supports research and alerts, portfolio rebuilding, AI briefing, and reporting. The graph emphasizes documented calls and README capabilities; several unsampled engines are represented by their exact directory paths, with uncertain links omitted.

Main entry points: [`server/index.js`](https://github.com/dunking99/meridian/blob/main/server/index.js) (HTTP API), [`server/engines/portfolio.js`](https://github.com/dunking99/meridian/blob/main/server/engines/portfolio.js) (Portfolio valuation), [`src/shared/layout.jsx`](https://github.com/dunking99/meridian/blob/main/src/shared/layout.jsx) (Page renderer), [`src/overview`](https://github.com/dunking99/meridian/tree/main/src/overview) (Overview page)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ingest["Market data"]
  node_yahoo["Yahoo data<br/>[yahoo.js]"]
  node_news["News ingestion<br/>[news.js]"]
  node_other_sources["Market sources"]
end

subgraph group_analysis["Portfolio analytics"]
  node_portfolio["Portfolio valuation<br/>[portfolio.js]"]
  node_analytics["Risk primitives<br/>[analytics.js]"]
  node_performance["Performance<br/>[performance.js]"]
  node_research["Research<br/>[research.js]"]
  node_briefing["Daily briefing<br/>[briefing.js]"]
  node_rebuild["Portfolio rebuild"]
  node_other_engines["Portfolio engines"]
end

subgraph group_server["API and persistence"]
  node_store[("SQLite history<br/>[db.js]")]
  node_api_server["HTTP API<br/>[index.js]"]
  node_overnight["Page routes"]
end

subgraph group_client["Terminal UI"]
  node_api_client["API client<br/>[api.js]"]
  node_data_hooks["Data hooks<br/>[useApi.js]"]
  node_overview["Overview page"]
  node_holdings["Holdings page"]
  node_performance_ui["Performance page"]
  node_analysis_ui["Analysis page"]
  node_layout["Page renderer<br/>[layout.jsx]"]
  node_charts["Charts and UI"]
end

node_user(("User"))
node_database_service[("SQLite")]

node_yahoo -->|"stores prices"| node_store
node_news -->|"stores stories"| node_store
node_store -->|"reads holdings"| node_portfolio
node_portfolio -->|"uses metrics"| node_analytics
node_research -->|"uses metrics"| node_analytics
node_research -->|"reads stories"| node_news
node_briefing -->|"reads portfolio"| node_portfolio
node_briefing -->|"reads news"| node_news
node_rebuild -->|"uses valuation"| node_portfolio
node_api_server -->|"fetches quotes"| node_yahoo
node_api_server -->|"refreshes feed"| node_news
node_api_server -->|"reads state"| node_store
node_api_server -->|"dispatches requests"| node_other_engines
node_overnight -->|"calls reports"| node_performance
node_overnight -->|"calls valuation"| node_portfolio
node_overnight -->|"routes pages"| node_other_engines
node_api_server -->|"merges routes"| node_overnight
node_database_service -.->|"serves requests"| node_api_server
node_user -->|"views terminal"| node_overview
node_overview -->|"renders panels"| node_layout
node_holdings -->|"sends edits"| node_api_client
node_overview -->|"sends updates"| node_api_client
node_data_hooks -->|"fetches data"| node_api_client
node_layout -->|"loads panel data"| node_data_hooks
node_performance_ui -->|"renders panels"| node_layout
node_analysis_ui -->|"renders panels"| node_layout
node_holdings -->|"uses page specs"| node_layout
node_overview -.->|"renders visuals"| node_charts
node_holdings -->|"renders visuals"| node_charts
node_performance_ui -->|"renders visuals"| node_charts
node_analysis_ui -->|"renders visuals"| node_charts
node_api_client -.->|"requests endpoints"| node_api_server

click node_yahoo "https://github.com/dunking99/meridian/blob/main/server/sources/yahoo.js"
click node_news "https://github.com/dunking99/meridian/blob/main/server/sources/news.js"
click node_other_sources "https://github.com/dunking99/meridian/tree/main/server/sources"
click node_store "https://github.com/dunking99/meridian/blob/main/server/db.js"
click node_portfolio "https://github.com/dunking99/meridian/blob/main/server/engines/portfolio.js"
click node_analytics "https://github.com/dunking99/meridian/blob/main/server/engines/analytics.js"
click node_performance "https://github.com/dunking99/meridian/blob/main/server/engines/performance.js"
click node_research "https://github.com/dunking99/meridian/blob/main/server/engines/research.js"
click node_briefing "https://github.com/dunking99/meridian/blob/main/server/engines/briefing.js"
click node_rebuild "https://github.com/dunking99/meridian/tree/main/server/engines/rebuild"
click node_other_engines "https://github.com/dunking99/meridian/tree/main/server/engines"
click node_api_server "https://github.com/dunking99/meridian/blob/main/server/index.js"
click node_overnight "https://github.com/dunking99/meridian/blob/main/server/routes-overnight.js"
click node_api_client "https://github.com/dunking99/meridian/blob/main/src/shared/api.js"
click node_data_hooks "https://github.com/dunking99/meridian/blob/main/src/shared/useApi.js"
click node_overview "https://github.com/dunking99/meridian/tree/main/src/overview"
click node_holdings "https://github.com/dunking99/meridian/tree/main/src/holdings"
click node_performance_ui "https://github.com/dunking99/meridian/tree/main/src/performance"
click node_analysis_ui "https://github.com/dunking99/meridian/tree/main/src/analysis"
click node_layout "https://github.com/dunking99/meridian/blob/main/src/shared/layout.jsx"
click node_charts "https://github.com/dunking99/meridian/tree/main/src/shared/charts"

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_yahoo,node_news,node_other_sources,node_user toneBlue
class node_portfolio,node_analytics,node_performance,node_research,node_briefing,node_rebuild,node_other_engines,node_database_service toneAmber
class node_store,node_api_server,node_overnight toneMint
class node_api_client,node_data_hooks,node_overview,node_holdings,node_performance_ui,node_analysis_ui,node_layout,node_charts toneRose
```

## Components

### Market data

- [Yahoo data](https://github.com/dunking99/meridian/blob/main/server/sources/yahoo.js): `server/sources/yahoo.js`
- [News ingestion](https://github.com/dunking99/meridian/blob/main/server/sources/news.js): `server/sources/news.js`
- [Market sources](https://github.com/dunking99/meridian/tree/main/server/sources): `server/sources`

### Portfolio analytics

- [Portfolio valuation](https://github.com/dunking99/meridian/blob/main/server/engines/portfolio.js): `server/engines/portfolio.js`
- [Risk primitives](https://github.com/dunking99/meridian/blob/main/server/engines/analytics.js): `server/engines/analytics.js`
- [Performance](https://github.com/dunking99/meridian/blob/main/server/engines/performance.js): `server/engines/performance.js`
- [Research](https://github.com/dunking99/meridian/blob/main/server/engines/research.js): `server/engines/research.js`
- [Daily briefing](https://github.com/dunking99/meridian/blob/main/server/engines/briefing.js): `server/engines/briefing.js`
- [Portfolio rebuild](https://github.com/dunking99/meridian/tree/main/server/engines/rebuild): `server/engines/rebuild`
- [Portfolio engines](https://github.com/dunking99/meridian/tree/main/server/engines): `server/engines`

### API and persistence

- [SQLite history](https://github.com/dunking99/meridian/blob/main/server/db.js): `server/db.js`
- [HTTP API](https://github.com/dunking99/meridian/blob/main/server/index.js): `server/index.js`
- [Page routes](https://github.com/dunking99/meridian/blob/main/server/routes-overnight.js): `server/routes-overnight.js`

### Terminal UI

- [API client](https://github.com/dunking99/meridian/blob/main/src/shared/api.js): `src/shared/api.js`
- [Data hooks](https://github.com/dunking99/meridian/blob/main/src/shared/useApi.js): `src/shared/useApi.js`
- [Overview page](https://github.com/dunking99/meridian/tree/main/src/overview): `src/overview`
- [Holdings page](https://github.com/dunking99/meridian/tree/main/src/holdings): `src/holdings`
- [Performance page](https://github.com/dunking99/meridian/tree/main/src/performance): `src/performance`
- [Analysis page](https://github.com/dunking99/meridian/tree/main/src/analysis): `src/analysis`
- [Page renderer](https://github.com/dunking99/meridian/blob/main/src/shared/layout.jsx): `src/shared/layout.jsx`
- [Charts and UI](https://github.com/dunking99/meridian/tree/main/src/shared/charts): `src/shared/charts`

### Other components

- **User**
- **SQLite**

## Connections

- Yahoo data → SQLite history: stores prices (evidence: `server/sources/yahoo.js`)
- News ingestion → SQLite history: stores stories (evidence: `server/sources/news.js`)
- SQLite history → Portfolio valuation: reads holdings (evidence: `server/engines/portfolio.js`)
- Portfolio valuation → Risk primitives: uses metrics (evidence: `server/engines/portfolio.js`)
- Research → Risk primitives: uses metrics (evidence: `server/engines/research.js`)
- Research → News ingestion: reads stories (evidence: `server/engines/research.js`)
- Daily briefing → Portfolio valuation: reads portfolio (evidence: `server/engines/briefing.js`)
- Daily briefing → News ingestion: reads news (evidence: `server/engines/briefing.js`)
- Portfolio rebuild → Portfolio valuation: uses valuation (evidence: `server/engines/rebuild/index.js`)
- HTTP API → Yahoo data: fetches quotes (evidence: `server/index.js`)
- HTTP API → News ingestion: refreshes feed (evidence: `server/index.js`)
- HTTP API → SQLite history: reads state (evidence: `server/index.js`)
- HTTP API → Portfolio engines: dispatches requests (evidence: `server/index.js`)
- Page routes → Performance: calls reports (evidence: `server/routes-overnight.js`)
- Page routes → Portfolio valuation: calls valuation (evidence: `server/routes-overnight.js`)
- Page routes → Portfolio engines: routes pages (evidence: `server/routes-overnight.js`)
- HTTP API → Page routes: merges routes (evidence: `server/routes-overnight.js`)
- SQLite → HTTP API: serves requests
- User → Overview page: views terminal (evidence: `README.md`)
- Overview page → Page renderer: renders panels (evidence: `src/overview/hooks/useComposition.js`)
- Holdings page → API client: sends edits (evidence: `src/holdings/hooks/useHoldings.js`)
- Overview page → API client: sends updates (evidence: `src/overview/hooks/useBookFacts.js`)
- Data hooks → API client: fetches data (evidence: `src/shared/useApi.js`)
- Page renderer → Data hooks: loads panel data (evidence: `src/shared/layout.jsx`)
- Performance page → Page renderer: renders panels (evidence: `src/performance/hooks/usePerformance.js`)
- Analysis page → Page renderer: renders panels (evidence: `src/analysis/hooks/useAnalysis.js`)
- Holdings page → Page renderer: uses page specs (evidence: `src/holdings/hooks/useHoldings.js`)
- Overview page → Charts and UI: renders visuals
- Holdings page → Charts and UI: renders visuals (evidence: `src/holdings/views/HoldingsMore.jsx`)
- Performance page → Charts and UI: renders visuals (evidence: `src/performance/views/PerformanceViews.jsx`)
- Analysis page → Charts and UI: renders visuals (evidence: `src/analysis/views/AnalysisViews.jsx`)
- API client → HTTP API: requests endpoints
