You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
2.9 KiB
2.9 KiB
+++ title = "Write docs/LOCAL_DEV.md — local dev quickstart (cargo run + trunk serve, rusqlite, DATABASE_URL)" priority = 5 status = "todo" ticket_type = "task" dependencies = ["33ed29"] +++
The `quotesdb` API is built with Axum + Tokio, targeting Cloudflare Workers via `workers-rs`. It serves JSON at `/api/*` endpoints and persists data to Cloudflare D1 (production) or a local SQLite file (development).TRIAGE 33ed29 resolved the local dev database strategy: plain rusqlite with a local SQLite file. No Turso, no wrangler, no Cloudflare account required for local development.
Selection is compile-time via cfg(target_arch = "wasm32"):
wasm32→ workers-rs D1 bindings (production)- native →
rusqlite+tokio-rusqlitewith a local.sqlitefile (dev/test)
The native main() (see ticket 6e829e) reads DATABASE_URL from the environment, defaulting to
./quotesdb.sqlite, and calls repo.run_migrations() on startup to create tables if they don't exist.
- Prerequisites — Rust (via Nix flake), no Cloudflare account needed
- Running the API:
cargo runfrom thequotesdb/directory- Listens on
localhost:3000 - Creates
./quotesdb.sqliteautomatically on first run - Override DB path:
DATABASE_URL=/path/to/db.sqlite cargo run
- Running the UI:
trunk servefrom thequotesdb/directory- Listens on
localhost:8080 - Proxies
/api/*tolocalhost:3000(see Trunk.toml[[proxy]]block)
- Environment variables:
DATABASE_URL— path to SQLite file (optional, default:./quotesdb.sqlite)- No other variables required for local dev
- Local dev workflow (two terminals):
# Terminal 1 — API cargo run # Terminal 2 — UI trunk serve # Open http://localhost:8080 - No wrangler required —
cargo runuses the native Axum server with rusqlite directly. Wrangler is only needed for Workers deployment (handled by CI/infra). - Database notes:
- Schema is applied automatically via
run_migrations()on firstcargo run - Delete
./quotesdb.sqliteto start fresh sqlite3 ./quotesdb.sqlitefor manual inspection
- Schema is applied automatically via