Status
Accepted (2026-12-02)
Context
The Fofo product specification defines a multi-surface pet-life platform:
- An Expo mobile app (iOS and Android) with five top-level tabs: Today, Health, Routine, Family, and You.
- A TanStack Start web app hosting the public landing page, the family web panel, the read-only veterinarian portal, the temporary pet-sitter view, the single-column Pro plan page, the public shelter transparency page, and the multi-tenant NGO web platform.
- A PostgreSQL database with Drizzle ORM, row-level security, object storage in R2, and scheduled background jobs.
The original architecture document mentions pg-boss for background jobs and standalone workers. This repository already ships a single-Worker Cloudflare deployment (ADR-0020), Effect-based scheduled jobs (packages/api/src/platform/jobs), Better Auth with Organizations, Drizzle + PostgreSQL 16+ RLS (app_tenant), R2 storage via files-sdk, and i18next catalogs (en, pt-BR, de, fr).
Decision
- Single Worker and monorepo feature shape. All Fofo backend domains (
pets,medications,pet-health,routine,care-links,pet-ai,shelters,ngo-panel) live underpackages/api/src/features/<feature>/following ADR-0011, ADR-0010 (Effect/Tier-1 procedures), and ADR-0009 (mandatory RLS withapp_tenantgrants). - Background jobs via Cron + Drizzle leases. Instead of
pg-boss, scheduled reminders, link expiration, stock warnings, and monthly transparency aggregation run on the template's Cron trigger and Drizzle lease pattern (ADR-0006). - Database and storage. Local development runs on PostgreSQL 19 (Docker) and private R2 (
fofo-dev). Production targets EU hosting (Frankfurt Neon + EU-jurisdiction R2) per ADR-0021. - Password hashing for Vet and Pet-Sitter links. Rather than native Argon2id bindings that fail in
workerd, 6-digit link PINs are hashed with Web Crypto PBKDF2-SHA256 (high iteration count + per-link random salt) so verification runs identically in Node and Cloudflare Workers. - Mocked payments in v1 local build. Billing pages and Pro entitlements match the product design (single-column paywall, 14-day trial, free core safety features, 10% subscription-share NGO selection) while persisting mocked entitlements locally without calling live Stripe or RevenueCat APIs until payment credentials are enabled.
- Non-negotiable product safety boundaries.
- Doses are plain prescription text copied by the caregiver; the codebase never calculates or suggests medication doses.
- Health warnings ("talk to your vet") and emergency triggers never provide medical diagnosis or triage.
- AI photo/voice capture only produces drafts that require explicit user confirmation before writing domain records.
- Direct shelter donations always open external NGO links/Pix outside the app; Fofo never processes or stores direct donation amounts.
Consequences
- Zero drift from repository boundary tests (
leaf-modules,feature-boundaries,rls-catalog,web-feature-boundaries,mobile-feature-boundaries,code-language). - All product surfaces share one type-safe oRPC contract and one PostgreSQL schema with strict tenant isolation.