- Define SQLModel table models for AdminAllowlist, AdminAuditLog, Client, Service, Package, Booking, and Payment with foreign keys and strict validation. - Configure portable SQLModel create_engine in app/db/database.py supporting local SQLite and Turso Cloud (sqlite+libsql://) with PRAGMA foreign_keys = ON. - Provide get_session generator dependency for FastAPI routers. - Align ONE_ON_ONE service type to INDIVIDUAL across schema.sql, routers, seeds, and documentation. - Add unit tests for all models and database connectivity (75 tests passing). Refs: #6
2.4 KiB
2.4 KiB
ADR 0003: Mandatory Buffer Times and Recoverable Google Calendar Synchronization
Status
Accepted (Amended 2026-10-18)
Context
Discovery feedback from long-term clients revealed chronic 10-to-35-minute delays in therapy sessions caused by emotional consultation overruns and back-to-back scheduling without buffers. Additionally, Jasmin relies on Google Calendar to view her daily schedule on her phone, while armonia-api (backed by Turso) must remain the authoritative record of business state.
Decision
- Mandatory Post-Session Buffers: Every individual appointment (
INDIVIDUAL) enforces an unbookable 15-to-20-minute buffer interval immediately following the session. A 60-minute consultation blocks 75 minutes on the scheduling engine for anyRESERVEDbooking. - Backend-Owned Truth with Google Calendar Coordination:
armonia-apiowns the authoritative booking and payment decision in Turso; Google Calendar reflects the schedule:[PAGO PENDIENTE]whenbooking_status = 'RESERVED',payment_arrangement = 'PREPAID_DEFAULT', andpayment_status = 'AWAITING_ACKNOWLEDGMENT'.[PAGO DIFERIDO]whenbooking_status = 'RESERVED',payment_arrangement = 'DELAYED_ALLOWED', andpayment_status = 'AWAITING_ACKNOWLEDGMENT'.[CONFIRMADO]whenpayment_status = 'ACKNOWLEDGED'orpayment_arrangement = 'PACKAGE_REDEEMED'.- Event deleted/cancelled when
booking_statustransitions toRELEASEDorCANCELLED.
- Visible & Recoverable Integration State:
- Each booking stores
gcal_event_id,gcal_sync_status(PENDING,SYNCED,FAILED,NOT_CONFIGURED),gcal_sync_error, andgcal_synced_at. - If the Google Calendar API fails transiently, the Turso record is preserved with
gcal_sync_status = 'FAILED'and administrators can retry synchronization viaPOST /bookings/{id}/sync-calendar.
- Each booking stores
Consequences
Positive
- Prevents cascade delays across consultations and frees slots immediately when a booking is
RELEASED. - Prevents silent divergence between Turso and Google Calendar by surfacing
gcal_sync_statusandgcal_sync_errordirectly to the dashboard. - Works cleanly in local development and tests (
NOT_CONFIGUREDfallback when GCP credentials are absent).
Negative / Trade-offs
- Slightly reduces theoretical maximum daily capacity (e.g., maximum 5 sessions/day instead of 6) in exchange for punctuality and therapist well-being.