How keeratipong4/agnos-patient-realtime-intake works
Agnos is a demo app for pairing a Patient intake form with a Staff live monitor through a shared session UUID. Staff sees field changes, focus and activity status, and can recover a snapshot after joining or reconnecting; submission locks the views. The main path is session creation, role-specific routes, Patient entry and validation, realtime synchronization, and Staff monitoring. Drafts are ephemeral rather than database-backed. Source excerpts show key route, hook, protocol, and UI relationships; unsampled capabilities are retained where the README documents them.
Main entry points: use-patient-sync.ts Patient sync · patient-form.tsx Intake form · use-staff-sync.ts Staff sync · page.tsx Patient route
Components 22
Session entry
- Launcher route
src/app/page.tsx - Session launcher
src/components/session-launcher.tsx - Patient route
src/app/patient/page.tsx - Staff route
src/app/staff/page.tsx - Session identity
src/lib/session.ts - Invalid session view
src/components/common/invalid-session.tsx
Patient intake
- Intake form
src/components/patient/patient-form.tsx - Form validation
src/lib/validations.ts - Form sections
src/components/patient/form-section.tsx - Field broadcaster
src/components/patient/patient-field-sync.tsx - Activity tracker
src/hooks/use-idle-tracker.ts - Vertical-slice demo
src/components/patient/patient-vertical-slice.tsx
Realtime sync
- Patient sync
src/hooks/use-patient-sync.ts - Staff sync
src/hooks/use-staff-sync.ts - Realtime protocol
src/lib/realtime-events.ts - Realtime client
src/lib/supabase.ts - Vertical-slice sync
src/hooks/use-patient-vertical-slice.ts
Staff monitoring
- Live monitor
src/components/staff/staff-monitor.tsx - Connection badge
src/components/common/status-badge.tsx
Other components
- Patient
- Staff
- Supabase Realtime
Connections 30
- Launcher route → Session launcher: renders
src/app/page.tsx - Patient → Session launcher: starts session
README.md - Session launcher → Patient route: links to
src/components/session-launcher.tsx - Session launcher → Staff route: links to
src/components/session-launcher.tsx - Patient route → Session identity: validates session
src/app/patient/page.tsx - Staff route → Session identity: validates session
src/app/staff/page.tsx - Patient route → Invalid session view: renders if invalid
src/app/patient/page.tsx - Staff route → Invalid session view: renders if invalid
src/app/staff/page.tsx - Patient route → Intake form: renders
src/app/patient/page.tsx - Staff route → Live monitor: renders
src/app/staff/page.tsx - Intake form → Form validation: validates with
src/components/patient/patient-form.tsx - Intake form → Form sections: renders
src/components/patient/patient-form.tsx - Intake form → Field broadcaster: renders
src/components/patient/patient-form.tsx - Intake form → Activity tracker: tracks activity
src/components/patient/patient-form.tsx - Intake form → Patient sync: synchronizes with
src/components/patient/patient-form.tsx - Field broadcaster → Patient sync: sends field changes
src/components/patient/patient-field-sync.tsx - Activity tracker → Patient sync: updates status
src/hooks/use-idle-tracker.ts - Patient sync → Session identity: names channel
src/hooks/use-patient-sync.ts - Staff sync → Session identity: names channel
src/hooks/use-staff-sync.ts - Patient sync → Realtime protocol: builds events
src/hooks/use-patient-sync.ts - Staff sync → Realtime protocol: validates events
src/hooks/use-staff-sync.ts - Patient sync → Realtime client: creates client
src/hooks/use-patient-sync.ts - Staff sync → Realtime client: creates client
src/hooks/use-staff-sync.ts - Patient sync → Supabase Realtime: broadcasts and tracks
src/hooks/use-patient-sync.ts - Staff sync → Supabase Realtime: listens and requests snapshots
src/hooks/use-staff-sync.ts - Live monitor → Staff sync: reads live state
src/components/staff/staff-monitor.tsx - Live monitor → Connection badge: renders
src/components/staff/staff-monitor.tsx - Staff → Live monitor: views intake
README.md - Vertical-slice demo → Vertical-slice sync: uses
src/components/patient/patient-vertical-slice.tsx - Vertical-slice sync → Patient sync: delegates to
src/hooks/use-patient-vertical-slice.ts