Architecture: Where should cross-API schemas and services live for the Two...

Documentation for Sessions

🏗️ Architecture: Where should cross-API schemas and services live for the Two...

Date: 2026-01-31
Time: 18:32:06 UTC
Session: editor2-75.18
Agent: backend
Confidence: 95%
Status: ✅ Documented


📋 Decision Context

Question:

Where should cross-API schemas and services live for the Two-Layer Agent Memory system?

Task: Session 75.15: Two-Layer Agent Intelligence & Preference Override System


🎯 Decision Made

Chosen:

Move schemas (UserAgentMemory, UserPreferences) and services (UserAgentService, UserPreferencesService) to @libs-api/backend-core shared library

Options Considered:

  1. Keep in backend-api only, have backend-ai-api call HTTP endpoints
  2. Duplicate code in both APIs
  3. Create new @libs-api/user-intelligence library
  4. Move to @libs-api/backend-core (chosen)

💭 Reasoning

Both backend-api and backend-ai-api need access to agent memories and user preferences. Duplicating code across APIs would violate DRY and cause maintenance nightmares. The shared library pattern already exists with auth-core, so this follows established conventions. Services are stateless and only depend on MongoDB models, making them safe to share. Controllers stay in individual APIs since they handle HTTP-specific logic.


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation