Replace PGlite with embedded-postgres and add startup banner

Switch from PGlite (WebAssembly) to embedded-postgres for zero-config
local development — provides a real PostgreSQL server with full
compatibility. Add startup banner with config summary on server boot.
Improve server bootstrap with auto port detection, database creation,
and migration on startup. Update DATABASE.md, DEVELOPING.md, and
SPEC-implementation.md to reflect the change. Update CLI database
check and prompts. Simplify OnboardingWizard database options.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
Forgotten
2026-02-18 11:45:43 -06:00
parent 0d436911cd
commit cc24722090
18 changed files with 738 additions and 101 deletions

View File

@@ -2,9 +2,9 @@
Paperclip uses PostgreSQL via [Drizzle ORM](https://orm.drizzle.team/). There are three ways to run the database, from simplest to most production-ready.
## 1. Embedded (PGlite) — zero config
## 1. Embedded PostgreSQL — zero config
If you don't set `DATABASE_URL`, the server automatically starts an embedded PostgreSQL instance powered by [PGlite](https://pglite.dev/). No installation, no Docker, no setup.
If you don't set `DATABASE_URL`, the server automatically starts an embedded PostgreSQL instance and manages a local data directory.
```sh
pnpm dev
@@ -12,19 +12,14 @@ pnpm dev
That's it. On first start the server:
1. Creates a `./data/pglite/` directory for storage
2. Pushes the Drizzle schema to create all tables
3. Starts serving requests
1. Creates a `./server/data/embedded-postgres/` directory for storage
2. Ensures the `paperclip` database exists
3. Runs migrations automatically for empty databases
4. Starts serving requests
Data persists across restarts in the `./data/pglite/` directory. To reset the database, delete that directory.
Data persists across restarts in `./server/data/embedded-postgres/`. To reset local dev data, delete that directory.
**Limitations:**
- Single connection only (no concurrent access from multiple processes)
- Slower than native PostgreSQL (runs in WebAssembly)
- Not suitable for production
This mode is ideal for getting started, local development, and demos.
This mode is ideal for local development and one-command installs.
## 2. Local PostgreSQL (Docker)
@@ -116,11 +111,11 @@ See [Supabase pricing](https://supabase.com/pricing) for current details.
## Switching between modes
The database mode is controlled entirely by the `DATABASE_URL` environment variable:
The database mode is controlled by `DATABASE_URL`:
| `DATABASE_URL` | Mode |
|---|---|
| Not set | Embedded PGlite (`./data/pglite/`) |
| Not set | Embedded PostgreSQL (`./server/data/embedded-postgres/`) |
| `postgres://...localhost...` | Local Docker PostgreSQL |
| `postgres://...supabase.com...` | Hosted Supabase |

View File

@@ -19,14 +19,14 @@ pnpm dev
This starts:
- API server: `http://localhost:3100`
- UI: `http://localhost:5173`
- UI: served by the API server in dev middleware mode (same origin as API)
## Database in Dev (Auto-Handled)
For local development, leave `DATABASE_URL` unset.
The server will automatically use embedded PGlite and persist data at:
The server will automatically use embedded PostgreSQL and persist data at:
- `./data/pglite`
- `./data/embedded-postgres`
No Docker or external database is required for this mode.
@@ -49,10 +49,10 @@ Expected:
To wipe local dev data and start fresh:
```sh
rm -rf data/pglite
rm -rf server/data/embedded-postgres
pnpm dev
```
## Optional: Use External Postgres
If you set `DATABASE_URL`, the server will use that instead of embedded PGlite.
If you set `DATABASE_URL`, the server will use that instead of embedded PostgreSQL.

View File

@@ -42,7 +42,7 @@ These decisions close open questions from `SPEC.md` for V1.
| Auth | Session auth for board, API keys for agents |
| Budget period | Monthly UTC calendar window |
| Budget enforcement | Soft alerts + hard limit auto-pause |
| Deployment modes | Embedded PGlite default; Docker/hosted Postgres supported |
| Deployment modes | Embedded PostgreSQL default; Docker/hosted Postgres supported |
## 4. Current Baseline (Repo Snapshot)
@@ -50,7 +50,7 @@ As of 2026-02-17, the repo already includes:
- Node + TypeScript backend with REST CRUD for `agents`, `projects`, `goals`, `issues`, `activity`
- React UI pages for dashboard/agents/projects/goals/issues lists
- PostgreSQL schema via Drizzle with embedded PGlite fallback when `DATABASE_URL` is unset
- PostgreSQL schema via Drizzle with embedded PostgreSQL fallback when `DATABASE_URL` is unset
V1 implementation extends this baseline into a company-centric, governance-aware control plane.
@@ -86,13 +86,13 @@ V1 implementation extends this baseline into a company-centric, governance-aware
- `server/`: REST API, auth, orchestration services
- `ui/`: Board operator interface
- `packages/db/`: Drizzle schema, migrations, DB clients (Postgres and PGlite)
- `packages/db/`: Drizzle schema, migrations, DB clients (Postgres)
- `packages/shared/`: Shared API types, validators, constants
## 6.2 Data Stores
- Primary: PostgreSQL
- Local default: embedded PGlite at `./data/pglite`
- Local default: embedded PostgreSQL at `./server/data/embedded-postgres`
- Optional local prod-like: Docker Postgres
- Optional hosted: Supabase/Postgres-compatible
@@ -754,7 +754,7 @@ V1 is complete only when all criteria are true:
6. Budget hard limit auto-pauses an agent and prevents new invocations.
7. Dashboard shows accurate counts/spend from live DB data.
8. Every mutation is auditable in activity log.
9. App runs with embedded PGlite by default and with external Postgres via `DATABASE_URL`.
9. App runs with embedded PostgreSQL by default and with external Postgres via `DATABASE_URL`.
## 20. Post-V1 Backlog (Explicitly Deferred)