Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.encoreos.io/llms.txt

Use this file to discover all available pages before exploring further.

Purpose: Detailed reference material moved out of LOVABLE_CUSTOM_KNOWLEDGE.md to keep the main file under 300 lines. This file is NOT pasted into Lovable Custom Knowledge — reference it on demand when implementing CL/PM features or setting performance targets.

Table of Contents


Quick Reference

I need to…PatternLocation
Validate performance budgetLighthouse/Web Vitals + API p95 targetsPerformance Targets
Determine minimum test coverage expectationsFeature-type matrix (Unit/RLS/Integration/E2E)Testing Requirements
Apply DB table/index/soft-delete rulesTable categories, indexes, soft deleteDatabase Pattern Reference
Map Supabase/Postgres errors to user messagesError codes and retry rulesError Handling Reference
Use form layout, page templates, icon sizesResponsiveFormLayout, OverviewPageWrapper, icon scaleUI Component Patterns
Govern automations (FW, cron, webhooks)Circuit breaker, dry-run, loggingAutomation Governance
Find authoritative regulatory/source linksSpec-mapped external reference tableAuthoritative External References

Performance Targets

  • Lighthouse Performance: 85+, PWA: 90+
  • First Contentful Paint: < 2s
  • Largest Contentful Paint: < 2.5s
  • CLS: < 0.1
  • Time to Interactive: < 3.5s on 3G
  • API p95: < 500ms reads, < 2s writes
Mandatory patterns: Route code splitting (React.lazy), Suspense boundaries, skeleton loaders, QueryClient defaults (staleTime: 5min, gcTime: 10min), font optimization (max 2-3 families, font-display: swap), preconnect hints.

Testing Requirements

Feature TypeUnitRLSIntegrationE2E
Database schemaRequired
CRUD operations80%RequiredOptional
Business logic80%RequiredRequired
Critical flows80%RequiredRequiredRequired
  • Propose tests alongside code, not as TODO.
  • RLS tests verify tenant isolation.
  • No placeholder assertions (expect(true).toBe(true)).

Database Pattern Reference

Table category matrix: Determines which columns each table type requires.
Categorycustom_fieldsdeleted_atorganization_idsite_idAudit columns
Business EntityRequiredOptionalRequiredWhere applicableYes
TransactionRequiredNoRequiredWhere applicableYes
JunctionNoNoRequired (or via join)Where applicableOptional
AuditNoNoAs in sourceN/A
Config / ReferenceNoNoAs neededOptional
Module settingsNoNoRequiredOptionalYes
Index naming: idx_{core}_{entity}_org on organization_id; idx_{core}_{entity}_site partial on site_id WHERE site_id IS NOT NULL; index every FK column used in joins. Unique constraints should be explicitly named. Soft delete: Add partial unique index excluding soft-deleted rows if uniqueness is required on active rows. App queries: .is('deleted_at', null). Human-readable IDs: Use module-specific prefix + sequence or generation function; optional trigger for auto-fill. See .cursor/rules/database-patterns.mdc for full pattern. Module settings: Table {core}_module_settings (key, value, organization_id, etc.); admin UI at /{core}/settings; RLS: view for org users, insert/update for org_admin only; use set_updated_at trigger.

Error Handling Reference

Error code mapping (Supabase/Postgres):
CodeMeaningUser-facing message (sanitized)
PGRST116No rows returned”No matching records.” or context-specific empty state
42501Permission denied”You don’t have permission to perform this action.”
429Rate limitRetry with backoff; show “Please try again in a moment.”
23505Unique violation”A record with this value already exists.” or field-specific
23503FK violation”Cannot complete: related record missing or in use.”
Retry logic: Do not retry permission (42501) or validation errors. Retry network/transient failures with failureCount < 2 (e.g. in useQuery retry option). Use sanitizeErrorMessage(error) for all user-facing messages.

UI Component Patterns

Form layout: Use ResponsiveFormLayout for multi-field forms; columns 1/2/3, spacing sm/md/lg. Form actions: Cancel left, Submit right; disable submit while submitting; use descriptive button labels. Page templates: OverviewPageWrapper for module landing pages (supports pull-to-refresh, refreshQueryKeys). MobileTableWrapper for responsive tables. See docs/development/UI_UX_STANDARDS.md. Icon sizes: icon-xs (14px) through icon-lg (24px); icon-touch (44×44px) for icon-only buttons (touch target). See docs/development/ICON_GUIDE.md. Touch-safe actions: Actions must be always visible or in a clear control; no hover-only actions. Use CardActionsMenu for multiple actions on a card. Native dialogs (window.prompt, confirm, alert) are prohibited; use Dialog/AlertDialog/toast.

Automation Governance

Per constitution §12:
  • Approval: High-risk automations (bulk operations, external API writes, financial/clinical side effects) require explicit approval and dry-run testing.
  • Circuit breaker: After 5 consecutive failures, pause the automation and surface alert; do not retry indefinitely.
  • Logging: Use fw_automation_logs (or equivalent) for automation runs; log run id, status, error message, and timestamp.
  • Rate limits: Respect external API rate limits; use exponential backoff and queue where appropriate.
  • Dry-run: Where possible, support a dry-run mode that logs intended actions without executing them.

Authoritative External References (for AI Accuracy)

When implementing CL or PM features, prefer these authoritative sources over training data.
CategorySourceURLSpecs
SUD Confidentiality42 CFR Part 2 (eCFR — current)eCFR 42 CFR Part 2CL-11
SUD Confidentiality — Final Rule2024 Final Rule (compliance deadline: Feb 16, 2026)Federal Register 2024-02544CL-11
SUD Confidentiality Guidance42 CFR Part 2 HHS Fact SheetHHS Fact SheetCL-11
Prior AuthCMS-0057-FCMS-0057-F Final RulePM-10
AZ MedicaidAHCCCS AMPMAHCCCS AMPMCL-02 through CL-04, PM-07
AZ BH BillingAHCCCS CBHSGAHCCCS Covered BH Services GuidePM-07, PM-08
AccreditationJoint Commission CAMBHCJoint Commission CAMBHCCL-15
QualityNCQA HEDISNCQA HEDIS MeasuresCL-10, CL-15
OutcomesSAMHSA QualitySAMHSA Quality MeasurementCL-10
OutcomesSAMHSA NOMsSAMHSA NOMsCL-10
InteropHL7 US Core 7.0 (STU7; superseded by STU8)HL7 US Core STU7CL-16
BH FHIRUS BH Profiles IGUS Behavioral Health Profiles IGCL-16
Prior Auth FHIRDa Vinci PAS STU 2.1Da Vinci PAS STU2.1PM-10
Prior Auth FHIRDa Vinci CRD STU 2.0.1Da Vinci CRD STU2.0.1PM-10
Prior Auth FHIRDa Vinci DTR STU 2.0.1Da Vinci DTR STU2PM-10
Suicide RiskColumbia C-SSRSColumbia C-SSRSCL-07
DepressionPHQ ScreenersPHQ ScreenersCL-02, CL-07
SUD LOCASAM CriteriaASAM CriteriaCL-02
Full reference table with all URLs: see root AGENTS.md > Authoritative External References.