Features Index
This directory contains 18 core features, each documented for both non-technical and technical audiences.
How to Read This Documentation
Every feature page follows the same structure:
# Feature Name
> One-liner for anyone
## What this enables
Plain-language bullets explaining business value
## How it works
Step-by-step workflow for non-technical users
---
## Technical Reference
[All technical details for developers]
- Database schema with indexes and RLS
- Complete API endpoint documentation
- Architecture decisions and trade-offs
- Code examplesReading guide:
- 👤 Non-technical folks: Read the top section (one-liner + "What this enables" + "How it works")
- 👨💻 Developers: Jump to Technical Reference section for schema, API, and implementation details
Browse All Features
auth/
Authentication & Users - User authentication, sessions, organization switching, Clerk integration
- Tables:
users,user_organizations - Endpoints:
/v1/me,/v1/me/switch-organization - Key concepts: Clerk auth, RLS session variables, organization context
organizations/
Organization Management - Organization CRUD, settings, API keys
- Tables:
organizations,organization_integrations - Endpoints:
/v1/organizations/* - Key concepts: Multi-tenancy root, slug-based lookup, API key management
Service Catalog & Scheduling
services/
Service Catalog - What the organization offers (procedures, therapies, consultations)
- Tables:
services,service_specialists,service_forms,service_attachments,service_plans,patient_service_plans,products,service_plan_products,patient_product_orders - Endpoints:
/v1/services/*,/v1/service-plans/*,/v1/products/*,/v1/patient-product-orders/* - Key concepts: Service catalog, three billing models (session_based, time_based, hybrid), access grants (telerehab_access, library_access), add-on services, products, product bundling with plans, standalone product sales
- Replaces:
appointment-templates(deprecated)
scheduling/
Calendars & Booking - When/how services can be booked
- Tables:
calendars,calendar_specialists,calendar_forms,specialist_weekly_hours,specialist_schedule_overrides,specialist_assignment_tracking - Endpoints:
/v1/calendars/*,/v1/calendars/{id}/timeslots,/v1/holds/* - Key concepts: Calendars (bookable units), availability engine, hold system (Redis), SSE streaming, timezone handling, campaign calendars with hour overrides
- Note: Calendars link to services; one service can have many calendars (default, campaigns, promotions)
appointments/
Appointment Management - What was booked (booking records + lifecycle)
- Tables:
appointments,appointment_files,appointment_reviews - Endpoints:
/v1/appointments/*,/v1/calendar - Key concepts: State machine (booked → upcoming → done), Daily.co integration, patient onboarding, service + calendar references, add-ons, reviews
Profile Management
patients/
Patient Profiles - Patient CRUD, onboarding, impersonation
- Tables:
patients - Endpoints:
/v1/patients/* - Key concepts: Onboarding flow, admin impersonation, profile management
specialists/
Specialist Profiles - Specialist CRUD, scheduling configuration
- Tables:
specialists,specialist_specialties - Endpoints:
/v1/specialists/* - Key concepts: Scheduling profile, timezone, weekly hours, date overrides
specialties/
Specialty Categories - Medical specialty definitions
- Tables:
specialties - Endpoints:
/v1/specialties/* - Key concepts: Specialty categorization, specialist associations
Data Collection System
custom-fields/
Versioned Field Library - Reusable, versioned field definitions for all entities
- Tables:
custom_fields,custom_field_versions,custom_field_values - Endpoints:
/v1/custom-fields/*,/v1/patients/{id}/profile,/v1/specialists/{id}/profile - Key concepts: Field library model, versioning (automatic propagation), system fields, profile data, entity attributes
- Architecture: Custom fields ARE the schema (forms reference them, not duplicate)
forms/
Dynamic Forms - Form templates (design) and instances (runtime filled forms)
- Tables:
form_templates,form_template_versions,forms - Endpoints:
/v1/form-templates/*,/v1/forms/* - Key concepts: Templates reference custom_field_id (no schema duplication), instances snapshot custom field versions (immutability), one-off fields (custom_field_id: null), auto-fill from profiles, lifecycle state machine
segments/
Patient Cohorts - Rules-based patient grouping from forms, profiles, and appointments
- Tables:
segments,segment_members,segment_versions - Endpoints:
/v1/segments/* - Key concepts: Multi-source rules (forms.values + custom_field_values + appointments), tiered evaluation, auto-update on data changes
Telerehabilitation
exercise-library/
Exercise Video Library — Global + org-scoped exercise library with video, taxonomy, and instructions
- Tables:
exercises,exercise_categories,exercise_body_regions,exercise_equipment,exercise_tags,exercise_instructions,exercise_contraindications - Endpoints:
/v1/exercises/*,/v1/exercise-categories/*,/v1/exercise-body-regions/*,/v1/exercise-equipment/* - Key concepts: Global + org dual-scope (org_id IS NULL = global), CDN-agnostic video (Bunny Stream / S3), full taxonomy (categories, body regions, equipment, difficulty, contraindications), soft delete, clone from global to org
- New RLS pattern:
organization_id IS NULLvisible to all authenticated users
treatment-plans/
Treatment Plans — Personalized rehabilitation programs with versioned exercise sessions
- Tables:
treatment_plans,treatment_plan_versions,treatment_plan_sessions,treatment_plan_session_exercises,patient_treatment_plans,patient_session_completions,patient_exercise_logs - Endpoints:
/v1/treatment-plans/*,/v1/treatment-plans/library,/v1/patient-treatment-plans/*,/v1/patient-session-completions/*,/v1/patient-exercise-logs/* - Key concepts: Three scopes (global/org/custom, same dual-scope pattern as exercises), telerehab + in-clinic types, versioning (JSONB snapshots), clone & promote flow, self-service library browsing (patients with
library_access), flexible frequency scheduling, approval workflow (configurable per org), guided session execution with timers, post-session questionnaires (forms integration), video watch tracking, optional MediaPipe pose detection, Telemetry analytics integration - Linked to service plans for access control:
telerehab_access(specialist-assigned) andlibrary_access(patient self-service)
Supporting Features
automations/
Lifecycle Workflows - Event-driven automation rules for patient and appointment lifecycle
- Tables:
automation_rules,automation_executions - Endpoints:
/v1/automations/rules/*,/v1/automations/executions/* - Key concepts: Trigger events (patient.onboarded, appointment.first_booked, etc.), actions (require_form, send_email, etc.), conditional execution, execution history
- Replaces: Hardcoded
template_policy_id/template_terms_idwith flexible automation rules
pdf-templates/
Visual PDF Designer - Block-based template editor for professional PDFs, chromedp rendering
- Tables:
pdf_templates,pdf_template_versions,pdf_template_components - Endpoints:
/v1/pdf-templates/*,/v1/pdf-template-components/* - Key concepts: Block-based editor, Go template syntax, component library (letterhead, footer, signature), versioning, live preview, forms integration
documents/
Reports & Prescriptions - PDF generation, digital signatures, templating
- Tables:
appointment_documents,appointment_document_files - Endpoints:
/v1/reports/*,/v1/prescriptions/* - Key concepts: PDF pipeline, template rendering, signature handling, caching
webhooks/
Webhook System - Org-scoped event subscriptions, delivery, retry logic
- Tables:
webhook_subscriptions,webhook_deliveries - Endpoints: Webhook management, event delivery
- Key concepts: Event catalog, signing, retry with backoff, idempotency
integrations/
External Services - Third-party API integrations, data migration
- Services: Daily.co (videocalls), AWS S3 (file storage)
- Key concepts: Cross-tenant isolation, org-scoped keys, meeting tokens, signed URLs, legacy migration
audit/
Audit Logging - Comprehensive audit trail for HIPAA/GDPR compliance
- Tables:
audit_log(local), forwarded to Telemetry PostgreSQL - Key concepts: Synchronous local write, asynchronous Telemetry forwarding, enrichment
- See ../telemetry/ for the full audit schema, media tracking, and video performance metrics
Quick Navigation
Finding a feature:
📋 Forms/Templates? → forms/ (templates + instances unified)
🏷️ Custom Fields/Profiles? → custom-fields/ (field library)
📅 Appointments/Booking? → services/, scheduling/, appointments/
🛍️ Service Catalog? → services/ (services, plans, products)
🏥 Specialists/Specialties? → specialists/, specialties/
📊 Segments/Grouping? → segments/
⚡ Automation/Workflows? → automations/ (lifecycle triggers & actions)
🎨 PDF Templates/Designer? → pdf-templates/
📄 PDF/Documents? → documents/
🔗 Webhooks/Events? → webhooks/
Exercise Library? → exercise-library/ (videos, taxonomy, instructions)
Treatment Plans/Telerehab? → treatment-plans/ (plans, sessions, patient execution)
Telemetry/Analytics? → ../telemetry/ (video performance, audit, analytics, pose tracking)
Cross-cutting concerns:
- See ../reference/ for RBAC, GDPR, encryption, scaling, etc.
- See ../telemetry/ for telemetry, compliance audit, and video performance tracking
Adding a New Feature
When adding a new feature, create a folder with:
features/my-feature/
├── README.md # Feature overview, key concepts
├── schema.sql # Tables, indexes, RLS policies
├── api.md # API endpoints with request/response
└── [feature-specific docs as needed]Template structure:
- README.md - What is this feature? Why does it exist?
- schema.sql - Database schema (copy from migration files)
- api.md - All endpoints, grouped logically
- Additional docs - Lifecycle, workflows, edge cases, performance
Update these files:
- This README (add to index)
- ../reference/database-overview.md (regenerate)
- ../reference/api-overview.md (regenerate)