MongoDB New Architecture Design

Target architecture for GoGrab Space MongoDB infrastructure with AI optimization

MongoDB New Architecture Design

Purpose: Define the complete target architecture for GoGrab Space MongoDB infrastructure.


πŸ“‹ Architecture Overview

System Diagram

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                              GOGRAB SPACE                                   β”‚
β”‚                                                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚                         FRONTEND LAYER                                β”‚  β”‚
β”‚  β”‚                                                                       β”‚  β”‚
β”‚  β”‚   gograb-space (:5200)  β”‚  space-admin (:5300)  β”‚  gograb-admin      β”‚  β”‚
β”‚  β”‚                         β”‚                        β”‚  (:4300)           β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                   β”‚                                                         β”‚
β”‚                   β–Ό                                                         β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚                         API GATEWAY LAYER                             β”‚  β”‚
β”‚  β”‚                      (Future: Kong/Nginx)                             β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                   β”‚                             β”‚                           β”‚
β”‚        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”       β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”               β”‚
β”‚        β–Ό                     β”‚       β–Ό                     β”‚               β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚               β”‚
β”‚  β”‚  backend-api     β”‚        β”‚ β”‚  backend-ai-api  β”‚        β”‚               β”‚
β”‚  β”‚  :3000           β”‚        β”‚ β”‚  :3001           β”‚        β”‚               β”‚
β”‚  β”‚                  β”‚        β”‚ β”‚                  β”‚        β”‚               β”‚
β”‚  β”‚  Core Platform   β”‚        β”‚ β”‚  AI Platform     β”‚        β”‚               β”‚
β”‚  β”‚  β€’ spaces        β”‚        β”‚ β”‚  β€’ agents        β”‚        β”‚               β”‚
β”‚  β”‚  β€’ widgets       β”‚        β”‚ β”‚  β€’ intelligence  β”‚        β”‚               β”‚
β”‚  β”‚  β€’ themes        β”‚        β”‚ β”‚  β€’ learning      β”‚        β”‚               β”‚
β”‚  β”‚  β€’ users         β”‚        β”‚ β”‚  β€’ memory        β”‚        β”‚               β”‚
β”‚  β”‚  β€’ ecommerce     β”‚        β”‚ β”‚  β€’ generation    β”‚        β”‚               β”‚
β”‚  β”‚  β€’ singularity   β”‚        β”‚ β”‚  β€’ assistant     β”‚        β”‚               β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜        β”‚               β”‚
β”‚           β”‚                  β”‚          β”‚                  β”‚               β”‚
β”‚           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β”‚
β”‚                              β”‚                                              β”‚
β”‚                              β–Ό                                              β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚                      MONGODB ATLAS CLUSTER                            β”‚  β”‚
β”‚  β”‚                         (M30 Production)                              β”‚  β”‚
β”‚  β”‚                                                                       β”‚  β”‚
β”‚  β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚
β”‚  β”‚   β”‚                     DATA NODES                                 β”‚  β”‚  β”‚
β”‚  β”‚   β”‚     Primary ────────── Secondary ────────── Secondary         β”‚  β”‚  β”‚
β”‚  β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
β”‚  β”‚                                                                       β”‚  β”‚
β”‚  β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚  β”‚
β”‚  β”‚   β”‚                   SEARCH NODES (Optional)                      β”‚  β”‚  β”‚
β”‚  β”‚   β”‚     S30 Node 1 ────────────────────────── S30 Node 2          β”‚  β”‚  β”‚
β”‚  β”‚   β”‚     (Vector Search Isolation - Add when needed)               β”‚  β”‚  β”‚
β”‚  β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚  β”‚
β”‚  β”‚                                                                       β”‚  β”‚
β”‚  β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚  β”‚
β”‚  β”‚   β”‚gograb-  β”‚ β”‚gograb-  β”‚ β”‚gograb-ai-   β”‚ β”‚gograb-ai-           β”‚   β”‚  β”‚
β”‚  β”‚   β”‚api      β”‚ β”‚agents   β”‚ β”‚memory       β”‚ β”‚tenants              β”‚   β”‚  β”‚
β”‚  β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ—„οΈ Database Design

Database: gograb-api (Core Platform)

Purpose: Core platform data for spaces, widgets, themes, etc.

Used by: backend-api

// Collections
{
  "spaces": {
    // Space definitions
    indexes: ["tenantId", "status", "createdAt"]
  },
  "widgets": {
    // Widget catalog
    indexes: ["spaceId", "type", "status"]
  },
  "modules": {
    // Module catalog
    indexes: ["spaceId", "type", "status"]
  },
  "themes": {
    // Theme definitions
    indexes: ["tenantId", "isDefault"]
  },
  "universes": {
    // Universe configurations
    indexes: ["spaceId", "status"]
  }
}

Database: ai-agents (AI Orchestration)

Purpose: Agent runtime operations and session management

Used by: backend-ai-api/agents

// Collection: sessions
{
  "_id": ObjectId,
  "sessionId": "session_abc123",
  "tenantId": "tenant_xyz",
  "agentId": "cursor-angular-agent",
  "status": "active",  // active, paused, completed
  "startedAt": ISODate,
  "lastActivityAt": ISODate,
  "metadata": {
    "type": "cursor",
    "sessionNumber": 7,
    "sessionID": "7.7"
  }
}
// Indexes: tenantId, status, lastActivityAt

// Collection: decisions
{
  "_id": ObjectId,
  "decisionId": "dev_1765513398060_yghb99h",
  "sessionId": "session_abc123",
  "agentId": "cursor-angular-agent",
  "type": "implementation",  // architecture, implementation, refactor, bugfix
  "question": "How to structure the component?",
  "chosen": "Signal-based state management",
  "confidence": 0.95,
  "timestamp": ISODate,
  "outcome": {
    "wasSuccessful": true,
    "feedback": "Works perfectly"
  }
}
// Indexes: sessionId, agentId, timestamp, type

// Collection: tasks
{
  "_id": ObjectId,
  "taskId": "task_123",
  "userId": "user_abc",
  "tenantId": "tenant_xyz",
  "goal": "Create new component",
  "status": "in_progress",
  "steps": [...],
  "createdAt": ISODate,
  "updatedAt": ISODate
}
// Indexes: userId, tenantId, status, createdAt

// Collection: agent_state
{
  "_id": ObjectId,
  "agentId": "cursor-angular-agent",  // unique
  "status": "idle",
  "currentTaskId": null,
  "isolatedMemory": [...],
  "lastUpdated": ISODate
}
// Indexes: agentId (unique)

Database: ai-memory (AI Learning)

Purpose: Vector embeddings, patterns, and AI memory

Used by: backend-ai-api/memory, backend-ai-api/intelligence

⚠️ Vector-heavy - Primary candidate for Search Nodes

// Collection: embeddings
{
  "_id": ObjectId,
  "content": "Original text that was embedded",
  "contentType": "decision",  // decision, pattern, document
  "embedding": [...],  // 1536-dim vector (float32 or int8)
  "metadata": {
    "agentId": "cursor-angular-agent",
    "taskType": "implementation",
    "qualityRating": 4.5,
    "wasSuccessful": true,
    "tenantId": "tenant_xyz"
  },
  "createdAt": ISODate
}
// Vector Index: embedding (1536 dims, cosine similarity)
// Regular Indexes: contentType, metadata.agentId, metadata.tenantId

// Collection: patterns
{
  "_id": ObjectId,
  "patternId": "pattern_123",
  "name": "Signal-based State Pattern",
  "description": "Use Angular Signals for component state",
  "whenToUse": "When managing local component state",
  "implementation": "...",
  "embedding": [...],  // Vector for similarity search
  "successRate": 0.95,
  "usageCount": 42,
  "lastUsed": ISODate
}
// Vector Index: embedding
// Regular Indexes: successRate, usageCount

// Collection: context_cache
{
  "_id": ObjectId,
  "key": "preflight:user123:angular",
  "context": {...},
  "createdAt": ISODate,
  "expiresAt": ISODate  // TTL index
}
// Indexes: key (unique), expiresAt (TTL)

// Collection: calibrations
{
  "_id": ObjectId,
  "modelId": "claude-3-opus",
  "calibrationData": {...},
  "performance": {
    "accuracy": 0.92,
    "latency": 150
  },
  "updatedAt": ISODate
}
// Indexes: modelId, updatedAt

Database: gograb-ai-tenants (Personalization)

Purpose: Per-tenant AI customization and user profiles

Used by: backend-ai-api/tenants

// Collection: user_profiles
{
  "_id": ObjectId,
  "tenantId": "tenant_xyz",
  "userId": "user_abc",
  "preferences": {
    "preferredLanguage": "typescript",
    "codeStyle": "functional",
    "verbosity": "concise"
  },
  "learningHistory": [...],
  "createdAt": ISODate,
  "updatedAt": ISODate
}
// Indexes: tenantId+userId (compound unique)

// Collection: user_interactions
{
  "_id": ObjectId,
  "tenantId": "tenant_xyz",
  "userId": "user_abc",
  "interactionType": "module_generation",
  "request": "Create a user management module",
  "response": {...},
  "wasHelpful": true,
  "embedding": [...],  // For similarity search
  "timestamp": ISODate
}
// Vector Index: embedding
// Regular Indexes: tenantId+userId, interactionType, timestamp

// Collection: preferences
{
  "_id": ObjectId,
  "tenantId": "tenant_xyz",
  "userId": "user_abc",
  "aiEnabled": true,
  "autoSuggestions": true,
  "privacyLevel": "standard",
  "updatedAt": ISODate
}
// Indexes: tenantId+userId

πŸ” Vector Search Configuration

Current Vector Indexes (Flex Cluster)

Database Collection Index Name Fields Status
ai-agents agent_embeddings vector_index embedding, taskType, tenantId, etc. READY
ai-agents agent_patterns pattern_vector_index embedding, status, etc. READY
ai-agents tenant_user_interactions tenant_interaction_index embedding, tenantId, userId, etc. READY

Target Vector Indexes (After Migration)

Database Collection Index Name Dimensions Similarity
ai-memory embeddings embedding_vector_idx 1536 cosine
ai-memory patterns pattern_vector_idx 1536 cosine
gograb-ai-tenants user_interactions interaction_vector_idx 1536 cosine

Vector Index Definition Example

// Create vector index via Atlas UI or API
{
  "name": "embedding_vector_idx",
  "type": "vectorSearch",
  "definition": {
    "fields": [
      {
        "type": "vector",
        "path": "embedding",
        "numDimensions": 1536,
        "similarity": "cosine"
      },
      {
        "type": "filter",
        "path": "metadata.tenantId"
      },
      {
        "type": "filter",
        "path": "metadata.agentId"
      },
      {
        "type": "filter",
        "path": "contentType"
      }
    ]
  }
}

πŸš€ Scaling Architecture

Phase 1: Development (Current)

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         FLEX CLUSTER (~$35/mo)      β”‚
β”‚                                     β”‚
β”‚   Single shared infrastructure      β”‚
β”‚   10 vector indexes max             β”‚
β”‚   Variable performance              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Phase 2: Production Launch

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚         M30 CLUSTER (~$320/mo)      β”‚
β”‚                                     β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚   β”‚      3-Node Replica Set       β”‚ β”‚
β”‚   β”‚   8GB RAM, 2 vCPU, 40GB       β”‚ β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                                     β”‚
β”‚   Dedicated resources               β”‚
β”‚   Unlimited vector indexes          β”‚
β”‚   Consistent performance            β”‚
β”‚   Auto-scaling enabled              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Phase 3: Growth (When Needed)

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              M30 + SEARCH NODES (~$670/mo)                  β”‚
β”‚                                                             β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚   β”‚      Data Nodes (M30)         β”‚  β”‚  Search Nodes    β”‚  β”‚
β”‚   β”‚   Primary + 2 Secondary       β”‚  β”‚   S30 Γ— 2        β”‚  β”‚
β”‚   β”‚   Regular CRUD operations     β”‚  β”‚   Vector search  β”‚  β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                                                             β”‚
β”‚   Complete workload isolation                               β”‚
β”‚   Vector search on dedicated hardware                       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Phase 4: Scale (Future)

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚              M50 SHARDED + SEARCH NODES (~$1,500+/mo)       β”‚
β”‚                                                             β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”             β”‚
β”‚   β”‚  Shard 1   β”‚ β”‚  Shard 2   β”‚ β”‚  Shard 3   β”‚             β”‚
β”‚   β”‚  3 nodes   β”‚ β”‚  3 nodes   β”‚ β”‚  3 nodes   β”‚             β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜             β”‚
β”‚           β”‚            β”‚            β”‚                       β”‚
β”‚           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                       β”‚
β”‚                        β”‚                                    β”‚
β”‚              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                          β”‚
β”‚              β”‚   mongos Router   β”‚                          β”‚
β”‚              β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                          β”‚
β”‚                                                             β”‚
β”‚   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚   β”‚              Search Nodes (S50 Γ— 4)                β”‚   β”‚
β”‚   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                                                             β”‚
β”‚   Horizontal scaling                                        β”‚
β”‚   Terabyte-scale data                                       β”‚
β”‚   Millions of embeddings                                    β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ” Security Architecture

Network Security

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     SECURITY LAYERS                         β”‚
β”‚                                                             β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚                  IP WHITELIST                          β”‚ β”‚
β”‚  β”‚   β€’ Production servers only                            β”‚ β”‚
β”‚  β”‚   β€’ VPC peering for cloud environments                 β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                           β”‚                                 β”‚
β”‚                           β–Ό                                 β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚                  TLS ENCRYPTION                        β”‚ β”‚
β”‚  β”‚   β€’ In-transit encryption (TLS 1.2+)                   β”‚ β”‚
β”‚  β”‚   β€’ At-rest encryption (AES-256)                       β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                           β”‚                                 β”‚
β”‚                           β–Ό                                 β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚              DATABASE USER ROLES                       β”‚ β”‚
β”‚  β”‚   β€’ backend-api-user: gograb-api (readWrite)           β”‚ β”‚
β”‚  β”‚   β€’ backend-ai-user: ai-agents, gograb-ai-*        β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Database User Configuration

// User: backend-api-user
{
  roles: [
    { role: "readWrite", db: "gograb-api" },
    { role: "readWrite", db: "gograb-core" }
  ]
}

// User: backend-ai-user
{
  roles: [
    { role: "readWrite", db: "ai-agents" },
    { role: "readWrite", db: "ai-memory" },
    { role: "readWrite", db: "gograb-ai-tenants" },
    { role: "read", db: "gograb-api" }  // Read core data for context
  ]
}

πŸ“Š Monitoring & Alerts

Key Metrics to Monitor

Metric Warning Critical Action
CPU Utilization > 70% > 85% Scale tier
Memory Utilization > 75% > 90% Scale tier
Disk Usage > 70% > 85% Increase storage
Connections > 2000 > 2500 Scale tier
Query Latency (p95) > 100ms > 500ms Optimize/scale
Vector Search Latency > 100ms > 200ms Add Search Nodes

Recommended Alerts

// Alert: High Memory Usage
{
  metric: "SYSTEM_MEMORY_USED",
  threshold: 80,
  operator: "GREATER_THAN",
  notification: ["email", "slack"]
}

// Alert: Slow Vector Search
{
  metric: "VECTOR_SEARCH_LATENCY_P95",
  threshold: 100,  // ms
  operator: "GREATER_THAN",
  notification: ["email", "slack"]
}

πŸ”— Related Documentation