DeploymentInfrastructure
Database Setup
Database Setup
PostgreSQL configuration for production
Requirements
- PostgreSQL: 16+ (LTS recommended)
- TimescaleDB: 2.x (for time-series events)
- pgvector: Latest (for semantic search)
Installation
Managed Services
- Supabase: Managed PostgreSQL with extensions
- Railway: Easy deployment with PostgreSQL
- AWS RDS: Enterprise-grade managed PostgreSQL
- Any PostgreSQL 14+: Cloud, managed, or self-hosted
Self-Hosted
Current Architecture
Synap uses a pure PostgreSQL 14+ approach with two complementary database clients:
Database Clients
postgres.js
- Purpose: Connection management and raw SQL queries
- Use For: Complex queries, PostgreSQL-specific features, performance-critical operations
Drizzle ORM
- Purpose: Type-safe query building and schema management
- Use For: CRUD operations, schema definitions, type-safe queries
Why Both?
- Flexibility: Raw SQL for complex queries, ORM for simple operations
- Performance: postgres.js is one of the fastest PostgreSQL clients
- Type Safety: Drizzle provides full TypeScript support
- Cost Control: Works with any PostgreSQL 14+ provider
Compatible With:
- Supabase
- Railway
- AWS RDS
- Google Cloud SQL
- Self-hosted PostgreSQL
- Any PostgreSQL 14+ provider
Configuration
Enable Extensions
Create Hypertable
Performance Tuning
Connection Pooling
Query Optimization
Indexes
Backup Strategy
Automated Backups
Point-in-Time Recovery
Configure WAL archiving for point-in-time recovery:
Monitoring
Key Metrics
- Connection pool usage
- Query performance
- Table sizes
- Index usage
- Replication lag (if applicable)
Next: See Storage Setup for file storage configuration.
