The Interactive CD application now uses JSON files as the single source of truth instead of a database. This provides:
✅ Zero database queries - All data loaded at build time ✅ No database hosting costs - Save ~$5-20/month ✅ Ultra-fast page loads - Pre-rendered static HTML ✅ Version controlled data - All changes tracked in Git ✅ Simple deployment - Pure static files on CDN ✅ Easy local development - No database setup required
All practice data is stored in:
src/lib/data/cd-practices.json
This file contains:
- practices: All 51 CD practices with descriptions, requirements, benefits
- dependencies: All 89 practice dependencies
- metadata: Version, changelog, etc.
// src/infrastructure/persistence/FilePracticeRepository.js
import data from '$lib/data/cd-practices.json'
export const createFilePracticeRepository = () => ({
findById: async practiceId => {
/* ... */
},
findAll: async () => {
/* ... */
},
getTransitiveCategories: async practiceId => {
/* ... */
}
// ... other methods
})// src/routes/+page.js
export const prerender = true // ← Enables SSGAll routes and API endpoints are pre-rendered at build time.
Option A: Edit JSON directly
# Edit the JSON file manually
vim src/lib/data/cd-practices.json
# Commit changes
git add src/lib/data/cd-practices.json
git commit -m "feat: update practice descriptions"Option B: Use database for editing, then export
# 1. Update database with migrations
npm run db:migrate:local
# 2. Export to JSON
npm run db:export
# 3. Commit the exported JSON
git add src/lib/data/cd-practices.json
git commit -m "feat: add new practice dependencies"# No database needed!
npm run dev
# Opens at http://localhost:5173# Build static site
npm run build
# Preview production build
npm run previewThe build creates:
- Pre-rendered HTML pages
- Pre-rendered API JSON responses
- Optimized JavaScript bundles
- All static assets
# Netlify auto-deploys on git push
git push origin main
# Or manual deploy
netlify deploy --prodZero environment variables needed! No DATABASE_URL, no connection pooling, no database credentials.
Page Load Timeline:
1. Server starts (50ms)
2. HTML sent (100ms)
3. JavaScript loads (200ms)
4. API call to server (50ms)
5. Database query (100ms)
6. Render data (50ms)
───────────────────────
Total: ~550ms + network
Page Load Timeline:
1. HTML with data sent from CDN (20ms)
2. JavaScript loads (200ms)
3. Hydrate (50ms)
───────────────────────
Total: ~270ms
~50% faster! Plus instant subsequent loads from CDN cache.
Use the database → export workflow when you need:
- Complex data validation
- Referential integrity checks
- Migration-based updates
- Bulk updates
Edit JSON directly for:
- Simple text changes
- Adding/removing single items
- Quick fixes
- Documentation updates
npm run db:exportThis script:
- Connects to local PostgreSQL
- Exports all practices, dependencies, and metadata
- Formats as pretty JSON
- Saves to
src/lib/data/cd-practices.json - Shows summary (practices count, dependencies count, version)
{
"id": "continuous-delivery",
"name": "Continuous Delivery",
"type": "root",
"category": "practice",
"description": "...",
"requirements": ["...", "..."],
"benefits": ["...", "..."]
}{
"practice_id": "continuous-delivery",
"depends_on_id": "continuous-integration"
}{
"version": "1.5.0",
"source": "MinimumCD.org",
"lastUpdated": "2025-10-20",
"changelog": "..."
}Since data is version controlled:
# Rollback to previous version
git checkout HEAD~1 -- src/lib/data/cd-practices.json
git commit -m "revert: rollback practice changes"
git pushNetlify automatically rebuilds and deploys.
The migration has already been completed:
- ✅ Exported current database to JSON
- ✅ Created file-based repository
- ✅ Updated API routes to use files
- ✅ Enabled SSG (prerendering)
- ✅ Removed database from production dependencies
- ✅ Updated build process
Database is now optional - only needed if you prefer the database-first workflow for edits.
| Aspect | Before (Database) | After (File-Based) |
|---|---|---|
| First load | ~550ms | ~270ms (-50%) |
| Hosting cost | $5-20/month | $0 |
| Environment vars | DATABASE_URL needed | None |
| Local setup | Requires PostgreSQL | Just npm install |
| Deployment | Database + app | Static files only |
| Caching | Complex | Automatic CDN |
| Scalability | Limited by DB | Infinite (CDN) |
| Cold starts | Yes (serverless) | None (static) |
Potential improvements:
- GitHub Actions workflow to auto-export on DB changes
- Validation schema for JSON file
- TypeScript types generated from JSON
- Admin UI that edits JSON directly (no database)
- Automated JSON formatting/sorting
For issues or questions, see:
- Main README:
/README.md - Netlify deploy logs: Netlify dashboard
- Export script:
scripts/export-db-to-json.sh - Repository code:
src/infrastructure/persistence/FilePracticeRepository.js