Designing a Concurrent Donation Ledger With FastAPI and PostgreSQL
Inside GoodCause’s Expo, FastAPI, PostgreSQL, Paystack, and RevenueCat architecture for processing donations and tracking campaign allocations.
GoodCause, a social impact crowdfunding platform, aimed to eliminate transparency issues by building a system that guarantees financial integrity, atomic fund distribution, and a seamless cross-platform mobile experience. The project employed React Native, FastAPI, and PostgreSQL to create an auditable impact ledger and ensure data integrity in concurrent donation scenarios.
The system architecture is built on three core principles: Mobile-First Delivery, Atomic Auditability, and Strict Data Isolation. The frontend is developed using React Native and Expo Router, while the backend utilizes Python FastAPI for domain-driven routing. Supabase provides the database (PostgreSQL) and Row-Level Security (RLS) policy enforcement, while the RevenueCat SDK manages subscriptions, and Paystack handles payment processing with webhook verification using HMAC-SHA512 signatures.
The main challenge was preventing race conditions and double-spending during concurrent donations and automated payouts. To address this, GoodCause implemented PostgreSQL Common Table Expressions (CTEs) as atomic SQL execution units. This approach executes all table updates within a single transaction block, ensuring no two processes can simultaneously alter the same data without proper coordination.
By storing currency values as 64-bit integers, GoodCause avoids floating-point arithmetic drift during aggregation, ensuring precise financial tracking. The system evaluates milestones and triggers automated notifications upon successful atomic verification, notifying organizers and campaign followers when specific progress thresholds are reached. The client-side implementation uses expo-secure-store for secure session token storage, preventing token leakage on jailbroken or rooted devices.
Written by urgent.news from HackerNoon's reporting — not their text. Machine-written — may contain errors; check the original before relying on it.