Architecture: Session 133: How was VittoChatEngineService decomposed to pr...
Documentation for Sessions
🏗️ Architecture: Session 133: How was VittoChatEngineService decomposed to pr...
Date: 2026-02-21
Time: 19:25:50 UTC
Session: gspace1-133.12
Agent: angular
Confidence: NaN%
Status: ✅ Documented
📋 Decision Context
Question:
Session 133: How was VittoChatEngineService decomposed to prevent service bloat?
Task: Not specified
🎯 Decision Made
Chosen:
Decompose into 6 focused services with single responsibilities
Options Considered:
- Keep one engine service and add all capabilities to it
- Decompose into 6 focused services with single responsibilities
💭 Reasoning
The existing VittoChatEngineService (306 lines) was already near the 300-line cap. Adding streaming, cost tracking, context detection, and model selection would push it to 600+ lines. Decomposed into: (1) VittoChatEngineService (<=250 lines) -- sendMessage(), streaming orchestration, memory recall. Delegates to other services internally. (2) VittoChatPersistenceService (<=200 lines, already existed) -- Session CRUD, IndexedDB + MongoDB dual persistence. (3) VittoChatCostService (51 lines) -- Token counting, model pricing table, per-message and session cost calculation. (4) VittoChatContextService (64 lines) -- Route-aware context detection via Router.events, system prompt enrichment. (5) VittoChatStreamingService (139 lines) -- SSE via fetch+ReadableStream, phase tracking signals. (6) VittoChatModelService (64 lines) -- Provider/model selection, available models list, model-by-provider grouping. INJECTION RULE: No component injects more than 3 services. Components inject the engine; the engine injects specialized services internally.
📁 Files Involved
- No files specified
🔗 Related
- Decision ID:
dev_1771701950269_serfjc9 - Session: 133
- Workspace: gspace1
Auto-generated by MCP Smart Consolidation