# prismqd/pqd-dash architecture

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

- Interactive diagram: https://gitdiagram.com/prismqd/pqd-dash
- Repository: https://github.com/prismqd/pqd-dash

## Overview

1. **Overall shape**
   - This is a **Next.js App Router** frontend for the PRISMqd Dashboard.
   - The repository is organized around one main product surface: a **medical dashboard UI** composed from many specialized cards and visualization panels.

2. **Application entry points**
   - `app/layout.tsx`, `app/page.tsx`, and `app/globals.css` define the root shell, page composition, and global styling.
   - `app/actions/get-medical-dashboard-data.ts` is the main data-fetching boundary for the dashboard, separating page rendering from data acquisition.

3. **Primary feature surface**
   - `components/medical-dashboard.tsx` is the top-level dashboard composition component.
   - The `components/medical-dashboard/` folder contains the dashboard’s functional sub-panels: patient info, clinician info, policy info, status info, AI information, alert notes, alert surface, body diagram, timeline track, vital sign display, and the event details modal.

4. **Data flow and domain boundary**
   - The dashboard appears to consume a **single domain model** of medical-alert and patient-state data, then fan that data out into specialized cards.
   - `components/medical-dashboard/types.ts` defines the shared shape used across these panels, which keeps the UI consistent and typed.
   - The page/data flow is likely: **page → server action → DAL/mock data → dashboard component → individual cards/modals**.

5. **Data access layer**
   - `lib/dal/mock-medical-dashboard.ts` is the current data source boundary.
   - This suggests the frontend is wired to a **mocked or local data-access layer**, rather than directly calling a live backend in this repo.
   - That boundary is important for an architecture diagram because it shows where a future real API could be swapped in.

6. **State and interaction**
   - `components/alert-state-context.tsx` provides shared client-side state for alert-related UI behavior.
   - Interactive elements such as the **event details modal**, **expanded cards**, and **notes panel** are likely coordinated through this state layer rather than being isolated per-component.

7. **Visualization subsystem**
   - `components/vital-signs-waveform-card.tsx`, `data/vital-signs-stream.ts`, `data/scichart-vital-signs-data.ts`, and `data/waveforms.ts` support the waveform/vital-sign visualization path.
   - This is the most specialized part of the UI and is backed by **SciChart**, including the WASM runtime assets in `public/_wasm/scichart2d.js` and `public/_wasm/scichart2d.wasm`.
   - In the diagram, this should be shown as a distinct visualization subsystem with a native/WebAssembly dependency.

8. **Design system and shared UI**
   - `components/ui/` contains reusable primitives such as button, card, progress, scroll area, and tooltip.
   - The project uses **Tailwind CSS** and **shadcn/ui-style** component composition, which means most visual structure is built from small shared primitives rather than a heavyweight component framework.

9. **Static assets and presentation resources**
   - `public/images` holds image assets, likely for anatomical or branded visuals.
   - `styles/globals.css` and `app/globals.css` are the main styling entry points; the repo also includes a `theme-provider.tsx`, implying theme context is part of the UI shell.

10. **Local content generation and preprocessing**
    - `scripts/fetch-waveforms.mjs`, `scripts/verify-waveforms.mjs`, and `scripts/vectorize-body-diagram.ts` indicate offline asset/data preparation.
    - These scripts are not runtime features, but they matter architecturally because they generate or validate inputs used by the dashboard visualization and body diagram surfaces.

11. **Component development workflow**
    - Nearly every major UI piece has a corresponding `*.stories.tsx` file, and there is a `stories/Overview.mdx`.
    - Storybook is a first-class boundary for isolated component development and visual verification, separate from the live app runtime.

12. **Testing and quality gates**
    - `vitest.config.ts` and `storybook/vitest.setup.ts` show Vitest-based testing support.
    - Biome (`biome.json`), markdownlint, and Husky hooks indicate automated formatting/linting checks before commits and pushes.

