Repository navigation
14. Performance
Database access: Task and client endpoints will support pagination and bounded filters. Calendar queries will retrieve only the requested date range. PostgreSQL indexes will be selected around query patterns, including tenant/client identifiers, task due dates and advisor event times. Query measurements will guide optimization, and connection pooling will limit database connection overhead.
Availability and task calculations: The availability engine will retrieve relevant busy intervals for the requested period, merge overlapping intervals, and calculate slots for the selected appointment duration. Task urgency will initially be calculated dynamically for the returned tasks. Caching or precomputation will be introduced only if measurements show a need.
Background processing: Calendar synchronization, AI generation and substantial reconciliation work will run outside ordinary dashboard requests. Persistent jobs will expose processing status, use timeouts and bounded retries, and prevent duplicate effects when retried. Lightweight FastAPI background tasks may support small operations; heavier or restart-sensitive work will use a worker and persistent job mechanism.
Frontend responsiveness: React and React Native interfaces will load bounded datasets and avoid unnecessary refetching and rendering. The dashboard will reuse task data between board and calendar views. Optimistic task updates will provide immediate feedback and roll back when the API rejects an operation. Loading and error states will remain visible during longer operations.
Concurrency and external services: Booking creation and rescheduling will use database transactions with an appropriate locking or constraint strategy to prevent overlapping bookings. External API calls will use timeouts and bounded concurrency. Calendar or AI service failures will not prevent advisors from accessing existing client and task records.