Architecture: How should Vitto know the user's identity (name, email, role...
Documentation for Sessions
🏗️ Architecture: How should Vitto know the user's identity (name, email, role...
Date: 2026-02-11
Time: 22:16:16 UTC
Session: gspace1-105.2
Agent: backend
Confidence: 92%
Status: ✅ Documented
📋 Decision Context
Question:
How should Vitto know the user's identity (name, email, role, etc.) for personalized responses?
Task: Enhance Vitto user knowledge and memory
🎯 Decision Made
Chosen:
Two-layer: frontend passes name/email + backend does full profile lookup from MongoDB
Options Considered:
- Only use agent memories (existing approach)
- Pass user profile from frontend auth via API request
- Backend-only: look up user profile from MongoDB by userId
- Two-layer: frontend passes name/email + backend does full profile lookup from MongoDB
💭 Reasoning
The existing approach only loaded abstract agent memories (preferences, skills, facts) but never fetched the actual user profile. This meant Vitto couldn't greet users by name, reference their role, subscription tier, or account age. The two-layer approach provides: (1) Frontend passes userName/userEmail as hints (fast, available from auth state), (2) Backend does a full MongoDB lookup by userId to get name, email, roles, subscriptionTier, spaces, createdAt, lastLoginAt — giving Vitto complete identity context. The backend lookup is authoritative; frontend hints serve as fallback if the DB query fails. Both VittoChatService (VittoHub inline chat) and VittoChatEngineService (chat shell) now pass identity through to /ai-api/chat.
📁 Files Involved
apis/backend-ai-api/src/app/chat/chat.service.tsapis/backend-ai-api/src/app/chat/chat.controller.tsapis/backend-ai-api/src/app/shared/user-agent-memory.module.tslibs/libs-ai/vitto-chat/src/lib/services/user-context.service.tslibs/libs-ai/vitto-chat/src/lib/services/vitto-chat-engine.service.tslibs/libs-ai/vitto-chat/src/lib/components/chat-shell/chat-shell.component.tslibs/libs-ai/gograb-ai-lib/src/lib/services/vitto-chat.service.tslibs/libs-ai/gograb-ai-lib/src/lib/components/vitto-hub/vitto-hub.component.ts
🔗 Related
- Decision ID:
dev_1770848176912_29l4ndf - Session: 105
- Workspace: gspace1
Auto-generated by MCP Smart Consolidation