# prabhakaran-jm/stepclear architecture

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

- Interactive diagram: https://gitdiagram.com/prabhakaran-jm/stepclear
- Repository: https://github.com/prabhakaran-jm/stepclear

## Overview

StepClear is a Ring-camera accessibility agent. A resident selects a device, views its live stream, captures a frame, marks the accessible route, and explicitly requests analysis; the server validates the request, asks Bedrock to detect objects, and applies deterministic route-overlap geometry. The resident then reviews and resolves findings, with review metadata and the route stored locally. The graph also preserves Ring events and the optional video-processor dashboard. Some UI-to-API details are documented rather than visible in sampled excerpts, so those links are marked dashed where appropriate.

Main entry points: [`app/page.tsx`](https://github.com/prabhakaran-jm/stepclear/blob/main/app/page.tsx) (App dashboard), [`app/api/ring/stream/route.ts`](https://github.com/prabhakaran-jm/stepclear/blob/main/app/api/ring/stream/route.ts) (WHEP session endpoint), [`app/api/analyze/route.ts`](https://github.com/prabhakaran-jm/stepclear/blob/main/app/api/analyze/route.ts) (Analysis endpoint), [`app/api/ring/devices/route.ts`](https://github.com/prabhakaran-jm/stepclear/blob/main/app/api/ring/devices/route.ts) (Device endpoint)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Resident experience"]
  node_page["App dashboard<br/>[page.tsx]"]
  node_streamhook["Live stream hook<br/>[useWebRTCStream.ts]"]
  node_routeeditor["Route editor"]
  node_analysispanel["Analysis panel"]
end

subgraph group_ring["Ring integration"]
  node_ringauth["Ring authentication<br/>[auth.ts]"]
  node_ringconfig["Ring configuration<br/>[route.ts]"]
  node_devices["Device endpoint<br/>[route.ts]"]
  node_streamroute["WHEP session endpoint<br/>[route.ts]"]
  node_streamutils["Stream utilities<br/>[stream-utils.ts]"]
end

subgraph group_assessment["Route assessment"]
  node_zone["Route geometry<br/>[zone.ts]"]
  node_analyze["Analysis endpoint<br/>[route.ts]"]
  node_analysis["Detection validation<br/>[analysis.ts]"]
  node_obstruction["Overlap assessment<br/>[obstruction.ts]"]
end

subgraph group_events["Events and processors"]
  node_eventhook["Event stream hook<br/>[useEventStream.ts]"]
  node_eventpanel["Event panel<br/>[EventPanel.tsx]"]
  node_eventcard["Event card<br/>[EventCard.tsx]"]
  node_eventsroute["Event endpoint<br/>[route.ts]"]
  node_broadcast["Event broadcaster<br/>[sse-broadcast.ts]"]
  node_webhook["Webhook endpoint<br/>[route.ts]"]
  node_webhookschema["Webhook validation<br/>[webhook.ts]"]
  node_processors["Processor dashboard<br/>[ProcessorPanel.tsx]"]
  node_processinghook["Frame processing loop"]
  node_registry["Processor registry<br/>[registry.ts]"]
  node_processorindex["Built-in processors<br/>[index.ts]"]
  node_overlay["Canvas overlay"]
end

subgraph group_review["Human review"]
  node_reviewpanel["Review panel<br/>[ReviewPanel.tsx]"]
  node_review["Review workflow<br/>[review.ts]"]
  node_localstore[("Browser localStorage")]
end

node_resident(("Resident"))
node_bedrock{{"Amazon Bedrock"}}
node_ringapi{{"Ring Partner API"}}

node_resident -->|"uses"| node_page
node_page -->|"renders"| node_streamhook
node_page -->|"renders"| node_routeeditor
node_routeeditor -->|"validates route"| node_zone
node_page -->|"renders"| node_analysispanel
node_analysispanel -.->|"submits frame"| node_analyze
node_analyze -->|"validates request"| node_analysis
node_analyze -->|"requests detection"| node_bedrock
node_analyze -->|"assesses result"| node_obstruction
node_obstruction -->|"uses geometry"| node_zone
node_page -->|"renders"| node_reviewpanel
node_reviewpanel -->|"updates review"| node_review
node_reviewpanel -->|"reads and writes"| node_localstore
node_page -->|"fetches config"| node_ringconfig
node_ringconfig -->|"gets auth mode"| node_ringauth
node_page -.->|"loads devices"| node_devices
node_devices -->|"gets token"| node_ringauth
node_devices -->|"uses utilities"| node_streamutils
node_page -.->|"opens live view"| node_streamroute
node_streamroute -->|"gets token"| node_ringauth
node_streamroute -->|"uses utilities"| node_streamutils
node_streamroute -->|"manages WHEP session"| node_ringapi
node_streamhook -.->|"uses session"| node_streamroute
node_page -->|"loads events"| node_eventhook
node_page -->|"renders"| node_eventpanel
node_eventpanel -->|"renders cards"| node_eventcard
node_eventhook -.->|"subscribes"| node_eventsroute
node_eventsroute -->|"reads events"| node_broadcast
node_webhook -->|"validates payload"| node_webhookschema
node_webhook -->|"publishes event"| node_broadcast
node_page -->|"renders"| node_processors
node_page -->|"runs processing"| node_processinghook
node_processinghook -->|"gets processors"| node_registry
node_processorindex -->|"registers examples"| node_registry
node_page -->|"registers built-ins"| node_processorindex
node_page -->|"draws overlays"| node_overlay
node_overlay -->|"uses event types"| node_eventcard
node_overlay -.->|"draws results"| node_processinghook

click node_page "https://github.com/prabhakaran-jm/stepclear/blob/main/app/page.tsx"
click node_streamhook "https://github.com/prabhakaran-jm/stepclear/blob/main/app/hooks/useWebRTCStream.ts"
click node_routeeditor "https://github.com/prabhakaran-jm/stepclear/blob/main/app/components/RouteZoneEditor.tsx"
click node_zone "https://github.com/prabhakaran-jm/stepclear/blob/main/lib/zone.ts"
click node_analysispanel "https://github.com/prabhakaran-jm/stepclear/blob/main/app/components/RouteAnalysisPanel.tsx"
click node_analyze "https://github.com/prabhakaran-jm/stepclear/blob/main/app/api/analyze/route.ts"
click node_analysis "https://github.com/prabhakaran-jm/stepclear/blob/main/lib/analysis.ts"
click node_obstruction "https://github.com/prabhakaran-jm/stepclear/blob/main/lib/obstruction.ts"
click node_reviewpanel "https://github.com/prabhakaran-jm/stepclear/blob/main/app/components/ReviewPanel.tsx"
click node_review "https://github.com/prabhakaran-jm/stepclear/blob/main/lib/review.ts"
click node_ringauth "https://github.com/prabhakaran-jm/stepclear/blob/main/lib/auth.ts"
click node_ringconfig "https://github.com/prabhakaran-jm/stepclear/blob/main/app/api/ring/config/route.ts"
click node_devices "https://github.com/prabhakaran-jm/stepclear/blob/main/app/api/ring/devices/route.ts"
click node_streamroute "https://github.com/prabhakaran-jm/stepclear/blob/main/app/api/ring/stream/route.ts"
click node_streamutils "https://github.com/prabhakaran-jm/stepclear/blob/main/lib/stream-utils.ts"
click node_eventhook "https://github.com/prabhakaran-jm/stepclear/blob/main/app/hooks/useEventStream.ts"
click node_eventpanel "https://github.com/prabhakaran-jm/stepclear/blob/main/app/components/EventPanel.tsx"
click node_eventcard "https://github.com/prabhakaran-jm/stepclear/blob/main/app/components/EventCard.tsx"
click node_eventsroute "https://github.com/prabhakaran-jm/stepclear/blob/main/app/api/ring/events/route.ts"
click node_broadcast "https://github.com/prabhakaran-jm/stepclear/blob/main/lib/sse-broadcast.ts"
click node_webhook "https://github.com/prabhakaran-jm/stepclear/blob/main/app/api/webhook/route.ts"
click node_webhookschema "https://github.com/prabhakaran-jm/stepclear/blob/main/lib/schemas/webhook.ts"
click node_processors "https://github.com/prabhakaran-jm/stepclear/blob/main/app/components/ProcessorPanel.tsx"
click node_processinghook "https://github.com/prabhakaran-jm/stepclear/blob/main/lib/video-processors/useVideoProcessing.ts"
click node_registry "https://github.com/prabhakaran-jm/stepclear/blob/main/lib/video-processors/registry.ts"
click node_processorindex "https://github.com/prabhakaran-jm/stepclear/blob/main/lib/video-processors/index.ts"
click node_overlay "https://github.com/prabhakaran-jm/stepclear/blob/main/app/hooks/useCanvasOverlay.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_page,node_streamhook,node_routeeditor,node_analysispanel toneBlue
class node_ringauth,node_ringconfig,node_devices,node_streamroute,node_streamutils toneAmber
class node_zone,node_analyze,node_analysis,node_obstruction,node_ringapi toneMint
class node_eventhook,node_eventpanel,node_eventcard,node_eventsroute,node_broadcast,node_webhook,node_webhookschema,node_processors,node_processinghook,node_registry,node_processorindex,node_overlay toneRose
class node_reviewpanel,node_review,node_localstore,node_resident,node_bedrock toneIndigo
```

## Components

### Resident experience

- [App dashboard](https://github.com/prabhakaran-jm/stepclear/blob/main/app/page.tsx): `app/page.tsx`
- [Live stream hook](https://github.com/prabhakaran-jm/stepclear/blob/main/app/hooks/useWebRTCStream.ts): `app/hooks/useWebRTCStream.ts`
- [Route editor](https://github.com/prabhakaran-jm/stepclear/blob/main/app/components/RouteZoneEditor.tsx): `app/components/RouteZoneEditor.tsx`
- [Analysis panel](https://github.com/prabhakaran-jm/stepclear/blob/main/app/components/RouteAnalysisPanel.tsx): `app/components/RouteAnalysisPanel.tsx`

### Ring integration

- [Ring authentication](https://github.com/prabhakaran-jm/stepclear/blob/main/lib/auth.ts): `lib/auth.ts`
- [Ring configuration](https://github.com/prabhakaran-jm/stepclear/blob/main/app/api/ring/config/route.ts): `app/api/ring/config/route.ts`
- [Device endpoint](https://github.com/prabhakaran-jm/stepclear/blob/main/app/api/ring/devices/route.ts): `app/api/ring/devices/route.ts`
- [WHEP session endpoint](https://github.com/prabhakaran-jm/stepclear/blob/main/app/api/ring/stream/route.ts): `app/api/ring/stream/route.ts`
- [Stream utilities](https://github.com/prabhakaran-jm/stepclear/blob/main/lib/stream-utils.ts): `lib/stream-utils.ts`

### Route assessment

- [Route geometry](https://github.com/prabhakaran-jm/stepclear/blob/main/lib/zone.ts): `lib/zone.ts`
- [Analysis endpoint](https://github.com/prabhakaran-jm/stepclear/blob/main/app/api/analyze/route.ts): `app/api/analyze/route.ts`
- [Detection validation](https://github.com/prabhakaran-jm/stepclear/blob/main/lib/analysis.ts): `lib/analysis.ts`
- [Overlap assessment](https://github.com/prabhakaran-jm/stepclear/blob/main/lib/obstruction.ts): `lib/obstruction.ts`

### Events and processors

- [Event stream hook](https://github.com/prabhakaran-jm/stepclear/blob/main/app/hooks/useEventStream.ts): `app/hooks/useEventStream.ts`
- [Event panel](https://github.com/prabhakaran-jm/stepclear/blob/main/app/components/EventPanel.tsx): `app/components/EventPanel.tsx`
- [Event card](https://github.com/prabhakaran-jm/stepclear/blob/main/app/components/EventCard.tsx): `app/components/EventCard.tsx`
- [Event endpoint](https://github.com/prabhakaran-jm/stepclear/blob/main/app/api/ring/events/route.ts): `app/api/ring/events/route.ts`
- [Event broadcaster](https://github.com/prabhakaran-jm/stepclear/blob/main/lib/sse-broadcast.ts): `lib/sse-broadcast.ts`
- [Webhook endpoint](https://github.com/prabhakaran-jm/stepclear/blob/main/app/api/webhook/route.ts): `app/api/webhook/route.ts`
- [Webhook validation](https://github.com/prabhakaran-jm/stepclear/blob/main/lib/schemas/webhook.ts): `lib/schemas/webhook.ts`
- [Processor dashboard](https://github.com/prabhakaran-jm/stepclear/blob/main/app/components/ProcessorPanel.tsx): `app/components/ProcessorPanel.tsx`
- [Frame processing loop](https://github.com/prabhakaran-jm/stepclear/blob/main/lib/video-processors/useVideoProcessing.ts): `lib/video-processors/useVideoProcessing.ts`
- [Processor registry](https://github.com/prabhakaran-jm/stepclear/blob/main/lib/video-processors/registry.ts): `lib/video-processors/registry.ts`
- [Built-in processors](https://github.com/prabhakaran-jm/stepclear/blob/main/lib/video-processors/index.ts): `lib/video-processors/index.ts`
- [Canvas overlay](https://github.com/prabhakaran-jm/stepclear/blob/main/app/hooks/useCanvasOverlay.ts): `app/hooks/useCanvasOverlay.ts`

### Human review

- [Review panel](https://github.com/prabhakaran-jm/stepclear/blob/main/app/components/ReviewPanel.tsx): `app/components/ReviewPanel.tsx`
- [Review workflow](https://github.com/prabhakaran-jm/stepclear/blob/main/lib/review.ts): `lib/review.ts`
- **Browser localStorage**

### Other components

- **Resident**
- **Amazon Bedrock**
- **Ring Partner API**

## Connections

- Resident → App dashboard: uses
- App dashboard → Live stream hook: renders (evidence: `app/page.tsx`)
- App dashboard → Route editor: renders (evidence: `app/page.tsx`)
- Route editor → Route geometry: validates route (evidence: `app/components/RouteZoneEditor.tsx`)
- App dashboard → Analysis panel: renders (evidence: `app/page.tsx`)
- Analysis panel → Analysis endpoint: submits frame
- Analysis endpoint → Detection validation: validates request (evidence: `app/api/analyze/route.ts`)
- Analysis endpoint → Amazon Bedrock: requests detection
- Analysis endpoint → Overlap assessment: assesses result (evidence: `app/api/analyze/route.ts`)
- Overlap assessment → Route geometry: uses geometry (evidence: `lib/obstruction.ts`)
- App dashboard → Review panel: renders (evidence: `app/page.tsx`)
- Review panel → Review workflow: updates review (evidence: `app/components/ReviewPanel.tsx`)
- Review panel → Browser localStorage: reads and writes
- App dashboard → Ring configuration: fetches config (evidence: `app/page.tsx`)
- Ring configuration → Ring authentication: gets auth mode (evidence: `app/api/ring/config/route.ts`)
- App dashboard → Device endpoint: loads devices
- Device endpoint → Ring authentication: gets token (evidence: `app/api/ring/devices/route.ts`)
- Device endpoint → Stream utilities: uses utilities (evidence: `app/api/ring/devices/route.ts`)
- App dashboard → WHEP session endpoint: opens live view
- WHEP session endpoint → Ring authentication: gets token (evidence: `app/api/ring/stream/route.ts`)
- WHEP session endpoint → Stream utilities: uses utilities (evidence: `app/api/ring/stream/route.ts`)
- WHEP session endpoint → Ring Partner API: manages WHEP session
- Live stream hook → WHEP session endpoint: uses session
- App dashboard → Event stream hook: loads events (evidence: `app/page.tsx`)
- App dashboard → Event panel: renders (evidence: `app/page.tsx`)
- Event panel → Event card: renders cards (evidence: `app/components/EventPanel.tsx`)
- Event stream hook → Event endpoint: subscribes
- Event endpoint → Event broadcaster: reads events (evidence: `app/api/ring/events/route.ts`)
- Webhook endpoint → Webhook validation: validates payload (evidence: `app/api/webhook/route.ts`)
- Webhook endpoint → Event broadcaster: publishes event (evidence: `app/api/webhook/route.ts`)
- App dashboard → Processor dashboard: renders (evidence: `app/page.tsx`)
- App dashboard → Frame processing loop: runs processing (evidence: `app/page.tsx`)
- Frame processing loop → Processor registry: gets processors (evidence: `lib/video-processors/useVideoProcessing.ts`)
- Built-in processors → Processor registry: registers examples (evidence: `lib/video-processors/index.ts`)
- App dashboard → Built-in processors: registers built-ins (evidence: `app/page.tsx`)
- App dashboard → Canvas overlay: draws overlays (evidence: `app/page.tsx`)
- Canvas overlay → Event card: uses event types (evidence: `app/hooks/useCanvasOverlay.ts`)
- Canvas overlay → Frame processing loop: draws results
