Skip to content
Strata v1.2.6

ADR-003: Dev vs Production Database Strategy

Status: Accepted
Date: 2024


Strata is a personal asset tracker. It stores real financial data (account balances, property values, loan amounts). The risk of accidentally modifying or deleting real data during development is unacceptable. At the same time, the development workflow benefits from rich, realistic seed data for testing UI components and API behaviour.


ApproachProsCons
Single DB fileSimple; no mistakes possibleRisk of seeding over real data
Two DB files: dev + prod (chosen)Complete isolation; docker:reset is always safeTwo files to document and manage
DB flag / schema separationOne fileComplex queries; risk of data leak between schemas

Two SQLite files, never mixed:

FileUsed whenContains
backend/.data/strata-dev.dbdocker:dev, docker:reset, automated testsSeeded demo data (BNP Checking, Livret A, Paris Apt, BNP Loan, Toyota, Kangoo)
backend/.data/strata.dbdocker:prod, Tauri desktop appReal user data — never touched by scripts

The active database is selected by the DB_FILE environment variable (default: strata-dev.db in development, strata.db in production). The docker-compose file reads this variable, and the NestJS DATABASE_URL is constructed at runtime from DB_FILE.


Demo seed data (prisma/seed.ts) is designed to be:

  • Realistic — asset names and values reflect a plausible European personal balance sheet
  • Complete — covers all supported asset types (checking, savings, real estate, loan, vehicles)
  • Positive and negative — includes a loan (liability) to demonstrate net worth = assets − liabilities
  • Idempotent — seeding twice does not duplicate data (upsert by unique fields)

Current demo assets (total net worth ≈ €239,200):

AssetTypeValue
BNP Compte CourantCHECKING_ACCOUNT€4,250
Livret ASAVINGS_ACCOUNT€22,950
Appartement ParisREAL_ESTATE€385,000
Crédit Immo BNPLOAN−€180,000
Toyota YarisVEHICLE€5,000
Renault KangooVEHICLE€2,000

CommandDB usedWhat happens
npm run docker:devstrata-dev.dbGenerates version (DEV), layer-cached build, starts Docker. Keeps existing dev DB (demo data + any manual additions).
npm run docker:resetstrata-dev.dbDestroys dev DB, rebuilds images from scratch, re-seeds fresh demo data. Use after migrations or when DB state is unknown.
npm run docker:prodstrata.dbProduction mode. Swagger disabled. Real data never touched by seed.

Real data (strata.db) is a portable SQLite file. Three backup mechanisms:

  1. File copy — copy backend/.data/strata.db anywhere (macOS Time Machine, cloud sync)
  2. JSON export — Settings → Export Backup in the frontend (exports all entities as JSON)
  3. JSON import — Settings → Import Backup in the frontend (replaces or merges data)

See the Backup & Recovery page for the complete procedure.


  • Developers can run docker:reset freely without fear of losing real data
  • The .data/ directory is git-ignored — no accidental commit of database files
  • Switching between dev and prod requires only changing the DB_FILE env var (or running the appropriate npm run command)
  • In the Tauri desktop app, the database lives in ~/Library/Application Support/Strata/strata.db (not in the repo)