<!-- source: openspec/current/db/modules.md -->

---
title: DB — Modules
status: stable
owner: pavel
audience: [pavel, ai, engineer]
tldr: Module map for the db package — which source files export client, admin, types, and the barrel index, and who consumes them.
---
# DB — modules

> Part of openspec/current/db/ — split from db.md on 2026-05-12

## Module map

| Module | Path | Surface (exports) | Config deps | Used by |
|---|---|---|---|---|
| client | `src/client.ts` | `db` (singleton) | `supabase.url`, `supabase.anonKey` | — (no workspace consumer yet) |
| admin | `src/admin.ts` | `createAdminClient()` (factory) | `supabase.url`, `supabase.serviceRoleKey` | — (no workspace consumer yet) |
| types | `src/types.ts` | `Database`, `Json` | (none) | `packages/auth/src/supabase.ts:3`, `packages/auth/src/server.ts:1` (type-only) |
| index | `src/index.ts` | `db`, `createAdminClient`, `type Database` | (none) | barrel — re-exports the three modules above |

`Json` is exported from `types.ts` but **not re-exported by `index.ts`**. Consumers that need the recursive JSON type would need a new subpath export or an addition to the barrel — see `narrative.md § Open questions`.

Apps (`apps/web`, `apps/studio`) have **zero direct imports** of `@rapoport-studio/db`. They reach db transitively through `auth`.
