Data architecture
PostgreSQL 16. One database. Schema per bounded context: auth, social, expense, feed, media, notification, communication, messaging, and kong. Init SQL is splick-backend/infra/db-init. Each service sets search_path / Flyway schemas to its own schema.
PgBouncer pools connections. Hikari pool sizes are per service (*_HIKARI_MAXIMUM_POOL_SIZE). Alerts fire on pool exhaustion, slow acquire, Postgres connection count, and PgBouncer client waits.
Ownership
- Tables are created only by Flyway in the owning service.
- Another service never writes those tables.
- Projections (
social.user_projection,messaging.user_projection,feedfriend-derived activity) are rebuilt from events, not from a live join. - The relay is granted read/write on producer
event_outboxtables because publishing is centralized. That is the one deliberate cross-schema writer, and it only touches outbox columns.
Object storage
Media bytes are not in Postgres. media-service stores objects in R2 and rows in media.media_object. Public URLs use SHARED_MEDIA_PUBLIC_BASE_URL.
Backup
Production backups use WAL-G to R2, operated by manage.sh backup. Restore is an explicit ops action. See Backup and restore. Do not copy backup credentials into this site.