Status
Accepted (2026-12-02)
Context
Fofo includes both a consumer Shelter Help hub (verified shelters, adoption showcase, weekly needs, external donations, Pro subscription share, public Transparency) and a free multi-tenant NGO web platform (verification, team roles, animals, adoption requests, visits, adopters, finance, needs, timeline, campaigns, supporters).
Strict legal and privacy rules apply (LGPD, GDPR/DSGVO, Apple App Review 3.2.2(iv), advertising disclosure rules):
- NGOs must be strictly isolated per Organization via PostgreSQL RLS.
- Adopter phone/email contact details require explicit per-field dated consent, are visible only to
adminandadoptionNGO roles, are never exported, are access-logged on every view, and disappear immediately upon withdrawal. - Direct donations never pass through Fofo; NGO finance records are explicitly labeled "registered by the NGO".
- Monthly subscription-share Transparency totals must reconcile exactly to
SHARE_PCTof net Pro revenue per country and month, and unverified NGOs must never receive payouts or publish listings.
Decision
- Tenant scoping. Every NGO operational table (
shelter_org,animal_listing,adoption_request,adopter_consent,adoption_visit,shelter_ledger_entry,shelter_need,shelter_campaign,supporter,supporter_consent,shelter_activity_post,shelter_alert) carriesorganization_idwith PostgreSQL RLS policies (app_tenant). Public read endpoints (verified shelter directory, published animal showcase, public transparency, public supporter gallery) query strictly filtered verified/published projections through auditedasSystemreasons registered inSystemReason. - Role-gated contact projection. NGO team members hold one of four roles (
admin,adoption,finance,volunteer). Server procedures strip adopter email/phone before serialization unless: (a) caller holdsadminoradoption, and (b) an active, non-withdrawnadopter_consentrow permits that exact field. Every contact read writes an audit entry. CSV/PDF exports never select contact columns. - Immutable consent and ledger history. Consent withdrawals insert a timestamped revocation record (
withdrawn_at) rather than deleting history; financial corrections append new ledger entries. - Transparency sum invariant. Monthly payout distribution uses integer minor units (cents) with deterministic remainder allocation so
sum(payout.amount_cents) === Math.round(net_revenue_cents * SHARE_PCT / 100)per(month, country), verified by automated unit and integration tests.
Consequences
- Cross-tenant leaks and unauthorized adopter-contact exposure are prevented at both the database (RLS) and service (role + consent check) layers.
- Public Transparency math is auditable and regression-tested on every test run.