# thesysdev/openui-sales-dashboard architecture

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

- Interactive diagram: https://gitdiagram.com/thesysdev/openui-sales-dashboard
- Repository: https://github.com/thesysdev/openui-sales-dashboard

## Overview

Sales Dashboard turns a user’s sentence or chat request into a live, editable dashboard: the chat tools create or edit a dashboard definition, and the rendered dashboard queries sales data through the server interpreter. The app also provides dashboard history, follow-up suggestions, token-savings status, activity, and a connected-data browser. Relationships shown are documented in the README or visible in the supplied excerpts and source index; unsampled implementation details are not inferred.

Main entry points: [`src/components/app.tsx`](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/components/app.tsx) (App runtime), [`src/lib/data/db.ts`](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/lib/data/db.ts) (SQL access and helpers), [`src/components/dashboard.tsx`](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/components/dashboard.tsx) (Dashboard panel), [`src/app/api/chat/route.ts`](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/app/api/chat/route.ts) (Chat endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["User experience"]
  node_home["Request builder<br/>[home-sentence.tsx]"]
  node_runtime["App runtime<br/>[app.tsx]"]
  node_chatui["Chat thread<br/>[thread.aui.tsx]"]
  node_dashboardview["Dashboard panel<br/>[dashboard.tsx]"]
  node_history["Dashboard history"]
  node_chatmemory["Chat associations<br/>[threads.tsx]"]
  node_connectedview["Connected data browser<br/>[database-view.tsx]"]
  node_status["Status notch<br/>[notch.tsx]"]
end

subgraph group_dashboard["Dashboard generation"]
  node_toolkit["Dashboard tools<br/>[toolkit.tsx]"]
  node_openui["Dashboard definition<br/>[openui.ts]"]
end

subgraph group_data["Sales data"]
  node_sales["Sales query tools<br/>[sales.ts]"]
  node_query["SQL access and helpers<br/>[db.ts]"]
  node_fetchhelpers["Cache and query helpers<br/>[fetch.ts]"]
end

subgraph group_services["API services"]
  node_chatapi["Chat endpoint<br/>[route.ts]"]
  node_followups["Follow-up suggestions<br/>[route.ts]"]
  node_activityapi["Activity endpoint<br/>[route.ts]"]
  node_dbapi["Database browsing API<br/>[route.ts]"]
  node_summaryapi["Database summary API<br/>[route.ts]"]
  node_interpreter["Dashboard interpreter<br/>[route.ts]"]
  node_tokenapi["Token savings API<br/>[route.ts]"]
  node_frontendtoken["Frontend token API<br/>[route.ts]"]
end

subgraph group_identity["Visitor context"]
  node_visitor["Visitor identity<br/>[visitor.ts]"]
  node_activity["Activity recording<br/>[activity.ts]"]
end

node_browser(("Browser user"))
node_cloud["OpenUI Cloud"]
node_postgres[("Retail Postgres")]
node_salesmodel["Chat and dashboard models"]

node_browser -->|"enters request"| node_home
node_home -->|"submits request"| node_runtime
node_runtime -->|"hosts thread"| node_chatui
node_chatui -->|"sends messages"| node_chatapi
node_chatapi -->|"streams completion"| node_salesmodel
node_chatapi -->|"dispatches tools"| node_toolkit
node_toolkit -->|"creates or edits"| node_openui
node_openui -->|"defines dashboards"| node_cloud
node_toolkit -->|"renders tool card"| node_dashboardview
node_dashboardview -->|"streams artifact"| node_cloud
node_cloud -->|"requests queries"| node_interpreter
node_interpreter -->|"runs sales tools"| node_sales
node_sales -->|"queries data"| node_query
node_query -->|"uses helpers"| node_fetchhelpers
node_query -->|"executes SQL"| node_postgres
node_runtime -->|"shows dashboard rail"| node_history
node_history -->|"opens dashboard"| node_dashboardview
node_dashboardview -->|"remembers chat"| node_chatmemory
node_runtime -->|"opens data browser"| node_connectedview
node_connectedview -->|"loads overview"| node_summaryapi
node_connectedview -->|"loads table rows"| node_dbapi
node_dbapi -->|"reads database"| node_query
node_summaryapi -->|"reads summary data"| node_query
node_chatui -->|"requests suggestions"| node_followups
node_runtime -->|"gets cloud token"| node_frontendtoken
node_dashboardview -->|"measures savings"| node_tokenapi
node_runtime -->|"shows work state"| node_status
node_activityapi -->|"reads events"| node_activity
node_query -->|"records queries"| node_activity
node_chatapi -->|"reads visitor"| node_visitor
node_openui -->|"scopes dashboards"| node_visitor
node_dbapi -->|"checks visitor"| node_visitor

click node_home "https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/components/home-sentence.tsx"
click node_runtime "https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/components/app.tsx"
click node_chatui "https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/components/assistant-ui/elements/thread.aui.tsx"
click node_dashboardview "https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/components/dashboard.tsx"
click node_history "https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/components/dashboard-sidebar.tsx"
click node_chatmemory "https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/components/threads.tsx"
click node_connectedview "https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/components/database-view.tsx"
click node_status "https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/components/notch.tsx"
click node_chatapi "https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/app/api/chat/route.ts"
click node_followups "https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/app/api/followups/route.ts"
click node_activityapi "https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/app/api/activity/route.ts"
click node_dbapi "https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/app/api/db/route.ts"
click node_summaryapi "https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/app/api/db/summary/route.ts"
click node_interpreter "https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/app/api/interpreter/route.ts"
click node_tokenapi "https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/app/api/token-savings/route.ts"
click node_frontendtoken "https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/app/api/frontend-token/route.ts"
click node_toolkit "https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/lib/toolkit.tsx"
click node_openui "https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/lib/openui.ts"
click node_sales "https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/lib/data/sales.ts"
click node_query "https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/lib/data/db.ts"
click node_fetchhelpers "https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/lib/data/fetch.ts"
click node_visitor "https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/lib/visitor.ts"
click node_activity "https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/lib/data/activity.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_home,node_runtime,node_chatui,node_dashboardview,node_history,node_chatmemory,node_connectedview,node_status,node_browser,node_cloud toneBlue
class node_toolkit,node_openui,node_postgres toneAmber
class node_sales,node_query,node_fetchhelpers toneMint
class node_chatapi,node_followups,node_activityapi,node_dbapi,node_summaryapi,node_interpreter,node_tokenapi,node_frontendtoken toneRose
class node_visitor,node_activity,node_salesmodel toneIndigo
```

## Components

### User experience

- [Request builder](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/components/home-sentence.tsx): `src/components/home-sentence.tsx`
- [App runtime](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/components/app.tsx): `src/components/app.tsx`
- [Chat thread](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/components/assistant-ui/elements/thread.aui.tsx): `src/components/assistant-ui/elements/thread.aui.tsx`
- [Dashboard panel](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/components/dashboard.tsx): `src/components/dashboard.tsx`
- [Dashboard history](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/components/dashboard-sidebar.tsx): `src/components/dashboard-sidebar.tsx`
- [Chat associations](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/components/threads.tsx): `src/components/threads.tsx`
- [Connected data browser](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/components/database-view.tsx): `src/components/database-view.tsx`
- [Status notch](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/components/notch.tsx): `src/components/notch.tsx`

### Dashboard generation

- [Dashboard tools](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/lib/toolkit.tsx): `src/lib/toolkit.tsx`
- [Dashboard definition](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/lib/openui.ts): `src/lib/openui.ts`

### Sales data

- [Sales query tools](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/lib/data/sales.ts): `src/lib/data/sales.ts`
- [SQL access and helpers](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/lib/data/db.ts): `src/lib/data/db.ts`
- [Cache and query helpers](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/lib/data/fetch.ts): `src/lib/data/fetch.ts`

### API services

- [Chat endpoint](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/app/api/chat/route.ts): `src/app/api/chat/route.ts`
- [Follow-up suggestions](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/app/api/followups/route.ts): `src/app/api/followups/route.ts`
- [Activity endpoint](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/app/api/activity/route.ts): `src/app/api/activity/route.ts`
- [Database browsing API](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/app/api/db/route.ts): `src/app/api/db/route.ts`
- [Database summary API](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/app/api/db/summary/route.ts): `src/app/api/db/summary/route.ts`
- [Dashboard interpreter](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/app/api/interpreter/route.ts): `src/app/api/interpreter/route.ts`
- [Token savings API](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/app/api/token-savings/route.ts): `src/app/api/token-savings/route.ts`
- [Frontend token API](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/app/api/frontend-token/route.ts): `src/app/api/frontend-token/route.ts`

### Visitor context

- [Visitor identity](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/lib/visitor.ts): `src/lib/visitor.ts`
- [Activity recording](https://github.com/thesysdev/openui-sales-dashboard/blob/main/src/lib/data/activity.ts): `src/lib/data/activity.ts`

### Other components

- **Browser user**
- **OpenUI Cloud**
- **Retail Postgres**
- **Chat and dashboard models**

## Connections

- Browser user → Request builder: enters request
- Request builder → App runtime: submits request (evidence: `src/components/app.tsx`)
- App runtime → Chat thread: hosts thread (evidence: `src/components/app.tsx`)
- Chat thread → Chat endpoint: sends messages
- Chat endpoint → Chat and dashboard models: streams completion (evidence: `src/app/api/chat/route.ts`)
- Chat endpoint → Dashboard tools: dispatches tools (evidence: `src/app/api/chat/route.ts`)
- Dashboard tools → Dashboard definition: creates or edits (evidence: `src/lib/toolkit.tsx`)
- Dashboard definition → OpenUI Cloud: defines dashboards (evidence: `src/lib/openui.ts`)
- Dashboard tools → Dashboard panel: renders tool card (evidence: `src/lib/toolkit.tsx`)
- Dashboard panel → OpenUI Cloud: streams artifact
- OpenUI Cloud → Dashboard interpreter: requests queries
- Dashboard interpreter → Sales query tools: runs sales tools
- Sales query tools → SQL access and helpers: queries data (evidence: `src/lib/data/sales.ts`)
- SQL access and helpers → Cache and query helpers: uses helpers (evidence: `src/lib/data/db.ts`)
- SQL access and helpers → Retail Postgres: executes SQL (evidence: `src/lib/data/db.ts`)
- App runtime → Dashboard history: shows dashboard rail (evidence: `src/components/app.tsx`)
- Dashboard history → Dashboard panel: opens dashboard (evidence: `src/components/dashboard-sidebar.tsx`)
- Dashboard panel → Chat associations: remembers chat (evidence: `src/components/dashboard.tsx`)
- App runtime → Connected data browser: opens data browser (evidence: `src/components/app.tsx`)
- Connected data browser → Database summary API: loads overview (evidence: `src/components/database-view.tsx`)
- Connected data browser → Database browsing API: loads table rows (evidence: `src/components/database-view.tsx`)
- Database browsing API → SQL access and helpers: reads database (evidence: `src/app/api/db/route.ts`)
- Database summary API → SQL access and helpers: reads summary data (evidence: `src/app/api/db/summary/route.ts`)
- Chat thread → Follow-up suggestions: requests suggestions
- App runtime → Frontend token API: gets cloud token (evidence: `src/components/app.tsx`)
- Dashboard panel → Token savings API: measures savings (evidence: `src/components/dashboard.tsx`)
- App runtime → Status notch: shows work state (evidence: `src/components/app.tsx`)
- Activity endpoint → Activity recording: reads events (evidence: `src/app/api/activity/route.ts`)
- SQL access and helpers → Activity recording: records queries (evidence: `src/lib/data/db.ts`)
- Chat endpoint → Visitor identity: reads visitor (evidence: `src/app/api/chat/route.ts`)
- Dashboard definition → Visitor identity: scopes dashboards (evidence: `src/lib/openui.ts`)
- Database browsing API → Visitor identity: checks visitor (evidence: `src/app/api/db/route.ts`)
