Architecture: In which MongoDB database/collection should all chat session...
Documentation for Sessions
🏗️ Architecture: In which MongoDB database/collection should all chat session...
Date: 2026-03-03
Time: 15:50:22 UTC
Session: gspace1-166.5
Agent: backend
Confidence: 95%
Status: ✅ Documented
📋 Decision Context
Question:
In which MongoDB database/collection should all chat sessions (Panel + Vitto) be stored?
Task: Session 166.3: Chat storage database decision
🎯 Decision Made
Chosen:
Keep all chat sessions in
ai-agentsdatabase,chat_sessionscollection (existing). Both Panel and Vitto chats use the same collection, differentiated by thesourcefield ('panel' | 'vitto' | 'embedded' | etc.) andspaceIdfor multi-space scoping.
Options Considered:
- Keep in ai-agents.chat_sessions (current)
- Move to new dedicated chat-persistence database
- Move to vitto-mind alongside Vitto engine data
- Split active/archived across ai-agents and ai-archive
💭 Reasoning
4 alternatives evaluated: (1) Keep in ai-agents.chat_sessions — already works, ai-agents is the AI data hub (29 collections, 256 indexes), no migration needed; (2) Dedicated database — overkill, adds connection overhead for no benefit; (3) Move to vitto-mind — wrong cluster (vitto.urgh6ow.mongodb.net vs gograbspace.dgqij2t.mongodb.net), would require cross-cluster queries; (4) Split active/archived across ai-agents/ai-archive — adds query complexity for the same data type. The status field index (active/archived/cold) on the same collection achieves tier separation without cross-database joins. The conversation_genomes data is embedded in each session document (genome field) rather than a separate collection, keeping queries simple. ai-agents is already the established hub for AI operational data (decisions, embeddings, agent memories), and chat sessions are AI operational data. The ai-memory database (175MB) stores user long-term memories — different concern. The ai-archive database (16KB) exists but is essentially empty and better reserved for bulk cold storage in the future.
📁 Files Involved
APIs/backend-ai-api/src/app/sessions/sessions.schema.tsAPIs/backend-ai-api/src/app/sessions/sessions.module.tslibs/libs-api/backend-core/src/lib/config/database-names.config.ts
🔗 Related
- Decision ID:
dev_1772553022409_6kxyphy - Session: 166
- Workspace: gspace1
Auto-generated by MCP Smart Consolidation