ADR-0055: Rental module shares the platform Postgres database and Better Auth
Status
Accepted (2026-08-24)Tags
rental, architecture, better-auth, postgresql, multi-tenancy, product-boundary, adr-0006, adr-0054Decision
The rental platform’s Go module runs in the same Go backend, against the same shared PostgreSQL database and the same Better Auth deployment as the rest of the platform (crm, fieldforce, leave, etc.) — not a separate database or a separate auth deployment the way the standalone quiz app is (ADR-0054). Rental tables use therental_ prefix
(ADR-0021) for isolation. A B2C landlord is an ordinary row in the shared users
table with a global role token of landlord (not owner — see CONTEXT.md) and no
organization membership.
Why
The slice 1 design draft originally proposed “own Postgres database” for blast-radius isolation from B2B data, while also claiming to reuse Better Auth. Those claims conflict: ADR-0006 makes Go’s read ofusers/members a direct query against
the one physical database Better Auth owns, and the appProfiles config
(internal/shared/infrastructure/config/config.go) has no per-profile database field
at all — every existing profile already shares one Postgres instance. Real isolation
would mean building the same standalone pattern quiz uses (ADR-0054): its own Better
Auth deployment, its own users, its own database. Rental’s admin review queue, by
contrast, is meant to reuse the same platform admins and the existing /admin/*
panel patterns — which only works if identity is shared.
This is accepted as a conservative, repository-consistent default, not a proven
pattern: no existing module today serves an orgless (B2C) user, so the row-level
authorization path rental needs is new precedent, not reuse of something already
exercised in production.
Considered options
- Own Postgres database + own Better Auth deployment (quiz pattern, ADR-0054) — rejected for slice 1. Gives real isolation, but duplicates identity infrastructure for a feature whose admin side deliberately wants the same platform admins, and requires building multi-database plumbing the Go backend doesn’t have today.
- Own Postgres database, shared Better Auth — rejected: not physically possible without breaking ADR-0006, which assumes Go’s Better Auth table reads and a module’s own tables live in one shared database.
Consequences
- Landlord users live in the same
userstable as every other account on the platform;role = 'landlord'distinguishes them. - No module before rental has served an orgless user; expect to find (and fix) code
elsewhere that assumes
organization_idis always present as rental is built — the notifications module is one confirmed example (rental does not use it, see the slice 1 design doc). - A single account cannot hold both a platform-staff role and the
landlordrole in slice 1 (users.roleis single-valued). Acceptable — no product need for both today. - If a genuine compliance or scale reason to isolate B2C from B2B data emerges later, revisit this ADR deliberately rather than drifting into it.