Build a fast local-first backend using Bun's built-in SQLite. CRUD API, migrations, full-text search, and WAL mode for concurrent reads.
## Task
Local-first backend using Bun's native SQLite bindings.
## Requirements
- Runtime: Bun (not Node.js)
- Database: Bun's built-in bun:sqlite
- HTTP: Bun.serve()
- Zero external dependencies
## Specifications
```typescript
import { Database } from "bun:sqlite";
// Features:
// 1. WAL mode for concurrent reads during writes
// 2. Prepared statements (reusable, faster)
// 3. Typed query results with generics
// 4. Migration system (SQL files in /migrations)
// 5. Full-text search using FTS5
// 6. Auto-backup every hour
// API:
// GET /api/notes → list (with FTS search via ?q=)
// POST /api/notes → create
// GET /api/notes/:id → read
// PUT /api/notes/:id → update
// DELETE /api/notes/:id → delete
// Performance targets:
// - Simple GET: <0.5ms
// - FTS search: <2ms for 100K records
// - Throughput: 50K requests/sec on single core
```
## Implementation Notes
1. Enable WAL: `db.exec("PRAGMA journal_mode = WAL")`
2. Use `db.prepare()` for all repeated queries — 10x faster than `db.query()`
3. FTS5: create virtual table, sync with triggers on main table
4. Migration runner: read SQL files sorted by timestamp, track applied in _migrations table
5. Transactions for multi-step operations
6. Graceful shutdown: checkpoint WAL before exitNo gallery images yet.