ADR-0011: PostgreSQL as SPIKE’s Backing Store
- Status:
- Superseded by ADR-0013: S3-Compatible Storage as SPIKE’s Backing Store
- Date: 2024-11-07
- History:
- 2024-11-04: Accepted
- 2024-11-07: Superseded by ADR-0013
- Tags: Database, Persistence, Storage, Backup
Context
SPIKE needs a reliable, secure, and performant backing store to maintain various types of encrypted data including:
- Root keys (encrypted with admin password)
- Admin tokens (encrypted with root key)
- Secrets (encrypted with root key)
The system requires:
- Strong data consistency and ACID transactions
- Support for binary data storage (for encrypted keys and secrets)
- Advanced data types and indexing capabilities
- Robust access control and security features
- Audit logging capabilities
- Schema management and version control
Decision
We will use PostgreSQL as the exclusive backing store for SPIKE, with SPIKE Nexus being the only client with direct database access.
Rationale
Security Features
- Native support for encryption at rest
- Fine-grained access control
- SSL support for encrypted connections
- Built-in audit logging capabilities
Data Integrity:
- ACID compliance
- Strong consistency model
- Native support for UUID, JSONB, and bytea types
- Constraints and triggers for data validation
Performance:
- Efficient indexing for binary and text data
- Good performance with both read and write operations
- Mature query optimizer
- Support for concurrent access
Operational Benefits:
- Wide industry adoption
- Extensive tooling ecosystem
- Strong community support
- Well-documented backup and recovery procedures
- Free and open-source
Consequences
Positive
- Simplified architecture with a single source of truth
- Reliable data persistence and consistency
- Built-in support for all required data types
- Easy integration with existing backup and monitoring tools
- No additional licensing costs
Negative
- Limited to PostgreSQL-specific features
- Team needs to maintain PostgreSQL expertise
- Single database deployment could be a bottleneck
- Migration complexity if database change is needed in future
Mitigations
- Use database-agnostic SQL where possible
- Implement connection pooling
- Plan for regular maintenance windows
- Document all PostgreSQL-specific features used
Implementation Notes
- SPIKE Nexus can use prepared statements to prevent SQL injection
- All sensitive data will be encrypted before storage
- Regular backups will be configured
- Monitor database performance metrics
- Implement connection pooling for scalability
Consequences
Positive
- Simplified architecture with a single source of truth
- Reliable data persistence and consistency
- Built-in support for all required data types
- Easy integration with existing backup and monitoring tools
- No additional licensing costs
Negative
- Limited to PostgreSQL-specific features
- Team needs to maintain PostgreSQL expertise
- Single database deployment could be a bottleneck
- Migration complexity if database change is needed in future
Mitigations
- Use database-agnostic SQL where possible
- Implement connection pooling
- Plan for regular maintenance windows
- Document all PostgreSQL-specific features used
Implementation Notes
- SPIKE Nexus will use prepared statements to prevent SQL injection
- All sensitive data will be encrypted before storage
- Regular backups will be configured
- Monitor database performance metrics
- Implement connection pooling for scalability
- ADR-0021: SPIKE Keeper as a Stateless Shard Holder
- ADR-0020: Switch to Zola for Documentation System
- ADR-0019: Plugin-Based Storage Backend Architecture
- ADR-0018: Administrative Access to SPIKE
- ADR-0017: Synchronous Persistence for SPIKE Secrets Store
- ADR-0016: Memory-First Secrets Store
- ADR-0015: Use Singular Form for File and Package Naming
- ADR-0014: Maintaining SQLite as SPIKE’s Primary Storage Backend
- ADR-0013: S3-Compatible Storage as SPIKE’s Backing Store
- ADR-0012: HTTP Methods for SPIKE API
- ADR-0011: PostgreSQL as SPIKE’s Backing Store
- ADR-0010: Session Token Storage Strategy for SPIKE Nexus
- ADR-0009: Multi-Administrator Support System
- ADR-0008: Administrative Access Control System
- ADR-0007: Root Key Lifecycle and Management Strategy
- ADR-0006: Trust Boundary Definition and Security Assumptions
- ADR-0005: Use SPIFFE mTLS for Inter-Component Authentication and Communication
- ADR-0004: SPIKE Keeper Minimalist Design Approach
- ADR-0003: Root Key Management and Storage Strategy
- ADR-0002: Use Docsify for Documentation System
- ADR-0001: Display Secrets in Plain Text in SPIKE Pilot Admin CLI