Architecture: Where should the phone→user channel identity mapping live? v...
Documentation for Sessions
🏗️ Architecture: Where should the phone→user channel identity mapping live? v...
Date: 2026-02-20
Time: 20:06:32 UTC
Session: gspace1-129.6
Agent: backend
Confidence: 95%
Status: ✅ Documented
📋 Decision Context
Question:
Where should the phone→user channel identity mapping live? vitto-mind or backend-api?
Task: Session 129: Move channel identity to backend-api (correct data ownership)
🎯 Decision Made
Chosen:
backend-api (gograb-space database) as source of truth. UserChannelIdentity schema in @libs-api/backend-core, endpoint in backend-api UsersController, vitto delegates via BackendApiClientService REST calls.
Options Considered:
- No alternatives documented
💭 Reasoning
Initial implementation incorrectly placed ChannelUserLinkDoc in vitto-mind, creating a parallel user database. User identity MUST be owned by backend-api — it's the auth system, owns User/PlatformUser schemas, and all services can query it. Vitto storing its own phone→user mapping creates: (1) data segregation — web panel can't see channel links, (2) auth bypass — Vitto doing its own identity resolution, (3) consistency drift — if user changes account in backend-api, vitto-mind doesn't know. Corrected to: UserChannelIdentity schema in backend-core (shared), registered in backend-api's UsersModule, REST endpoints at /api/users/resolve-channel and /api/users/link-channel. Vitto's ChannelUserService now delegates to backend-api via BackendApiClientService with graceful fallback to anonymous mode if backend-api unreachable.
📁 Files Involved
libs/libs-api/backend-core/src/lib/schemas/user-channel-identity.schema.tslibs/libs-api/backend-core/src/index.tsapis/backend-api/src/app/users/users.service.tsapis/backend-api/src/app/users/users.controller.tsapis/backend-api/src/app/users/users.module.tsapis/backend-vitto-api/src/app/connectivity/channel-user.service.tsapis/backend-vitto-api/src/app/connectivity/backend-api-client.service.tsapis/backend-vitto-api/src/app/connectivity/connectivity.module.ts
🔗 Related
- Decision ID:
dev_1771617991935_uchrhe9 - Session: 129
- Workspace: gspace1
Auto-generated by MCP Smart Consolidation