- Postgres — Production web deployments (Neon, Vercel)
- SQLite — Desktop and local development
- InMemory — Testing and quick prototyping
Database Selection
The system automatically selects the database driver based on environment variables (drizzle.config.ts:1-26):Decision Logic
- If
DATABASE_URLis set → Use Postgres - If
ROUTA_DB_DRIVER=sqlite→ Use SQLite - Otherwise → Use InMemory
Postgres Configuration
Local Postgres
Neon Serverless (Recommended)
Neon provides serverless Postgres optimized for Next.js:- Create a Neon account at https://neon.tech
- Create a new project
- Copy the connection string
- Set environment variable:
Vercel Postgres
For Vercel deployments:- Install Vercel Postgres integration
- Connection string is automatically set as
DATABASE_URL - No additional configuration needed
Schema Management
SQLite Configuration
Local SQLite
Desktop (Tauri)
The Tauri desktop app uses SQLite by default:Schema Management
InMemory Mode
Useful for testing and development without persistence:Database Schema
Core Tables
Both Postgres and SQLite implement the same logical schema:- agents — Agent definitions and configurations
- conversations — Conversation history
- tasks — Task management and dependencies
- notes — Collaborative notes (CRDT-backed)
- workspaces — Workspace metadata
- codebases — Codebase registrations
- background_tasks — Background job queue
- schedules — Scheduled task definitions
Schema Files
src/core/db/schema.ts— Postgres schema (Drizzle)src/core/db/sqlite-schema.ts— SQLite schema (Drizzle)
Store Implementations
The RoutaSystem (src/core/routa-system.ts) provides three implementations:1. InMemory Stores
2. Postgres Stores
3. SQLite Stores
Docker Configuration
SQLite (Default)
Postgres
Create.env in project root:
Troubleshooting
Connection Errors
Migration Issues
Schema Drift
Performance Considerations
Postgres
- Connection pooling — Handled by Neon Serverless
- Prepared statements — Automatic via Drizzle
- Indexes — Defined in schema
SQLite
- WAL mode — Enabled by default for better concurrency
- Synchronous=NORMAL — Balance between safety and performance
- Temp store=MEMORY — Faster temp operations
Related Resources
- Dual Backend Architecture — Next.js vs Rust
- Testing Guide — Database testing strategies
- Drizzle ORM Docs — Official documentation