# longsurf-ai/openchart architecture

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

- Interactive diagram: https://gitdiagram.com/longsurf-ai/openchart
- Repository: https://github.com/longsurf-ai/openchart

## Overview

OpenChart is a desktop market-analysis workspace combining interactive charts, custom Tea logic, alerts, and user-configured AI agents. Users explore market data and indicators, define alert conditions or monitors, and can ask agents to investigate market moves; results may include source-linked chart annotations. The repository also includes dashboards, watchlists, schedules, shared posts, and workspace files. The graph combines README-documented capabilities with sampled API and server boundaries; several implementation details are unsampled, so uncertain links are dashed.

Main entry points: [`server/agent/router.ts`](https://github.com/longsurf-ai/openchart/blob/main/server/agent/router.ts) (Agent sessions and prompts), [`server/index.ts`](https://github.com/longsurf-ai/openchart/blob/main/server/index.ts) (HTTP and Hose API), [`app/src/features/chart`](https://github.com/longsurf-ai/openchart/tree/main/app/src/features/chart) (Charts and indicators), [`app/src/features/alerts`](https://github.com/longsurf-ai/openchart/tree/main/app/src/features/alerts) (Alerts and monitors)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Desktop experience"]
  node_desktop["Desktop host<br/>[main.ts]"]
  node_app["Application UI"]
end

subgraph group_market["Market analysis"]
  node_chart["Charts and indicators"]
  node_dashboard["Dashboards"]
  node_watchlist["Watchlists"]
  node_marketdata["Market data providers"]
  node_tea["Tea analysis logic<br/>[tea.ts]"]
  node_alerts["Alerts and monitors"]
end

subgraph group_agent["Agent workflows"]
  node_agentui["Agent interface"]
  node_agentapi["Agent sessions and prompts<br/>[router.ts]"]
  node_models["Model providers<br/>[models.ts]"]
  node_annotations["Chart explanations"]
end

subgraph group_server["Backend services"]
  node_schedule["Schedules"]
  node_workspace["Workspace files<br/>[router.ts]"]
  node_feed["Community feed"]
end

subgraph group_runtime["Runtime infrastructure"]
  node_api["HTTP and Hose API<br/>[index.ts]"]
  node_hose["Hose transport<br/>[server.ts]"]
  node_database[("SQLite database<br/>[database.ts]")]
  node_events["Application events<br/>[router.ts]"]
end

node_investor(("Investor"))

node_investor -.->|"opens"| node_desktop
node_desktop -->|"hosts"| node_app
node_investor -->|"explores markets"| node_chart
node_chart -.->|"loads market data"| node_marketdata
node_chart -->|"uses custom logic"| node_tea
node_investor -->|"defines alerts"| node_alerts
node_alerts -->|"evaluates monitors"| node_tea
node_alerts -->|"requests investigation"| node_agentapi
node_investor -->|"asks agent"| node_agentui
node_agentui -.->|"submits prompts"| node_agentapi
node_agentapi -.->|"uses configured models"| node_models
node_agentapi -.->|"produces explanations"| node_annotations
node_investor -.->|"organizes charts"| node_dashboard
node_investor -.->|"tracks symbols"| node_watchlist
node_investor -.->|"schedules tasks"| node_schedule
node_investor -.->|"manages files"| node_workspace
node_investor -.->|"views posts"| node_feed
node_api -->|"creates transport"| node_hose
node_api -.->|"starts runtime"| node_database
node_agentapi -.->|"routes through tRPC"| node_api
node_events -.->|"streams subscriptions"| node_api

click node_desktop "https://github.com/longsurf-ai/openchart/blob/main/platform/desktop/src/main.ts"
click node_app "https://github.com/longsurf-ai/openchart/tree/main/app/src/app"
click node_chart "https://github.com/longsurf-ai/openchart/tree/main/app/src/features/chart"
click node_dashboard "https://github.com/longsurf-ai/openchart/tree/main/app/src/features/dashboard"
click node_watchlist "https://github.com/longsurf-ai/openchart/tree/main/app/src/features/watchlist"
click node_marketdata "https://github.com/longsurf-ai/openchart/tree/main/server/data/providers"
click node_tea "https://github.com/longsurf-ai/openchart/blob/main/server/tea/tea.ts"
click node_alerts "https://github.com/longsurf-ai/openchart/tree/main/app/src/features/alerts"
click node_agentui "https://github.com/longsurf-ai/openchart/tree/main/app/src/features/agent"
click node_agentapi "https://github.com/longsurf-ai/openchart/blob/main/server/agent/router.ts"
click node_models "https://github.com/longsurf-ai/openchart/blob/main/server/models/models.ts"
click node_annotations "https://github.com/longsurf-ai/openchart/blob/main/app/src/features/chart/components/chart-explain-drawings.tsx"
click node_schedule "https://github.com/longsurf-ai/openchart/tree/main/app/src/features/schedule"
click node_workspace "https://github.com/longsurf-ai/openchart/blob/main/server/workspace/router.ts"
click node_feed "https://github.com/longsurf-ai/openchart/tree/main/app/src/features/posts"
click node_api "https://github.com/longsurf-ai/openchart/blob/main/server/index.ts"
click node_hose "https://github.com/longsurf-ai/openchart/blob/main/common/hose/src/server.ts"
click node_database "https://github.com/longsurf-ai/openchart/blob/main/server/db/database.ts"
click node_events "https://github.com/longsurf-ai/openchart/blob/main/server/events/router.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_desktop,node_app toneBlue
class node_chart,node_dashboard,node_watchlist,node_marketdata,node_tea,node_alerts toneAmber
class node_agentui,node_agentapi,node_models,node_annotations toneMint
class node_schedule,node_workspace,node_feed toneRose
class node_api,node_hose,node_database,node_events,node_investor toneIndigo
```

## Components

### Desktop experience

- [Desktop host](https://github.com/longsurf-ai/openchart/blob/main/platform/desktop/src/main.ts): `platform/desktop/src/main.ts`
- [Application UI](https://github.com/longsurf-ai/openchart/tree/main/app/src/app): `app/src/app`

### Market analysis

- [Charts and indicators](https://github.com/longsurf-ai/openchart/tree/main/app/src/features/chart): `app/src/features/chart`
- [Dashboards](https://github.com/longsurf-ai/openchart/tree/main/app/src/features/dashboard): `app/src/features/dashboard`
- [Watchlists](https://github.com/longsurf-ai/openchart/tree/main/app/src/features/watchlist): `app/src/features/watchlist`
- [Market data providers](https://github.com/longsurf-ai/openchart/tree/main/server/data/providers): `server/data/providers`
- [Tea analysis logic](https://github.com/longsurf-ai/openchart/blob/main/server/tea/tea.ts): `server/tea/tea.ts`
- [Alerts and monitors](https://github.com/longsurf-ai/openchart/tree/main/app/src/features/alerts): `app/src/features/alerts`

### Agent workflows

- [Agent interface](https://github.com/longsurf-ai/openchart/tree/main/app/src/features/agent): `app/src/features/agent`
- [Agent sessions and prompts](https://github.com/longsurf-ai/openchart/blob/main/server/agent/router.ts): `server/agent/router.ts`
- [Model providers](https://github.com/longsurf-ai/openchart/blob/main/server/models/models.ts): `server/models/models.ts`
- [Chart explanations](https://github.com/longsurf-ai/openchart/blob/main/app/src/features/chart/components/chart-explain-drawings.tsx): `app/src/features/chart/components/chart-explain-drawings.tsx`

### Backend services

- [Schedules](https://github.com/longsurf-ai/openchart/tree/main/app/src/features/schedule): `app/src/features/schedule`
- [Workspace files](https://github.com/longsurf-ai/openchart/blob/main/server/workspace/router.ts): `server/workspace/router.ts`
- [Community feed](https://github.com/longsurf-ai/openchart/tree/main/app/src/features/posts): `app/src/features/posts`

### Runtime infrastructure

- [HTTP and Hose API](https://github.com/longsurf-ai/openchart/blob/main/server/index.ts): `server/index.ts`
- [Hose transport](https://github.com/longsurf-ai/openchart/blob/main/common/hose/src/server.ts): `common/hose/src/server.ts`
- [SQLite database](https://github.com/longsurf-ai/openchart/blob/main/server/db/database.ts): `server/db/database.ts`
- [Application events](https://github.com/longsurf-ai/openchart/blob/main/server/events/router.ts): `server/events/router.ts`

### Other components

- **Investor**

## Connections

- Investor → Desktop host: opens
- Desktop host → Application UI: hosts (evidence: `platform/desktop/src/main.ts`)
- Investor → Charts and indicators: explores markets (evidence: `README.md`)
- Charts and indicators → Market data providers: loads market data
- Charts and indicators → Tea analysis logic: uses custom logic (evidence: `README.md`)
- Investor → Alerts and monitors: defines alerts (evidence: `README.md`)
- Alerts and monitors → Tea analysis logic: evaluates monitors (evidence: `README.md`)
- Alerts and monitors → Agent sessions and prompts: requests investigation (evidence: `README.md`)
- Investor → Agent interface: asks agent (evidence: `README.md`)
- Agent interface → Agent sessions and prompts: submits prompts
- Agent sessions and prompts → Model providers: uses configured models
- Agent sessions and prompts → Chart explanations: produces explanations
- Investor → Dashboards: organizes charts
- Investor → Watchlists: tracks symbols
- Investor → Schedules: schedules tasks
- Investor → Workspace files: manages files
- Investor → Community feed: views posts
- HTTP and Hose API → Hose transport: creates transport (evidence: `server/index.ts`)
- HTTP and Hose API → SQLite database: starts runtime
- Agent sessions and prompts → HTTP and Hose API: routes through tRPC
- Application events → HTTP and Hose API: streams subscriptions
