Phase 24.2: Database Layer & State Management#62
Merged
infinityabundance merged 5 commits intomainfrom Feb 14, 2026
Merged
Conversation
Co-authored-by: infinityabundance <255699974+infinityabundance@users.noreply.github.com>
Co-authored-by: infinityabundance <255699974+infinityabundance@users.noreply.github.com>
- Replace all string concatenation queries with parameterized queries - Fix SQL injection in user_model.cpp (createUser, loadByUsername, loadByEmail, save) - Fix SQL injection in stream_model.cpp (create, loadByStreamKey, save) - Fix SQL injection in event_store.cpp (appendEvent, createSnapshot) - Remove unimplemented pub/sub subscribe/unsubscribe methods from Redis client - Add clear warning to validatePassword placeholder - Document foreign key behavior in usage_logs table - Use DatabaseManager::executeParams for all user input Co-authored-by: infinityabundance <255699974+infinityabundance@users.noreply.github.com>
- Document SQL injection fixes - Add security review section - Note all vulnerabilities addressed - Update security considerations with status checkmarks Co-authored-by: infinityabundance <255699974+infinityabundance@users.noreply.github.com>
Copilot
AI
changed the title
[WIP] Implement comprehensive database and state management layer
Phase 24.2: Database Layer & State Management
Feb 13, 2026
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Implements PostgreSQL-backed persistence layer with Redis caching, event sourcing, and connection pooling for user accounts, stream metadata, sessions, and audit trails.
Details
What changed?
Database Schema (
src/database/schema.sql)Connection Manager (
src/database/database_manager.h/cpp)executeParams(prevents SQL injection)Redis Client (
src/cache/redis_client.h/cpp)Data Models (
src/database/models/)user_model: CRUD, authentication hooks, profile managementstream_model: Stream lifecycle (create, start/stop, viewer tracking), session analyticsEvent Store (
src/events/event_store.h/cpp)Security Hardening
Rationale
RootStream needs persistent state for user accounts, stream metadata, and billing while maintaining low-latency access patterns. PostgreSQL provides ACID guarantees for critical data (authentication, billing), while Redis caches hot data (session state, viewer counts) with sub-millisecond latency. Event sourcing enables complete audit trails and state reconstruction. Connection pooling eliminates per-query connection overhead. This aligns with RootStream's simplicity goal by providing a clean C++ API that abstracts database complexity.
Testing
make)Note: Build integration pending. Code compiles standalone but requires CMakeLists.txt updates to link libpqxx, hiredis, nlohmann-json.
Notes
find_package(libpqxx hiredis nlohmann_json))src/database/README.mdwith Docker Compose configOriginal prompt
PHASE 24.2: Database Layer & State Management
🎯 Objective
Implement a comprehensive database and state management layer that:
📋 Architecture Overview
🔨 Implementation Plan
1. PostgreSQL Schema Definition
File:
src/database/schema.sql