13. **Runtime and deployment context**
    - The stack is built for **Node.js 22**, **Bun**, and **Vercel**, with `next.config.mjs` controlling Next.js behavior.
    - This matters architecturally because the app is designed for a server-rendered React deployment model, with static assets and WASM delivered through the Next/Vercel pipeline.

14. **What to emphasize in an architecture diagram**
    - Show a central **Medical Dashboard UI** node fed by a **mock data layer / server action**.
    - Break the UI into subpanels: **patient/clinician/policy/status cards**, **alert and notes panels**, **timeline and body diagram**, and **vital-sign waveform visualization**.
    - Draw a separate **SciChart/WASM visualization dependency** and a **shared UI primitives layer** beneath the dashboard.
    - Keep **Storybook/testing/tooling** as a side lane, and **asset-generation scripts** as an offline support lane rather than runtime components.

Main entry points: [`components/medical-dashboard.tsx`](https://github.com/prismqd/pqd-dash/blob/main/components/medical-dashboard.tsx) (Medical dashboard), [`components/vital-signs-waveform-card.tsx`](https://github.com/prismqd/pqd-dash/blob/main/components/vital-signs-waveform-card.tsx) (Waveform card), [`stories/Overview.mdx`](https://github.com/prismqd/pqd-dash/blob/main/stories/Overview.mdx) (Storybook), [`data/waveforms.ts`](https://github.com/prismqd/pqd-dash/blob/main/data/waveforms.ts) (Waveform data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["App shell"]
  node_app_layout["Root layout<br/>next shell<br/>[layout.tsx]"]
  node_app_page["Dashboard page<br/>route page<br/>[page.tsx]"]
  node_app_actions["Data action<br/>server action"]
  node_global_styles["Global styles<br/>css entry<br/>[globals.css]"]
end

subgraph group_dashboard["Medical dashboard"]
  node_medical_dashboard["Medical dashboard<br/>composite UI"]
  node_patient_card["Patient card<br/>info panel"]
  node_clinician_card["Clinician card<br/>info panel<br/>[clinician-card.tsx]"]
  node_policy_card["Policy card<br/>info panel"]
  node_status_card["Status card<br/>status panel"]
  node_ai_card["AI card<br/>insight panel"]
  node_alert_surface["Alert surface<br/>alert panel"]
  node_alert_notes["Notes panel<br/>collaboration panel"]
  node_body_diagram["Body diagram<br/>anatomy view"]
  node_timeline_track["Timeline track<br/>event timeline<br/>[timeline-track.tsx]"]
  node_vital_sign["Vital sign<br/>measurement card<br/>[vital-sign.tsx]"]
  node_event_modal["Event modal<br/>detail modal"]
end

subgraph group_data["Data layer"]
  node_vital_stream["Vital stream<br/>data stream"]
  node_waveform_data["Waveform data<br/>prepared data<br/>[waveforms.ts]"]
  node_scichart_data["SciChart data<br/>prepared data"]
  node_mock_dal[("Mock DAL<br/>data access")]
end

subgraph group_viz["Visualization"]
  node_waveform_card["Waveform card<br/>viz card"]
  node_scichart_runtime[("SciChart WASM<br/>native runtime<br/>[scichart2d.wasm]")]
  node_scichart_js["SciChart loader<br/>runtime loader<br/>[scichart2d.js]"]
end

subgraph group_ui["Shared UI"]
  node_alert_state["Alert state<br/>client context"]
  node_ui_primitives["UI primitives<br/>shared components"]
  node_theme_provider["Theme provider<br/>ui context<br/>[theme-provider.tsx]"]
end

subgraph group_tooling["Tooling"]
  node_stories["Storybook<br/>component sandbox<br/>[Overview.mdx]"]
  node_scripts["Asset scripts<br/>offline pipeline"]
  node_testing["Quality checks<br/>test tooling<br/>[vitest.config.ts]"]
end

node_app_layout -->|"wraps"| node_theme_provider
node_app_layout -->|"loads"| node_global_styles
node_app_page -->|"requests data"| node_app_actions
node_app_page -->|"renders"| node_medical_dashboard
node_app_actions -->|"fetches from"| node_mock_dal
node_medical_dashboard -->|"includes"| node_patient_card
node_medical_dashboard -->|"includes"| node_clinician_card
node_medical_dashboard -->|"includes"| node_policy_card
node_medical_dashboard -->|"includes"| node_status_card
node_medical_dashboard -->|"includes"| node_ai_card
node_medical_dashboard -->|"includes"| node_alert_surface
node_medical_dashboard -->|"includes"| node_alert_notes
node_medical_dashboard -->|"includes"| node_body_diagram
node_medical_dashboard -->|"includes"| node_timeline_track
node_medical_dashboard -->|"includes"| node_vital_sign
node_medical_dashboard -->|"opens"| node_event_modal
node_medical_dashboard -->|"shares state"| node_alert_state
node_alert_notes -->|"reads state"| node_alert_state
node_event_modal -->|"reads state"| node_alert_state
node_vital_sign -->|"drills into"| node_waveform_card
node_waveform_card -->|"consumes"| node_vital_stream
node_vital_stream -->|"transforms to"| node_waveform_data
node_waveform_data -->|"adapts to"| node_scichart_data
node_waveform_card -->|"loads"| node_scichart_js
node_scichart_js -->|"boots"| node_scichart_runtime
node_scichart_data -->|"renders with"| node_scichart_runtime
node_medical_dashboard -->|"builds from"| node_ui_primitives
node_medical_dashboard -->|"uses"| node_theme_provider
node_stories -->|"documents"| node_medical_dashboard
node_stories -->|"documents"| node_ui_primitives
node_scripts -->|"prepares assets"| node_body_diagram
node_scripts -->|"prepares assets"| node_waveform_data
node_testing -->|"supports"| node_stories
node_testing -->|"verifies"| node_medical_dashboard

click node_app_layout "https://github.com/prismqd/pqd-dash/blob/main/app/layout.tsx"
click node_app_page "https://github.com/prismqd/pqd-dash/blob/main/app/page.tsx"
click node_app_actions "https://github.com/prismqd/pqd-dash/blob/main/app/actions/get-medical-dashboard-data.ts"
click node_global_styles "https://github.com/prismqd/pqd-dash/blob/main/app/globals.css"
click node_medical_dashboard "https://github.com/prismqd/pqd-dash/blob/main/components/medical-dashboard.tsx"
click node_patient_card "https://github.com/prismqd/pqd-dash/blob/main/components/medical-dashboard/patient-info-card.tsx"
click node_clinician_card "https://github.com/prismqd/pqd-dash/blob/main/components/medical-dashboard/clinician-card.tsx"
click node_policy_card "https://github.com/prismqd/pqd-dash/blob/main/components/medical-dashboard/policy-info-card.tsx"
click node_status_card "https://github.com/prismqd/pqd-dash/blob/main/components/medical-dashboard/status-info-card.tsx"
click node_ai_card "https://github.com/prismqd/pqd-dash/blob/main/components/medical-dashboard/ai-information-card.tsx"
click node_alert_surface "https://github.com/prismqd/pqd-dash/blob/main/components/medical-dashboard/alert-surface-card.tsx"
click node_alert_notes "https://github.com/prismqd/pqd-dash/blob/main/components/medical-dashboard/alert-notes-card.tsx"
click node_body_diagram "https://github.com/prismqd/pqd-dash/blob/main/components/medical-dashboard/body-diagram-card.tsx"
click node_timeline_track "https://github.com/prismqd/pqd-dash/blob/main/components/medical-dashboard/timeline-track.tsx"
click node_vital_sign "https://github.com/prismqd/pqd-dash/blob/main/components/medical-dashboard/vital-sign.tsx"
click node_event_modal "https://github.com/prismqd/pqd-dash/blob/main/components/medical-dashboard/event-details-modal.tsx"
click node_alert_state "https://github.com/prismqd/pqd-dash/blob/main/components/alert-state-context.tsx"
click node_ui_primitives "https://github.com/prismqd/pqd-dash/tree/main/components/ui"
click node_theme_provider "https://github.com/prismqd/pqd-dash/blob/main/components/theme-provider.tsx"
click node_waveform_card "https://github.com/prismqd/pqd-dash/blob/main/components/vital-signs-waveform-card.tsx"
click node_vital_stream "https://github.com/prismqd/pqd-dash/blob/main/data/vital-signs-stream.ts"
click node_waveform_data "https://github.com/prismqd/pqd-dash/blob/main/data/waveforms.ts"
click node_scichart_data "https://github.com/prismqd/pqd-dash/blob/main/data/scichart-vital-signs-data.ts"
click node_scichart_runtime "https://github.com/prismqd/pqd-dash/blob/main/public/_wasm/scichart2d.wasm"
click node_scichart_js "https://github.com/prismqd/pqd-dash/blob/main/public/_wasm/scichart2d.js"
click node_mock_dal "https://github.com/prismqd/pqd-dash/blob/main/lib/dal/mock-medical-dashboard.ts"
click node_stories "https://github.com/prismqd/pqd-dash/blob/main/stories/Overview.mdx"
click node_scripts "https://github.com/prismqd/pqd-dash/tree/main/scripts"
click node_testing "https://github.com/prismqd/pqd-dash/blob/main/vitest.config.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_layout,node_app_page,node_app_actions,node_global_styles toneBlue
class node_medical_dashboard,node_patient_card,node_clinician_card,node_policy_card,node_status_card,node_ai_card,node_alert_surface,node_alert_notes,node_body_diagram,node_timeline_track,node_vital_sign,node_event_modal toneAmber
class node_vital_stream,node_waveform_data,node_scichart_data,node_mock_dal toneMint
class node_waveform_card,node_scichart_runtime,node_scichart_js toneRose
class node_alert_state,node_ui_primitives,node_theme_provider toneIndigo
class node_stories,node_scripts,node_testing toneTeal
```

## Components

### App shell

Next.js App Router entrypoints and page composition.

- [Root layout](https://github.com/prismqd/pqd-dash/blob/main/app/layout.tsx): next shell · App-wide HTML shell and providers. · `app/layout.tsx`
- [Dashboard page](https://github.com/prismqd/pqd-dash/blob/main/app/page.tsx): route page · Top-level route composition for the dashboard. · `app/page.tsx`
- [Data action](https://github.com/prismqd/pqd-dash/blob/main/app/actions/get-medical-dashboard-data.ts): server action · Fetch boundary between page rendering and dashboard data. · `app/actions/get-medical-dashboard-data.ts`
- [Global styles](https://github.com/prismqd/pqd-dash/blob/main/app/globals.css): css entry · Application-wide styling entrypoint. · `app/globals.css`

### Medical dashboard

Core product surface and its specialized panels.

- [Medical dashboard](https://github.com/prismqd/pqd-dash/blob/main/components/medical-dashboard.tsx): composite UI · Main dashboard composition component. · `components/medical-dashboard.tsx`
- [Patient card](https://github.com/prismqd/pqd-dash/blob/main/components/medical-dashboard/patient-info-card.tsx): info panel · Patient identity and demographics surface. · `components/medical-dashboard/patient-info-card.tsx`
- [Clinician card](https://github.com/prismqd/pqd-dash/blob/main/components/medical-dashboard/clinician-card.tsx): info panel · Clinician and care-team surface. · `components/medical-dashboard/clinician-card.tsx`
- [Policy card](https://github.com/prismqd/pqd-dash/blob/main/components/medical-dashboard/policy-info-card.tsx): info panel · Policy and care-rule surface. · `components/medical-dashboard/policy-info-card.tsx`
- [Status card](https://github.com/prismqd/pqd-dash/blob/main/components/medical-dashboard/status-info-card.tsx): status panel · Current alert and patient-state summary. · `components/medical-dashboard/status-info-card.tsx`
- [AI card](https://github.com/prismqd/pqd-dash/blob/main/components/medical-dashboard/ai-information-card.tsx): insight panel · AI-generated or AI-assisted information surface. · `components/medical-dashboard/ai-information-card.tsx`
- [Alert surface](https://github.com/prismqd/pqd-dash/blob/main/components/medical-dashboard/alert-surface-card.tsx): alert panel · Primary alert presentation and escalation view. · `components/medical-dashboard/alert-surface-card.tsx`
- [Notes panel](https://github.com/prismqd/pqd-dash/blob/main/components/medical-dashboard/alert-notes-card.tsx): collaboration panel · Alert notes and clinician annotations. · `components/medical-dashboard/alert-notes-card.tsx`
- [Body diagram](https://github.com/prismqd/pqd-dash/blob/main/components/medical-dashboard/body-diagram-card.tsx): anatomy view · Body map or anatomical alert visualization. · `components/medical-dashboard/body-diagram-card.tsx`
- [Timeline track](https://github.com/prismqd/pqd-dash/blob/main/components/medical-dashboard/timeline-track.tsx): event timeline · Chronological alert and event track. · `components/medical-dashboard/timeline-track.tsx`
- [Vital sign](https://github.com/prismqd/pqd-dash/blob/main/components/medical-dashboard/vital-sign.tsx): measurement card · Single-vital presentation used inside the dashboard. · `components/medical-dashboard/vital-sign.tsx`
- [Event modal](https://github.com/prismqd/pqd-dash/blob/main/components/medical-dashboard/event-details-modal.tsx): detail modal · Expanded event details and interaction focus. · `components/medical-dashboard/event-details-modal.tsx`

### Data layer

Mock domain data and generated visualization inputs.

- [Vital stream](https://github.com/prismqd/pqd-dash/blob/main/data/vital-signs-stream.ts): data stream · Streaming or sequenced vital-sign data source. · `data/vital-signs-stream.ts`
- [Waveform data](https://github.com/prismqd/pqd-dash/blob/main/data/waveforms.ts): prepared data · Derived waveform dataset for chart rendering. · `data/waveforms.ts`
- [SciChart data](https://github.com/prismqd/pqd-dash/blob/main/data/scichart-vital-signs-data.ts): prepared data · SciChart-specific vital-sign dataset preparation. · `data/scichart-vital-signs-data.ts`
- [Mock DAL](https://github.com/prismqd/pqd-dash/blob/main/lib/dal/mock-medical-dashboard.ts): data access · Local medical dashboard data boundary. · `lib/dal/mock-medical-dashboard.ts`

### Visualization

Waveform rendering path and SciChart runtime.

- [Waveform card](https://github.com/prismqd/pqd-dash/blob/main/components/vital-signs-waveform-card.tsx): viz card · Dashboard card for waveform and vital-sign charts. · `components/vital-signs-waveform-card.tsx`
- [SciChart WASM](https://github.com/prismqd/pqd-dash/blob/main/public/_wasm/scichart2d.wasm): native runtime · WebAssembly charting runtime loaded by the app. · `public/_wasm/scichart2d.wasm`
- [SciChart loader](https://github.com/prismqd/pqd-dash/blob/main/public/_wasm/scichart2d.js): runtime loader · JavaScript bootstrap for the SciChart runtime. · `public/_wasm/scichart2d.js`

### Shared UI

Reusable primitives and cross-cutting UI state.

- [Alert state](https://github.com/prismqd/pqd-dash/blob/main/components/alert-state-context.tsx): client context · Shared client-side state for alert interactions. · `components/alert-state-context.tsx`
- [UI primitives](https://github.com/prismqd/pqd-dash/tree/main/components/ui): shared components · Reusable button, card, progress, scroll, and tooltip primitives. · `components/ui`
- [Theme provider](https://github.com/prismqd/pqd-dash/blob/main/components/theme-provider.tsx): ui context · Application theme context and shell wiring. · `components/theme-provider.tsx`

### Tooling

Storybook, testing, scripts, and repo workflows.

- [Storybook](https://github.com/prismqd/pqd-dash/blob/main/stories/Overview.mdx): component sandbox · Isolated UI development and visual verification. · `stories/Overview.mdx`
- [Asset scripts](https://github.com/prismqd/pqd-dash/tree/main/scripts): offline pipeline · Waveform fetching, validation, and body-diagram preprocessing. · `scripts`
- [Quality checks](https://github.com/prismqd/pqd-dash/blob/main/vitest.config.ts): test tooling · Vitest, Storybook setup, lint/format hooks, and repo checks. · `vitest.config.ts`

## Connections

- Root layout → Theme provider: wraps · The root layout installs shared UI context.
- Root layout → Global styles: loads · Global CSS is applied at the app shell.
- Dashboard page → Data action: requests data · The page obtains dashboard data through the server action.
- Dashboard page → Medical dashboard: renders · The route composes the dashboard surface.
- Data action → Mock DAL: fetches from · Dashboard data is sourced from the mock DAL boundary.
- Medical dashboard → Patient card: includes · Dashboard fans out domain data into the patient panel.
- Medical dashboard → Clinician card: includes · Dashboard fans out domain data into the clinician panel.
- Medical dashboard → Policy card: includes · Dashboard fans out domain data into the policy panel.
- Medical dashboard → Status card: includes · Dashboard fans out domain data into the status panel.
- Medical dashboard → AI card: includes · Dashboard fans out domain data into the AI panel.
- Medical dashboard → Alert surface: includes · Dashboard includes the main alert surface.
- Medical dashboard → Notes panel: includes · Dashboard includes notes and annotations.
- Medical dashboard → Body diagram: includes · Dashboard includes anatomical alert visualization.
- Medical dashboard → Timeline track: includes · Dashboard includes the event timeline.
- Medical dashboard → Vital sign: includes · Dashboard includes vital-sign summary cards.
- Medical dashboard → Event modal: opens · Dashboard interaction surfaces expanded event details.
- Medical dashboard → Alert state: shares state · Interactive dashboard pieces coordinate through alert context.
- Notes panel → Alert state: reads state · Notes UI is coordinated by shared alert state.
- Event modal → Alert state: reads state · Modal state is controlled through the shared alert context.
- Vital sign → Waveform card: drills into · Vital-sign UI links to waveform visualization.
- Waveform card → Vital stream: consumes · Waveform card is fed by the vital-sign stream.
- Vital stream → Waveform data: transforms to · Streamed data is shaped for chart-ready waveform output.
- Waveform data → SciChart data: adapts to · Prepared waveform data is adapted for SciChart rendering.
- Waveform card → SciChart loader: loads · The charting card bootstraps the JS runtime.
- SciChart loader → SciChart WASM: boots · The JS loader activates the WASM runtime.
- SciChart data → SciChart WASM: renders with · SciChart-specific data is rendered by the WASM engine.
- Medical dashboard → UI primitives: builds from · Dashboard panels are composed from shared primitives.
- Medical dashboard → Theme provider: uses · Dashboard is themed through the shared provider.
- Storybook → Medical dashboard: documents · Storybook captures the dashboard and subcomponents.
- Storybook → UI primitives: documents · Storybook also covers shared primitive components.
- Asset scripts → Body diagram: prepares assets · Offline scripts generate or vectorize body-diagram inputs.
- Asset scripts → Waveform data: prepares assets · Offline scripts fetch and verify waveform inputs.
- Quality checks → Storybook: supports · Storybook setup participates in the quality workflow.
- Quality checks → Medical dashboard: verifies · Vitest and repo checks validate the dashboard surface.
