Instruction file imported from dannyzia/carenet2 (
.github/instructions/backend-services.instructions.md). Copyright stays with the author.
You are working on the backend service layer for CareNet 2.
- Use
sbRead,sbWrite,sb, andcurrentUserIdfromsrc/backend/services/_sb.tsfor all Supabase operations. Do not duplicate query boilerplate. - Preserve all
USE_SUPABASEmock fallback branches. Never remove them. - Use
supabase.channel(...).on('postgres_changes', ...)for realtime subscriptions. - Always clean up channels and listeners on component unmount or hook teardown.
- Write flows that must survive disconnects should route through the Dexie queue in
src/backend/offline/. - Check
supabase/functions/andsupabase/migrations/before changing behavior that depends on them. - Keep conflict-prone flows retry-safe and idempotent.
- Do not introduce Firebase, Prisma, TanStack Query, or any alternative data layer.