Architecture: How should data be organized between user data, agent data, ...

Documentation for Sessions

🏗️ Architecture: How should data be organized between user data, agent data, ...

Date: 2026-01-31
Time: 16:12:39 UTC
Session: editor2-75.16
Agent: backend
Confidence: 100%
Status: ✅ Documented


📋 Decision Context

Question:

How should data be organized between user data, agent data, and custom agent data in a multi-tenant AI platform?

Task: Session 75.15: Define multi-tenant data architecture for AI platform with custom agents support


🎯 Decision Made

Chosen:

Three-tier data segregation: (1) User Space databases for user-owned data, (2) Shared ai-agents database for platform agent operations, (3) Custom agent collections within user Space databases for user-created agents

Options Considered:

  1. Single shared database for everything
  2. Database-per-user only
  3. Three-tier segregation with Space databases

💭 Reasoning

THE GOLDEN RULE: User data NEVER lives in shared databases.

Data Architecture Overview

Tier 1: User Space Databases (space_{slug}_{id})

Tier 2: Shared AI-Agents Database (ai-agents / ai-mcp-dev)

Tier 3: Custom Agent Data (within user Space)

Routing Rules

  1. backend-ai-api → backend-api (HTTP): For ANY user-specific data

    • File uploads: POST /api/spaces/:spaceId/files/internal
    • Module operations: POST /api/spaces/:spaceId/modules
    • Universe operations: POST /api/spaces/:spaceId/universes
  2. backend-ai-api → MongoDB directly: ONLY for shared platform data

    • Handoff creation/updates
    • Decision logging
    • Agent status tracking

Why This Matters for Custom Agents

When users create custom agents:

This enables:


📁 Files Involved


🔗 Related


Auto-generated by MCP Smart Consolidation