PostgreSQL Database
Feature Detail
Description
This feature establishes the PostgreSQL database infrastructure that persists all application data server-side. It covers the migration system for schema versioning, connection pool configuration for the Next.js backend, and automated backup infrastructure. The schema supports the full multi-tenancy model (organizations, regions, local associations), all 48 domain tables defined in the blueprint, and the role-based access structure. No vendor-specific PostgreSQL extensions are used — only standard SQL with migrations managed via a tool such as Drizzle ORM or node-postgres with custom migration scripts.
User Flow
Analysis
PostgreSQL is the single source of truth for all organizational data, member records, activity registrations, reimbursements, and reporting data that the partner organizations depend on for Bufdir grant reporting and operational management. Choosing a standard managed PostgreSQL instance without vendor lock-in ensures data portability and compliance with organizational data sovereignty requirements. A robust migration system is essential for maintaining schema correctness as features are added across phases, and connection pooling is necessary to support concurrent requests from both the mobile app and the admin panel without exhausting database connections.
The database is hosted as a managed PostgreSQL instance (e.g., Supabase Postgres, Neon, or Railway) with connection pooling via PgBouncer or the provider's built-in pooler. Schema migrations are version-controlled SQL files applied in sequence, tracked in a migrations table. The Next.js backend connects via node-postgres (pg) with a connection pool sized for the expected concurrent load. All 48 domain tables are created with appropriate indexes on foreign keys and commonly queried fields. Row-level security is not used — access control is enforced in the application layer via the REST API middleware. Automated daily backups with 30-day retention are configured at the provider level.
Components (59)
Shared Components
These components are reused across multiple features
User Interface (16)
Service Layer (13)
Data Layer (9)
Infrastructure (20)
User Stories
No user stories have been generated for this feature yet.