# daniyl-nguyen/crowdsense architecture

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

- Interactive diagram: https://gitdiagram.com/daniyl-nguyen/crowdsense
- Repository: https://github.com/daniyl-nguyen/crowdsense

## Overview

CrowdSense coaches presentations in real time: browser camera nodes analyze presenter delivery and anonymous audience engagement, while phones can submit reactions. A session room merges those signals into nudges, scores, and lost-moment spikes; afterward, presenters can review an AI-assisted report and synced recording. The README documents practice simulation, replay, account support, and optional integrations. Evidence is strongest for sampled room, server, and replay paths; some UI and vision links reflect explicit README architecture rather than inspected implementation.

Main entry points: [`server/room.ts`](https://github.com/daniyl-nguyen/crowdsense/blob/master/server/room.ts) (Live room), [`web/src/vision/usePresenterPipeline.ts`](https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/vision/usePresenterPipeline.ts) (Presenter pipeline), [`web/src/lib/socket.ts`](https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/lib/socket.ts) (WebSocket client), [`web/src/lib/api.ts`](https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/lib/api.ts) (HTTP client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser experience"]
  node_presenter["Presenter camera<br/>[presenter.ts]"]
  node_audiencecam["Audience camera<br/>[audience.ts]"]
  node_presentpipe["Presenter pipeline"]
  node_audio["Speech capture<br/>[mic.ts]"]
  node_camera["Camera views<br/>[Camera.tsx]"]
  node_dashboard["Dashboard<br/>[Dashboard.tsx]"]
  node_monitor["Live monitor<br/>[Monitor.tsx]"]
  node_practice["Practice mode<br/>[Practice.tsx]"]
  node_join["Phone reactions<br/>[Join.tsx]"]
  node_socket["WebSocket client<br/>[socket.ts]"]
  node_api["HTTP client<br/>[api.ts]"]
end

subgraph group_live["Live session engine"]
  node_hub["Session hub<br/>[hub.ts]"]
  node_room["Live room<br/>[room.ts]"]
  node_metrics["Nudges and scoring<br/>[nudges.ts]"]
  node_audiencecalc["Audience metrics<br/>[audience.ts]"]
  node_spikes["Lost-moment detection<br/>[spikes.ts]"]
  node_thresholds["Coaching thresholds<br/>[thresholds.ts]"]
  node_speech["Speech tracking<br/>[speech.ts]"]
  node_whisper["Whisper transcription<br/>[whisper.ts]"]
end

subgraph group_insights["Reports and replay"]
  node_report["Report builder<br/>[report.ts]"]
  node_coach["AI coaching<br/>[coach.ts]"]
  node_reportpage["Session report<br/>[Report.tsx]"]
  node_replay["Synced replay<br/>[Replay.tsx]"]
  node_timeline["Session timeline<br/>[Timeline.tsx]"]
  node_recorder["Recording upload<br/>[useRecorder.ts]"]
end

subgraph group_platform["Persistence and services"]
  node_repo[("Session repository<br/>[repo.ts]")]
  node_neon[("Neon Postgres<br/>[neon.ts]")]
  node_blobs[("Recording storage<br/>[storage.ts]")]
  node_routes["Session routes<br/>[sessions.ts]"]
  node_recordroutes["Recording routes<br/>[recordings.ts]"]
  node_ws["WebSocket server<br/>[ws.ts]"]
  node_auth["Account and access<br/>[auth.ts]"]
  node_extras["Optional review<br/>[review.ts]"]
end

node_actor(("Presenter and audience"))

node_actor -->|"speaks to"| node_presentpipe
node_presentpipe -->|"analyzes frames"| node_presenter
node_presentpipe -->|"captures speech"| node_audio
node_actor -->|"faces camera"| node_audiencecam
node_camera -.->|"hosts pipeline"| node_presentpipe
node_presentpipe -->|"sends metrics"| node_socket
node_dashboard -.->|"joins session"| node_socket
node_monitor -.->|"receives ticks"| node_socket
node_practice -.->|"starts practice"| node_hub
node_join -.->|"sends reactions"| node_socket
node_socket -->|"exchanges messages"| node_ws
node_ws -->|"dispatches messages"| node_hub
node_hub -->|"creates rooms"| node_room
node_room -->|"computes nudges"| node_metrics
node_room -.->|"aggregates audience"| node_audiencecalc
node_room -.->|"detects spikes"| node_spikes
node_room -.->|"applies thresholds"| node_thresholds
node_room -->|"tracks speech"| node_speech
node_room -->|"transcribes audio"| node_whisper
node_room -->|"persists session data"| node_repo
node_repo -->|"stores records"| node_neon
node_routes -->|"finds sessions"| node_hub
node_recordroutes -->|"handles recordings"| node_blobs
node_recorder -->|"uploads parts"| node_api
node_api -.->|"requests recordings"| node_recordroutes
node_room -.->|"builds final report"| node_report
node_report -.->|"requests coaching"| node_coach
node_reportpage -->|"loads report"| node_api
node_replay -->|"loads replay data"| node_api
node_replay -->|"renders timeline"| node_timeline
node_reportpage -->|"renders timeline"| node_timeline
node_auth -.->|"protects access"| node_routes
node_extras -->|"reads recordings"| node_blobs
node_extras -.->|"reviews moments"| node_coach

click node_presenter "https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/vision/presenter.ts"
click node_audiencecam "https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/vision/audience.ts"
click node_presentpipe "https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/vision/usePresenterPipeline.ts"
click node_audio "https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/audio/mic.ts"
click node_camera "https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/pages/Camera.tsx"
click node_dashboard "https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/pages/Dashboard.tsx"
click node_monitor "https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/pages/Monitor.tsx"
click node_practice "https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/pages/Practice.tsx"
click node_join "https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/pages/Join.tsx"
click node_socket "https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/lib/socket.ts"
click node_api "https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/lib/api.ts"
click node_hub "https://github.com/daniyl-nguyen/crowdsense/blob/master/server/hub.ts"
click node_room "https://github.com/daniyl-nguyen/crowdsense/blob/master/server/room.ts"
click node_metrics "https://github.com/daniyl-nguyen/crowdsense/blob/master/shared/nudges.ts"
click node_audiencecalc "https://github.com/daniyl-nguyen/crowdsense/blob/master/shared/audience.ts"
click node_spikes "https://github.com/daniyl-nguyen/crowdsense/blob/master/shared/spikes.ts"
click node_thresholds "https://github.com/daniyl-nguyen/crowdsense/blob/master/shared/thresholds.ts"
click node_speech "https://github.com/daniyl-nguyen/crowdsense/blob/master/server/speech.ts"
click node_whisper "https://github.com/daniyl-nguyen/crowdsense/blob/master/server/ai/whisper.ts"
click node_report "https://github.com/daniyl-nguyen/crowdsense/blob/master/server/report.ts"
click node_coach "https://github.com/daniyl-nguyen/crowdsense/blob/master/server/ai/coach.ts"
click node_reportpage "https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/pages/Report.tsx"
click node_replay "https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/pages/Replay.tsx"
click node_timeline "https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/ui/Timeline.tsx"
click node_recorder "https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/rec/useRecorder.ts"
click node_repo "https://github.com/daniyl-nguyen/crowdsense/blob/master/server/db/repo.ts"
click node_neon "https://github.com/daniyl-nguyen/crowdsense/blob/master/server/db/neon.ts"
click node_blobs "https://github.com/daniyl-nguyen/crowdsense/blob/master/server/storage.ts"
click node_routes "https://github.com/daniyl-nguyen/crowdsense/blob/master/server/routes/sessions.ts"
click node_recordroutes "https://github.com/daniyl-nguyen/crowdsense/blob/master/server/routes/recordings.ts"
click node_ws "https://github.com/daniyl-nguyen/crowdsense/blob/master/server/ws.ts"
click node_auth "https://github.com/daniyl-nguyen/crowdsense/blob/master/server/auth.ts"
click node_extras "https://github.com/daniyl-nguyen/crowdsense/blob/master/server/ai/review.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_presenter,node_audiencecam,node_presentpipe,node_audio,node_camera,node_dashboard,node_monitor,node_practice,node_join,node_socket,node_api toneBlue
class node_hub,node_room,node_metrics,node_audiencecalc,node_spikes,node_thresholds,node_speech,node_whisper toneAmber
class node_report,node_coach,node_reportpage,node_replay,node_timeline,node_recorder toneMint
class node_repo,node_neon,node_blobs,node_routes,node_recordroutes,node_ws,node_auth,node_extras toneRose
class node_actor toneIndigo
```

## Components

### Browser experience

- [Presenter camera](https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/vision/presenter.ts): `web/src/vision/presenter.ts`
- [Audience camera](https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/vision/audience.ts): `web/src/vision/audience.ts`
- [Presenter pipeline](https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/vision/usePresenterPipeline.ts): `web/src/vision/usePresenterPipeline.ts`
- [Speech capture](https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/audio/mic.ts): `web/src/audio/mic.ts`
- [Camera views](https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/pages/Camera.tsx): `web/src/pages/Camera.tsx`
- [Dashboard](https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/pages/Dashboard.tsx): `web/src/pages/Dashboard.tsx`
- [Live monitor](https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/pages/Monitor.tsx): `web/src/pages/Monitor.tsx`
- [Practice mode](https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/pages/Practice.tsx): `web/src/pages/Practice.tsx`
- [Phone reactions](https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/pages/Join.tsx): `web/src/pages/Join.tsx`
- [WebSocket client](https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/lib/socket.ts): `web/src/lib/socket.ts`
- [HTTP client](https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/lib/api.ts): `web/src/lib/api.ts`

### Live session engine

- [Session hub](https://github.com/daniyl-nguyen/crowdsense/blob/master/server/hub.ts): `server/hub.ts`
- [Live room](https://github.com/daniyl-nguyen/crowdsense/blob/master/server/room.ts): `server/room.ts`
- [Nudges and scoring](https://github.com/daniyl-nguyen/crowdsense/blob/master/shared/nudges.ts): `shared/nudges.ts`
- [Audience metrics](https://github.com/daniyl-nguyen/crowdsense/blob/master/shared/audience.ts): `shared/audience.ts`
- [Lost-moment detection](https://github.com/daniyl-nguyen/crowdsense/blob/master/shared/spikes.ts): `shared/spikes.ts`
- [Coaching thresholds](https://github.com/daniyl-nguyen/crowdsense/blob/master/shared/thresholds.ts): `shared/thresholds.ts`
- [Speech tracking](https://github.com/daniyl-nguyen/crowdsense/blob/master/server/speech.ts): `server/speech.ts`
- [Whisper transcription](https://github.com/daniyl-nguyen/crowdsense/blob/master/server/ai/whisper.ts): `server/ai/whisper.ts`

### Reports and replay

- [Report builder](https://github.com/daniyl-nguyen/crowdsense/blob/master/server/report.ts): `server/report.ts`
- [AI coaching](https://github.com/daniyl-nguyen/crowdsense/blob/master/server/ai/coach.ts): `server/ai/coach.ts`
- [Session report](https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/pages/Report.tsx): `web/src/pages/Report.tsx`
- [Synced replay](https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/pages/Replay.tsx): `web/src/pages/Replay.tsx`
- [Session timeline](https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/ui/Timeline.tsx): `web/src/ui/Timeline.tsx`
- [Recording upload](https://github.com/daniyl-nguyen/crowdsense/blob/master/web/src/rec/useRecorder.ts): `web/src/rec/useRecorder.ts`

### Persistence and services

- [Session repository](https://github.com/daniyl-nguyen/crowdsense/blob/master/server/db/repo.ts): `server/db/repo.ts`
- [Neon Postgres](https://github.com/daniyl-nguyen/crowdsense/blob/master/server/db/neon.ts): `server/db/neon.ts`
- [Recording storage](https://github.com/daniyl-nguyen/crowdsense/blob/master/server/storage.ts): `server/storage.ts`
- [Session routes](https://github.com/daniyl-nguyen/crowdsense/blob/master/server/routes/sessions.ts): `server/routes/sessions.ts`
- [Recording routes](https://github.com/daniyl-nguyen/crowdsense/blob/master/server/routes/recordings.ts): `server/routes/recordings.ts`
- [WebSocket server](https://github.com/daniyl-nguyen/crowdsense/blob/master/server/ws.ts): `server/ws.ts`
- [Account and access](https://github.com/daniyl-nguyen/crowdsense/blob/master/server/auth.ts): `server/auth.ts`
- [Optional review](https://github.com/daniyl-nguyen/crowdsense/blob/master/server/ai/review.ts): `server/ai/review.ts`

### Other components

- **Presenter and audience**

## Connections

- Presenter and audience → Presenter pipeline: speaks to
- Presenter pipeline → Presenter camera: analyzes frames (evidence: `web/src/vision/usePresenterPipeline.ts`)
- Presenter pipeline → Speech capture: captures speech (evidence: `web/src/vision/usePresenterPipeline.ts`)
- Presenter and audience → Audience camera: faces camera
- Camera views → Presenter pipeline: hosts pipeline
- Presenter pipeline → WebSocket client: sends metrics (evidence: `web/src/vision/usePresenterPipeline.ts`)
- Dashboard → WebSocket client: joins session
- Live monitor → WebSocket client: receives ticks
- Practice mode → Session hub: starts practice
- Phone reactions → WebSocket client: sends reactions
- WebSocket client → WebSocket server: exchanges messages (evidence: `web/src/lib/socket.ts`)
- WebSocket server → Session hub: dispatches messages (evidence: `server/ws.ts`)
- Session hub → Live room: creates rooms (evidence: `server/hub.ts`)
- Live room → Nudges and scoring: computes nudges (evidence: `server/room.ts`)
- Live room → Audience metrics: aggregates audience
- Live room → Lost-moment detection: detects spikes (evidence: `server/room.ts`)
- Live room → Coaching thresholds: applies thresholds (evidence: `server/room.ts`)
- Live room → Speech tracking: tracks speech (evidence: `server/room.ts`)
- Live room → Whisper transcription: transcribes audio (evidence: `server/room.ts`)
- Live room → Session repository: persists session data (evidence: `server/room.ts`)
- Session repository → Neon Postgres: stores records (evidence: `server/db/neon.ts`)
- Session routes → Session hub: finds sessions (evidence: `server/routes/sessions.ts`)
- Recording routes → Recording storage: handles recordings (evidence: `server/routes/recordings.ts`)
- Recording upload → HTTP client: uploads parts (evidence: `web/src/rec/useRecorder.ts`)
- HTTP client → Recording routes: requests recordings
- Live room → Report builder: builds final report
- Report builder → AI coaching: requests coaching
- Session report → HTTP client: loads report (evidence: `web/src/pages/Report.tsx`)
- Synced replay → HTTP client: loads replay data (evidence: `web/src/pages/Replay.tsx`)
- Synced replay → Session timeline: renders timeline (evidence: `web/src/pages/Replay.tsx`)
- Session report → Session timeline: renders timeline (evidence: `web/src/pages/Report.tsx`)
- Account and access → Session routes: protects access (evidence: `server/routes/sessions.ts`)
- Optional review → Recording storage: reads recordings (evidence: `server/ai/review.ts`)
- Optional review → AI coaching: reviews moments
