Skip to content

Bast AI Platform Architecture

Document Purpose

This document defines the complete platform architecture for Bast AI, covering the service hierarchy from Environment to Organization to CAT, including infrastructure setup, UI integration, and operational workflows.


Table of Contents

  1. Service Hierarchy Overview
  2. Environment Layer (ENV)
  3. Organization Layer (ORG)
  4. CAT Layer
  5. User Roles and Access
  6. Infrastructure on DuploCloud/AWS
  7. Data Architecture (HIPAA/SOC2)
  8. UI Integration Flows
  9. Service Creation Workflows
  10. Monitoring and Observability
  11. Compliance Requirements

Service Hierarchy Overview

Three-Tier Service Model

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                              ENVIRONMENT (ENV)                                   β”‚
β”‚  One deployment environment (dev, demo, prod)                                   β”‚
β”‚  Contains: Shared infrastructure, UI services, platform services                β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚                         ORGANIZATION (ORG/Tenant)                          β”‚ β”‚
β”‚  β”‚  One per customer/organization                                              β”‚ β”‚
β”‚  β”‚  Contains: org-services, org data, org configurations                      β”‚ β”‚
β”‚  β”‚                                                                              β”‚ β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚ β”‚
β”‚  β”‚  β”‚                              CAT                                      β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  One per use case within an org                                       β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  Contains: cat-runtime, CAT OS, Knowledge Domains, Agent Pool         β”‚  β”‚ β”‚
β”‚  β”‚  β”‚                                                                        β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  Components:                                                           β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  - 1 CAT OS (execution ontology)                                      β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  - N Knowledge Domains                                                 β”‚  β”‚ β”‚
β”‚  β”‚  β”‚  - 1 Agent Pool                                                        β”‚  β”‚ β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚ β”‚
β”‚  β”‚                                                                              β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Cardinality Summary

Parent Child Relationship
ENV ORG 1 : N (one env has many orgs)
ORG CAT 1 : N (one org has many CATs)
ORG CAT OS 1 : N (one org has many CAT OSs)
ORG Knowledge Domain 1 : N (one org has many knowledge domains)
ORG Agent Pool 1 : N (one org has many agent pools)
CAT CAT OS 1 : 1 (one CAT uses one CAT OS)
CAT Knowledge Domain 1 : N (one CAT uses many knowledge domains)
CAT Agent Pool 1 : 1 (one CAT uses one agent pool)

Environment Layer (ENV)

Definition

An Environment is a complete deployment of the Bast AI platform, isolated from other environments. Each environment contains shared infrastructure and services that support multiple organizations.

Environment Types

Environment Purpose Branch Stability Infrastructure
dev Development, testing dev May be unstable dev-shared
demo Customer demos, UAT main Should be stable demo-shared
prod Production workloads main (tagged) Must be stable prod-shared

DuploCloud Tenant Structure

Each environment has a shared tenant for platform services and org-specific tenants for organization services:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        DUPLOCLOUD TENANT STRUCTURE                               β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  DEV ENVIRONMENT (Infrastructure: dev-shared)                                       β”‚
β”‚  ────────────────────────────────────────                                       β”‚
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚ SHARED TENANT: dev-shared                                                 β”‚   β”‚
β”‚  β”‚                                                                           β”‚   β”‚
β”‚  β”‚ Services:                                                                 β”‚   β”‚
β”‚  β”‚ - dev-admin-ui      (Platform Admin, CAT Builder UI)                    β”‚   β”‚
β”‚  β”‚ - dev-chat-ui       (End User Chat UI)                                  β”‚   β”‚
β”‚  β”‚ - dev-bff           (Backend-for-Frontend)                              β”‚   β”‚
β”‚  β”‚ - platform-api      (Platform management + Authentication)              β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                              β”‚                                                  β”‚
β”‚              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                  β”‚
β”‚              β–Ό               β–Ό               β–Ό                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                β”‚
β”‚  β”‚ ORG TENANT:      β”‚ β”‚ ORG TENANT:      β”‚ β”‚ ORG TENANT:      β”‚                β”‚
β”‚  β”‚ dev-bastai        β”‚ β”‚ dev-craigh        β”‚ β”‚ dev-{org}         β”‚                β”‚
β”‚  β”‚                  β”‚ β”‚                  β”‚ β”‚                  β”‚                β”‚
β”‚  β”‚ - org-services   β”‚ β”‚ - org-services   β”‚ β”‚ - org-services   β”‚                β”‚
β”‚  β”‚ - cat-runtime-*  β”‚ β”‚ - cat-runtime-*  β”‚ β”‚ - cat-runtime-*  β”‚                β”‚
β”‚  β”‚ - monitoring     β”‚ β”‚ - monitoring     β”‚ β”‚ - monitoring     β”‚                β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                β”‚
β”‚                                                                                  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  DEMO ENVIRONMENT (Infrastructure: demo-shared)                                    β”‚
β”‚  ───────────────────────────────────────────                                    β”‚
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚ SHARED TENANT: demo-shared                                               β”‚   β”‚
β”‚  β”‚                                                                           β”‚   β”‚
β”‚  β”‚ Services:                                                                 β”‚   β”‚
β”‚  β”‚ - demo-admin-ui, demo-chat-ui, demo-bff                                 β”‚   β”‚
β”‚  β”‚ - platform-api (includes auth)                                          β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                              β”‚                                                  β”‚
β”‚              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                  β”‚
β”‚              β–Ό               β–Ό               β–Ό                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                β”‚
β”‚  β”‚ demo-bastai      β”‚ β”‚ demo-craigh      β”‚ β”‚ demo-{org}       β”‚                β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                β”‚
β”‚                                                                                  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  PROD ENVIRONMENT (Infrastructure: prod-shared)                                    β”‚
β”‚  ───────────────────────────────────────────                                    β”‚
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚
β”‚  β”‚ SHARED TENANT: prod-shared                                               β”‚   β”‚
β”‚  β”‚                                                                           β”‚   β”‚
β”‚  β”‚ Services:                                                                 β”‚   β”‚
β”‚  β”‚ - admin-ui, chat-ui, bff                                                β”‚   β”‚
β”‚  β”‚ - platform-api (includes auth)                                          β”‚   β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚
β”‚                              β”‚                                                  β”‚
β”‚              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                  β”‚
β”‚              β–Ό               β–Ό               β–Ό                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                β”‚
β”‚  β”‚ prod-bastai      β”‚ β”‚ prod-craigh      β”‚ β”‚ prod-{org}       β”‚                β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                β”‚
β”‚                                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Naming Convention

Component Pattern Dev Example Demo Example Prod Example
Infrastructure {env}-shared dev-shared demo-shared prod-shared
Shared Tenant {env}-shared dev-shared demo-shared prod-shared
Org Tenant {env}-{org} dev-bastai demo-bastai prod-bastai
UI Services {env}-{service} dev-admin-ui demo-admin-ui admin-ui

Services Per Environment

1. Infrastructure Services (AWS)

Service Purpose Scope Count
MongoDB Atlas Primary database See Data Architecture Per org (prod) / Shared (dev)
Redis/ElastiCache Caching, sessions Per environment 1 cluster
S3 Buckets Object storage Per org 1 per org
ECR Container registry Per environment 1
ALB/Ingress Load balancing Per tenant 1+ per tenant
Route53 DNS Global 1 hosted zone
Secrets Manager Secrets storage Per environment 1

Note: MongoDB Atlas architecture follows HIPAA/SOC2 compliance requirements with separate clusters per production org. See Data Architecture for details.

2. Shared Tenant Services ({env}-shared)

These services run in the shared tenant and serve all organizations:

Service Port Purpose Dev Name Demo Name Prod Name
admin-ui 9090 Org management, CAT Builder dev-admin-ui demo-admin-ui admin-ui
chat-ui 9090 End-user chat interface dev-chat-ui demo-chat-ui chat-ui
bff 4000 Backend-for-Frontend, API gateway dev-bff demo-bff bff
platform-api 8080 Platform management, org provisioning, authentication platform-api platform-api platform-api

3. Org Tenant Services ({env}-{org})

These services run in each org's dedicated tenant:

Service Port Purpose Count per Org
org-services 8080 Org-level APIs (CAT Builder, Security, Analytics) 1
cat-runtime-{type} 9090 CAT execution runtime 1 per CAT
monitoring 9100 Prometheus, Grafana (org-scoped metrics) 1

Environment Architecture Diagram

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    DEMO ENVIRONMENT (Infrastructure: demo-shared)                   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚                    INFRASTRUCTURE SERVICES (AWS)                             β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”          β”‚β”‚
β”‚  β”‚  β”‚ MongoDB  β”‚ β”‚  Redis   β”‚ β”‚   S3     β”‚ β”‚   ECR    β”‚ β”‚  Route53 β”‚          β”‚β”‚
β”‚  β”‚  β”‚ (Atlas)  β”‚ β”‚(Elasti-  β”‚ β”‚ Buckets  β”‚ β”‚ Registry β”‚ β”‚   DNS    β”‚          β”‚β”‚
β”‚  β”‚  β”‚          β”‚ β”‚  Cache)  β”‚ β”‚          β”‚ β”‚          β”‚ β”‚          β”‚          β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜          β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚                    SHARED TENANT: demo-shared                                β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚β”‚
β”‚  β”‚  β”‚demo-admin- β”‚ β”‚demo-chat-  β”‚ β”‚  demo-bff  β”‚ β”‚     platform-api        β”‚β”‚β”‚
β”‚  β”‚  β”‚    ui      β”‚ β”‚    ui      β”‚ β”‚            β”‚ β”‚   (org mgmt + auth)     β”‚β”‚β”‚
β”‚  β”‚  β”‚  :9090     β”‚ β”‚  :9090     β”‚ β”‚  :4000     β”‚ β”‚        :8080            β”‚β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β”‚  Routes requests to org tenants based on JWT/org_id                          β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                         β”‚                                        β”‚
β”‚          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”        β”‚
β”‚          β–Ό                              β–Ό                              β–Ό        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”‚
β”‚  β”‚ ORG TENANT:         β”‚  β”‚ ORG TENANT:         β”‚  β”‚ ORG TENANT:         β”‚      β”‚
β”‚  β”‚ demo-bastai         β”‚  β”‚ demo-craigh         β”‚  β”‚ demo-{org}          β”‚      β”‚
β”‚  β”‚                     β”‚  β”‚                     β”‚  β”‚                     β”‚      β”‚
β”‚  β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚  β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚  β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚      β”‚
β”‚  β”‚ β”‚  org-services   β”‚ β”‚  β”‚ β”‚  org-services   β”‚ β”‚  β”‚ β”‚  org-services   β”‚ β”‚      β”‚
β”‚  β”‚ β”‚  :8080          β”‚ β”‚  β”‚ β”‚  :8080          β”‚ β”‚  β”‚ β”‚  :8080          β”‚ β”‚      β”‚
β”‚  β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚  β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚  β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚      β”‚
β”‚  β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚  β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚  β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚      β”‚
β”‚  β”‚ β”‚cat-runtime-     β”‚ β”‚  β”‚ β”‚cat-runtime-     β”‚ β”‚  β”‚ β”‚cat-runtime-     β”‚ β”‚      β”‚
β”‚  β”‚ β”‚  advisor :9090  β”‚ β”‚  β”‚ β”‚  helper  :9090  β”‚ β”‚  β”‚ β”‚  {cat}   :9090  β”‚ β”‚      β”‚
β”‚  β”‚ β”‚cat-runtime-     β”‚ β”‚  β”‚ β”‚                 β”‚ β”‚  β”‚ β”‚                 β”‚ β”‚      β”‚
β”‚  β”‚ β”‚  support :9090  β”‚ β”‚  β”‚ β”‚                 β”‚ β”‚  β”‚ β”‚                 β”‚ β”‚      β”‚
β”‚  β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚  β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚  β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚      β”‚
β”‚  β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚  β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚  β”‚ β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚      β”‚
β”‚  β”‚ β”‚   monitoring    β”‚ β”‚  β”‚ β”‚   monitoring    β”‚ β”‚  β”‚ β”‚   monitoring    β”‚ β”‚      β”‚
β”‚  β”‚ β”‚  :9100          β”‚ β”‚  β”‚ β”‚  :9100          β”‚ β”‚  β”‚ β”‚  :9100          β”‚ β”‚      β”‚
β”‚  β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚  β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚  β”‚ β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚      β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β”‚
β”‚                                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Organization Layer (ORG)

Definition

An Organization (also called Tenant) represents a customer or business unit within an environment. Each organization has isolated data and configurations but shares platform infrastructure.

Services Per Organization

Service Port Purpose Count
org-services 8080 Org-level APIs (CAT Builder, Security, Analytics) 1 per org

Organization Data Entities

Entity Description Storage
Organization Config Org settings, branding, features MongoDB
Users Org users, roles, permissions MongoDB + Platform API (Auth)
CAT OS Configs Execution ontology definitions MongoDB
Knowledge Domains Knowledge base configurations MongoDB + Vector DB
Agent Pools Agent configurations and pools MongoDB
Themes Visual appearance and branding configurations MongoDB
CATs CAT configurations MongoDB

Organization Infrastructure Model

The Platform API stores deployment tracking information for each organization:

OrganizationInDB
└── infrastructure: InfrastructureConfig
    β”œβ”€β”€ tenant: DuploCloudTenantConfig
    β”‚   β”œβ”€β”€ tenant_name: str           # e.g., "dev-acme-corp"
    β”‚   β”œβ”€β”€ tenant_id: str             # DuploCloud UUID
    β”‚   β”œβ”€β”€ infrastructure_name: str   # e.g., "nonprod" (same as dev-shared)
    β”‚   β”œβ”€β”€ plan_id: str               # e.g., "dev-shared"
    β”‚   └── status: DeploymentStatus   # pending, deploying, running, etc.
    β”‚
    β”œβ”€β”€ mongodb: MongoDBConfig
    β”‚   β”œβ”€β”€ database_name: str         # e.g., "acme-corp_data"
    β”‚   └── mongodb_uri: str           # Connection string
    β”‚
    β”œβ”€β”€ org_services: ServiceDeployment    # One per org
    β”‚   β”œβ”€β”€ service_name: str          # DuploCloud service name
    β”‚   β”œβ”€β”€ image: str                 # Docker image
    β”‚   β”œβ”€β”€ image_tag: str             # Version tag
    β”‚   β”œβ”€β”€ status: DeploymentStatus
    β”‚   β”œβ”€β”€ replicas: int
    β”‚   β”œβ”€β”€ internal_endpoint: str     # Internal URL
    β”‚   └── env_vars: dict             # Non-sensitive env vars
    β”‚
    └── cat_runtimes: List[CATRuntimeDeployment]  # Multiple per org
        β”œβ”€β”€ cat_id: str                # CAT ID
        β”œβ”€β”€ cat_uuid: str              # e.g., "PREFIX-ABC123"
        β”œβ”€β”€ service_name: str          # DuploCloud service name
        β”œβ”€β”€ image: str                 # CAT runtime image
        β”œβ”€β”€ status: DeploymentStatus
        β”œβ”€β”€ replicas: int
        └── internal_endpoint: str

Environment Variables for Platform API:

Variable Description Example
PLATFORM_MONGODB_URI MongoDB connection string for Platform API See below
PORT API port (optional, default: 8080) 8080
DUPLO_HOST DuploCloud host URL https://<duplocloud-host>
DUPLO_TOKEN DuploCloud API token <token>

Platform MongoDB Connection Strings:

Environment Connection String
Local Dev mongodb+srv://<user>:<password>@<cluster>.mongodb.net/bast_platform?retryWrites=true&w=majority
Dev mongodb+srv://<user>:<password>@<cluster>.mongodb.net/bast_platform?retryWrites=true&w=majority

Note: Database name for Platform API is always bast_platform.

Environment Variables for org-services:

Variable Description Example
ORG_ID Organization ID (MongoDB ObjectId) 678e5903c5e17b32d40d1234
ORG_SLUG Organization slug (for DB naming) acme-corp
ORG_MONGODB_URI MongoDB connection string mongodb+srv://<user>:<password>@<cluster>.mongodb.net/

Database Naming Convention:

Environment Database Name Example
Dev {org_slug}_data acme-corp_data
Demo {org_slug}_data acme-corp_data
Prod {org_slug}_data acme-corp_data

Collections within each org database: cats, cat_os, knowledge_domains, agent_pools, themes

Organization Architecture Diagram

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                            ORGANIZATION: bastai                                  β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚                          ORG SERVICES                                        β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚β”‚
β”‚  β”‚  β”‚                      org-services                                    β”‚    β”‚β”‚
β”‚  β”‚  β”‚                      (ORG_NAME=bastai)                               β”‚    β”‚β”‚
β”‚  β”‚  β”‚                      Port: 8080                                      β”‚    β”‚β”‚
β”‚  β”‚  β”‚                                                                       β”‚    β”‚β”‚
β”‚  β”‚  β”‚  APIs:                                                                β”‚    β”‚β”‚
β”‚  β”‚  β”‚  - /api/v1/cat-builder/* (CAT OS, Knowledge, Agent Pools, CATs)     β”‚    β”‚β”‚
β”‚  β”‚  β”‚  - /api/v1/security/* (AuthZ, permissions)                          β”‚    β”‚β”‚
β”‚  β”‚  β”‚  - /api/v1/analytics/* (usage, metrics)                             β”‚    β”‚β”‚
β”‚  β”‚  β”‚  - /api/v1/org/* (org settings, users)                              β”‚    β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚                         ORG CONFIGURATIONS (MongoDB)                         β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”‚β”‚
β”‚  β”‚  β”‚  CAT OS     β”‚  β”‚ Knowledge   β”‚  β”‚ Agent       β”‚  β”‚   CATs      β”‚         β”‚β”‚
β”‚  β”‚  β”‚  Configs    β”‚  β”‚ Domains     β”‚  β”‚ Pools       β”‚  β”‚             β”‚         β”‚β”‚
β”‚  β”‚  β”‚             β”‚  β”‚             β”‚  β”‚             β”‚  β”‚             β”‚         β”‚β”‚
β”‚  β”‚  β”‚ - advisor-osβ”‚  β”‚ - products  β”‚  β”‚ - gpt4-pool β”‚  β”‚ - advisor   β”‚         β”‚β”‚
β”‚  β”‚  β”‚ - support-osβ”‚  β”‚ - policies  β”‚  β”‚ - claude-   β”‚  β”‚ - support   β”‚         β”‚β”‚
β”‚  β”‚  β”‚ - sales-os  β”‚  β”‚ - faqs      β”‚  β”‚   pool      β”‚  β”‚ - sales     β”‚         β”‚β”‚
β”‚  β”‚  β”‚             β”‚  β”‚ - manuals   β”‚  β”‚             β”‚  β”‚             β”‚         β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚                          CAT RUNTIME SERVICES                                β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”              β”‚β”‚
β”‚  β”‚  β”‚  cat-runtime-   β”‚  β”‚  cat-runtime-   β”‚  β”‚  cat-runtime-   β”‚              β”‚β”‚
β”‚  β”‚  β”‚    advisor      β”‚  β”‚    support      β”‚  β”‚    sales        β”‚              β”‚β”‚
β”‚  β”‚  β”‚                 β”‚  β”‚                 β”‚  β”‚                 β”‚              β”‚β”‚
β”‚  β”‚  β”‚ CAT_TYPE=advisorβ”‚  β”‚ CAT_TYPE=supportβ”‚  β”‚ CAT_TYPE=sales  β”‚              β”‚β”‚
β”‚  β”‚  β”‚ Port: 9090      β”‚  β”‚ Port: 9090      β”‚  β”‚ Port: 9090      β”‚              β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜              β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚                          MONITORING (Per-Org)                                β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”‚β”‚
β”‚  β”‚  β”‚  Prometheus + Grafana                                                β”‚    β”‚β”‚
β”‚  β”‚  β”‚  Port: 9100                                                          β”‚    β”‚β”‚
β”‚  β”‚  β”‚                                                                       β”‚    β”‚β”‚
β”‚  β”‚  β”‚  Metrics:                                                             β”‚    β”‚β”‚
β”‚  β”‚  β”‚  - CAT runtime performance                                           β”‚    β”‚β”‚
β”‚  β”‚  β”‚  - org-services API latency                                          β”‚    β”‚β”‚
β”‚  β”‚  β”‚  - Knowledge retrieval metrics                                       β”‚    β”‚β”‚
β”‚  β”‚  β”‚  - Agent pool utilization                                            β”‚    β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

CAT Layer

Definition

A CAT (Conversational AI Thing) is a specific AI assistant configuration within an organization. Each CAT has its own runtime service and is composed of reusable components (CAT OS, Knowledge Domains, Agent Pool).

CAT Components

Component Relationship Purpose
CAT OS 1:1 Execution ontology - defines how the CAT behaves
Knowledge Domains 1:N Knowledge bases the CAT can access
Agent Pool 1:1 LLM and agent configurations
Theme 1:1 (optional) Visual appearance and branding configuration

CAT Runtime Service

Each CAT gets its own cat-runtime service instance:

Service Port Environment Variables
cat-runtime-{cat_type} 9090 ORG_NAME, CAT_TYPE, MONGODB_URI, OPENAI_API_KEY, DVC_REGISTRY_URL

CAT Architecture Diagram

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                              CAT: advisor                                        β”‚
β”‚                              ORG: bastai                                         β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚                        cat-runtime-advisor                                   β”‚β”‚
β”‚  β”‚                        (Kubernetes Service)                                  β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β”‚  Environment:                                                                 β”‚β”‚
β”‚  β”‚  - ORG_NAME=bastai                                                           β”‚β”‚
β”‚  β”‚  - CAT_TYPE=advisor                                                          β”‚β”‚
β”‚  β”‚  - MONGODB_URI=mongodb+srv://<user>:<password>@<cluster>.mongodb.net/                                             β”‚β”‚
β”‚  β”‚  - OPENAI_API_KEY=sk-...                                                     β”‚β”‚
β”‚  β”‚  - DVC_REGISTRY_URL=s3://...                                                 β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β”‚  Endpoints:                                                                   β”‚β”‚
β”‚  β”‚  - POST /api/v1/cat/chat                                                     β”‚β”‚
β”‚  β”‚  - GET  /api/v1/cat/chat/history                                             β”‚β”‚
β”‚  β”‚  - GET  /api/v1/cat/chat/conversations                                       β”‚β”‚
β”‚  β”‚  - POST /api/v1/feedback/send                                                β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                         β”‚                                        β”‚
β”‚                    Loads configuration at startup                                β”‚
β”‚                                         β”‚                                        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚                                      β–Ό                                       β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚β”‚
β”‚  β”‚  β”‚    CAT OS       β”‚  β”‚    Knowledge Domains        β”‚  β”‚   Agent Pool    β”‚  β”‚β”‚
β”‚  β”‚  β”‚   (1:1)         β”‚  β”‚    (1:N)                    β”‚  β”‚   (1:1)         β”‚  β”‚β”‚
β”‚  β”‚  β”‚                 β”‚  β”‚                             β”‚  β”‚                 β”‚  β”‚β”‚
β”‚  β”‚  β”‚ advisor-os      β”‚  β”‚ - products (hybrid search) β”‚  β”‚ gpt4-pool       β”‚  β”‚β”‚
β”‚  β”‚  β”‚                 β”‚  β”‚ - policies (vector)        β”‚  β”‚                 β”‚  β”‚β”‚
β”‚  β”‚  β”‚ Defines:        β”‚  β”‚ - faqs (text search)       β”‚  β”‚ Defines:        β”‚  β”‚β”‚
β”‚  β”‚  β”‚ - Intents       β”‚  β”‚                             β”‚  β”‚ - Model (GPT-4) β”‚  β”‚β”‚
β”‚  β”‚  β”‚ - Workflows     β”‚  β”‚ Each domain has:           β”‚  β”‚ - Temperature   β”‚  β”‚β”‚
β”‚  β”‚  β”‚ - Behaviors     β”‚  β”‚ - Document store           β”‚  β”‚ - Max tokens    β”‚  β”‚β”‚
β”‚  β”‚  β”‚ - Guardrails    β”‚  β”‚ - Vector embeddings        β”‚  β”‚ - Fallbacks     β”‚  β”‚β”‚
β”‚  β”‚  β”‚                 β”‚  β”‚ - Search config            β”‚  β”‚                 β”‚  β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚β”‚
β”‚  β”‚  β”‚                              Theme (1:1 optional)                        β”‚ β”‚β”‚
β”‚  β”‚  β”‚                                                                          β”‚ β”‚β”‚
β”‚  β”‚  β”‚  advisor-theme                                                           β”‚ β”‚β”‚
β”‚  β”‚  β”‚                                                                          β”‚ β”‚β”‚
β”‚  β”‚  β”‚  Defines:                                                                β”‚ β”‚β”‚
β”‚  β”‚  β”‚  - Colors (primary, secondary, accent, background, text, etc.)          β”‚ β”‚β”‚
β”‚  β”‚  β”‚  - Typography (font family)                                             β”‚ β”‚β”‚
β”‚  β”‚  β”‚  - Radius (corner roundness)                                            β”‚ β”‚β”‚
β”‚  β”‚  β”‚  - Shadow depth                                                         β”‚ β”‚β”‚
β”‚  β”‚  β”‚  - Button style (filled/outline/ghost)                                  β”‚ β”‚β”‚
β”‚  β”‚  β”‚  - Background style (flat/gradient)                                     β”‚ β”‚β”‚
β”‚  β”‚  β”‚  - CAT avatar                                                           β”‚ β”‚β”‚
β”‚  β”‚  β”‚  - Logo URL                                                             β”‚ β”‚β”‚
β”‚  β”‚  β”‚  - Brand text                                                           β”‚ β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

User Roles and Access

Role Hierarchy

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                              USER ROLES                                          β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚                        PLATFORM LEVEL                                        β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                                         β”‚β”‚
β”‚  β”‚  β”‚ Platform Admin  β”‚  - Manage environments                                  β”‚β”‚
β”‚  β”‚  β”‚                 β”‚  - Create/delete organizations                          β”‚β”‚
β”‚  β”‚  β”‚                 β”‚  - Platform-wide settings                               β”‚β”‚
β”‚  β”‚  β”‚                 β”‚  - View all orgs                                        β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                                         β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                         β”‚                                        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚                        ORGANIZATION LEVEL                                    β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                   β”‚β”‚
β”‚  β”‚  β”‚   Org Admin     β”‚  β”‚   CAT Builder   β”‚                                   β”‚β”‚
β”‚  β”‚  β”‚  (Super-user)   β”‚  β”‚  (Super-user)   β”‚                                   β”‚β”‚
β”‚  β”‚  β”‚                 β”‚  β”‚                 β”‚                                   β”‚β”‚
β”‚  β”‚  β”‚ - Manage org    β”‚  β”‚ - Create CAT OS β”‚                                   β”‚β”‚
β”‚  β”‚  β”‚ - Manage users  β”‚  β”‚ - Create KDs    β”‚                                   β”‚β”‚
β”‚  β”‚  β”‚ - View analyticsβ”‚  β”‚ - Create Agents β”‚                                   β”‚β”‚
β”‚  β”‚  β”‚ - All CAT accessβ”‚  β”‚ - Create CATs   β”‚                                   β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                   β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β”‚  UI: admin-ui (https://admin.bast.ai)                                        β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                         β”‚                                        β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚                           CAT LEVEL                                          β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                                         β”‚β”‚
β”‚  β”‚  β”‚   End User      β”‚                                                         β”‚β”‚
β”‚  β”‚  β”‚ (Normal user)   β”‚                                                         β”‚β”‚
β”‚  β”‚  β”‚                 β”‚                                                         β”‚β”‚
β”‚  β”‚  β”‚ - Chat with CAT β”‚                                                         β”‚β”‚
β”‚  β”‚  β”‚ - View history  β”‚                                                         β”‚β”‚
β”‚  β”‚  β”‚ - Send feedback β”‚                                                         β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                                         β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β”‚  UI: chat-ui (https://chat.bast.ai)                                          β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

UI to Role Mapping

UI Target Users Capabilities
admin-ui Platform Admin, Org Admin, CAT Builder Org management, CAT configuration, analytics
chat-ui End Users Chat with CATs, view history, feedback

Infrastructure on DuploCloud/AWS

DuploCloud Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                           DUPLOCLOUD / AWS                                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚                        AWS ACCOUNT                                           β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚β”‚
β”‚  β”‚  β”‚              DUPLOCLOUD INFRASTRUCTURES                                  β”‚β”‚β”‚
β”‚  β”‚  β”‚                                                                          β”‚β”‚β”‚
β”‚  β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                β”‚β”‚β”‚
β”‚  β”‚  β”‚  β”‚   dev-shared      β”‚  β”‚  demo-shared     β”‚  β”‚  prod-shared     β”‚                β”‚β”‚β”‚
β”‚  β”‚  β”‚  β”‚   (Dev)       β”‚  β”‚  (Demo)       β”‚  β”‚  (Prod)       β”‚                β”‚β”‚β”‚
β”‚  β”‚  β”‚  β”‚               β”‚  β”‚               β”‚  β”‚               β”‚                β”‚β”‚β”‚
β”‚  β”‚  β”‚  β”‚ - VPC         β”‚  β”‚ - VPC         β”‚  β”‚ - VPC         β”‚                β”‚β”‚β”‚
β”‚  β”‚  β”‚  β”‚ - EKS Cluster β”‚  β”‚ - EKS Cluster β”‚  β”‚ - EKS Cluster β”‚                β”‚β”‚β”‚
β”‚  β”‚  β”‚  β”‚ - ALB/Ingress β”‚  β”‚ - ALB/Ingress β”‚  β”‚ - ALB/Ingress β”‚                β”‚β”‚β”‚
β”‚  β”‚  β”‚  β”‚ - IAM/IRSA    β”‚  β”‚ - IAM/IRSA    β”‚  β”‚ - IAM/IRSA    β”‚                β”‚β”‚β”‚
β”‚  β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                β”‚β”‚β”‚
β”‚  β”‚  β”‚                                                                          β”‚β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚β”‚
β”‚  β”‚  β”‚                    DEV TENANTS (dev-shared)                                  β”‚β”‚β”‚
β”‚  β”‚  β”‚                                                                          β”‚β”‚β”‚
β”‚  β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                      β”‚β”‚β”‚
β”‚  β”‚  β”‚  β”‚ dev-shared   β”‚  β”‚ dev-bastai   β”‚  β”‚ dev-craigh   β”‚                      β”‚β”‚β”‚
β”‚  β”‚  β”‚  β”‚ (shared svc)β”‚  β”‚ (org svc)   β”‚  β”‚ (org svc)   β”‚                      β”‚β”‚β”‚
β”‚  β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                      β”‚β”‚β”‚
β”‚  β”‚  β”‚                                                                          β”‚β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚β”‚
β”‚  β”‚  β”‚                   DEMO TENANTS (demo-shared)                                β”‚β”‚β”‚
β”‚  β”‚  β”‚                                                                          β”‚β”‚β”‚
β”‚  β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                      β”‚β”‚β”‚
β”‚  β”‚  β”‚  β”‚ demo-shared β”‚  β”‚ demo-bastai β”‚  β”‚ demo-craigh β”‚                      β”‚β”‚β”‚
β”‚  β”‚  β”‚  β”‚ (shared svc)β”‚  β”‚ (org svc)   β”‚  β”‚ (org svc)   β”‚                      β”‚β”‚β”‚
β”‚  β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                      β”‚β”‚β”‚
β”‚  β”‚  β”‚                                                                          β”‚β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚β”‚
β”‚  β”‚  β”‚                   PROD TENANTS (prod-shared)                                β”‚β”‚β”‚
β”‚  β”‚  β”‚                                                                          β”‚β”‚β”‚
β”‚  β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                      β”‚β”‚β”‚
β”‚  β”‚  β”‚  β”‚ prod-shared β”‚  β”‚ prod-bastai β”‚  β”‚ prod-craigh β”‚                      β”‚β”‚β”‚
β”‚  β”‚  β”‚  β”‚ (shared svc)β”‚  β”‚ (org svc)   β”‚  β”‚ (org svc)   β”‚                      β”‚β”‚β”‚
β”‚  β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                      β”‚β”‚β”‚
β”‚  β”‚  β”‚                                                                          β”‚β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚                        EXTERNAL SERVICES                                     β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”‚β”‚
β”‚  β”‚  β”‚  MongoDB    β”‚  β”‚   OpenAI    β”‚  β”‚   WorkOS    β”‚  β”‚   S3/DVC    β”‚         β”‚β”‚
β”‚  β”‚  β”‚  Atlas      β”‚  β”‚   API       β”‚  β”‚   Auth      β”‚  β”‚  Registry   β”‚         β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜         β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

DuploCloud Infrastructure & Tenant Strategy

Infrastructure Environment Purpose
dev-shared Dev Development infrastructure
demo-shared Demo Demo/UAT infrastructure
prod-shared Prod Production infrastructure (us-east-1)
Tenant Infrastructure Type Services
dev-shared dev-shared Shared UI services, platform services
dev-bastai dev-shared Org org-services, cat-runtime-*
dev-craigh dev-shared Org org-services, cat-runtime-*
demo-shared demo-shared Shared UI services, platform services
demo-bastai demo-shared Org org-services, cat-runtime-*
demo-craigh demo-shared Org org-services, cat-runtime-*
prod-shared prod-shared Shared UI services, platform services
prod-bastai prod-shared Org org-services, cat-runtime-*
prod-craigh prod-shared Org org-services, cat-runtime-*

AWS Resources per Environment

Resource Dev (dev-shared) Demo (demo-shared) Prod (prod-shared)
EKS Cluster 1 1 1
ECR Repositories Shared across all Shared across all Shared across all
S3 Buckets 1 per org 1 per org 1 per org
MongoDB Cluster 1 shared (bast-nonprod) 1 shared (bast-demo) 1 per org (prod-{org})
Redis/ElastiCache 1 shared 1 shared 1 per org
ALB/Ingress 1 per tenant 1 per tenant 1 per tenant
Secrets Manager 1 1 1

Data Architecture (HIPAA/SOC2)

Overview

To meet HIPAA and SOC2 compliance requirements, the platform uses a hybrid MongoDB architecture: - Non-Production: Shared cluster (no PHI/PII) - Production: Dedicated cluster per organization (PHI/PII isolation)

MongoDB Atlas Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        MONGODB ATLAS ARCHITECTURE                                β”‚
β”‚                        (HIPAA/SOC2 Compliant)                                    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚                    DEV ENVIRONMENT (No PHI/PII)                            β”‚  β”‚
β”‚  β”‚                                                                             β”‚  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚  β”‚
β”‚  β”‚  β”‚              Shared Cluster: bast-nonprod                           β”‚   β”‚  β”‚
β”‚  β”‚  β”‚              Tier: M10 (development)                                β”‚   β”‚  β”‚
β”‚  β”‚  β”‚                                                                      β”‚   β”‚  β”‚
β”‚  β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                  β”‚   β”‚  β”‚
β”‚  β”‚  β”‚  β”‚ DB: np_bastaiβ”‚ β”‚ DB: np_craighβ”‚ β”‚ DB: dev_{org}β”‚                  β”‚   β”‚  β”‚
β”‚  β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                  β”‚   β”‚  β”‚
β”‚  β”‚  β”‚                                                                      β”‚   β”‚  β”‚
β”‚  β”‚  β”‚  Requirements:                                                       β”‚   β”‚  β”‚
β”‚  β”‚  β”‚  - NO PHI/PII data                                                  β”‚   β”‚  β”‚
β”‚  β”‚  β”‚  - Synthetic/anonymized data only                                   β”‚   β”‚  β”‚
β”‚  β”‚  β”‚  - VPC peering to dev-shared infrastructure                             β”‚   β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚  β”‚
β”‚  β”‚                                                                             β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚                    DEMO ENVIRONMENT (No PHI/PII)                           β”‚  β”‚
β”‚  β”‚                                                                             β”‚  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚  β”‚
β”‚  β”‚  β”‚              Shared Cluster: bast-demo                              β”‚   β”‚  β”‚
β”‚  β”‚  β”‚              Tier: M10/M30 (demo)                                   β”‚   β”‚  β”‚
β”‚  β”‚  β”‚                                                                      β”‚   β”‚  β”‚
β”‚  β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”               β”‚   β”‚  β”‚
β”‚  β”‚  β”‚  β”‚DB: demo_bastaiβ”‚ β”‚DB: demo_craighβ”‚ β”‚DB: demo_{org}β”‚               β”‚   β”‚  β”‚
β”‚  β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜               β”‚   β”‚  β”‚
β”‚  β”‚  β”‚                                                                      β”‚   β”‚  β”‚
β”‚  β”‚  β”‚  Requirements:                                                       β”‚   β”‚  β”‚
β”‚  β”‚  β”‚  - NO PHI/PII data (use synthetic data for demos)                   β”‚   β”‚  β”‚
β”‚  β”‚  β”‚  - Customer-facing demos                                            β”‚   β”‚  β”‚
β”‚  β”‚  β”‚  - VPC peering to demo-shared infrastructure                           β”‚   β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚  β”‚
β”‚  β”‚                                                                             β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚                    PROD ENVIRONMENT (PHI/PII - HIPAA Compliant)            β”‚  β”‚
β”‚  β”‚                                                                             β”‚  β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”            β”‚  β”‚
β”‚  β”‚  β”‚ Cluster:        β”‚  β”‚ Cluster:        β”‚  β”‚ Cluster:        β”‚            β”‚  β”‚
β”‚  β”‚  β”‚ prod-bastai     β”‚  β”‚ prod-craigh     β”‚  β”‚ prod-{org}      β”‚            β”‚  β”‚
β”‚  β”‚  β”‚                 β”‚  β”‚                 β”‚  β”‚                 β”‚            β”‚  β”‚
β”‚  β”‚  β”‚ Tier: M30+      β”‚  β”‚ Tier: M30+      β”‚  β”‚ Tier: M30+      β”‚            β”‚  β”‚
β”‚  β”‚  β”‚ (HIPAA eligible)β”‚  β”‚ (HIPAA eligible)β”‚  β”‚ (HIPAA eligible)β”‚            β”‚  β”‚
β”‚  β”‚  β”‚                 β”‚  β”‚                 β”‚  β”‚                 β”‚            β”‚  β”‚
β”‚  β”‚  β”‚ Features:       β”‚  β”‚ Features:       β”‚  β”‚ Features:       β”‚            β”‚  β”‚
β”‚  β”‚  β”‚ - Dedicated     β”‚  β”‚ - Dedicated     β”‚  β”‚ - Dedicated     β”‚            β”‚  β”‚
β”‚  β”‚  β”‚ - BAA signed    β”‚  β”‚ - BAA signed    β”‚  β”‚ - BAA signed    β”‚            β”‚  β”‚
β”‚  β”‚  β”‚ - Encryption    β”‚  β”‚ - Encryption    β”‚  β”‚ - Encryption    β”‚            β”‚  β”‚
β”‚  β”‚  β”‚ - Audit logs    β”‚  β”‚ - Audit logs    β”‚  β”‚ - Audit logs    β”‚            β”‚  β”‚
β”‚  β”‚  β”‚ - BYOK option   β”‚  β”‚ - BYOK option   β”‚  β”‚ - BYOK option   β”‚            β”‚  β”‚
β”‚  β”‚  β”‚ - VPC peering   β”‚  β”‚ - VPC peering   β”‚  β”‚ - VPC peering   β”‚            β”‚  β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜            β”‚  β”‚
β”‚  β”‚                                                                             β”‚  β”‚
β”‚  β”‚  Each production cluster has:                                               β”‚  β”‚
β”‚  β”‚  - Dedicated resources (no noisy neighbor)                                 β”‚  β”‚
β”‚  β”‚  - Isolated network (VPC peering to prod-shared infrastructure)               β”‚  β”‚
β”‚  β”‚  - Independent backup/restore                                               β”‚  β”‚
β”‚  β”‚  - Org-specific connection string                                           β”‚  β”‚
β”‚  β”‚  - Audit logging enabled                                                    β”‚  β”‚
β”‚  β”‚  - BAA signed with MongoDB Atlas                                           β”‚  β”‚
β”‚  β”‚                                                                             β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β”‚                                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

MongoDB Cluster Requirements by Environment

Environment Cluster Name Cluster Type Tier PHI/PII BAA Required Encryption
Dev bast-nonprod Shared (all orgs) M10 No No TLS + At-rest
Demo bast-demo Shared (all orgs) M10/M30 No (synthetic) No TLS + At-rest
Prod prod-{org} Dedicated per Org M30+ Yes Yes TLS + At-rest + BYOK

Connection String Management

Each environment/org has its own MongoDB connection string stored in AWS Secrets Manager:

Secret Name Description Used By
bast/dev/mongodb/shared Shared dev cluster (bast-nonprod) dev-{org} services
bast/demo/mongodb/shared Shared demo cluster (bast-demo) demo-{org} services
bast/prod/mongodb/{org} Org-specific prod cluster prod-{org} services

Examples:

# Dev Environment (shared cluster, separate databases)
bast/dev/mongodb/shared β†’ mongodb+srv://<user>:<password>@<cluster>.mongodb.net/

# Demo Environment (shared cluster, separate databases)
bast/demo/mongodb/shared β†’ mongodb+srv://<user>:<password>@<cluster>.mongodb.net/

# Prod Environment (dedicated cluster per org)
bast/prod/mongodb/bastai β†’ mongodb+srv://<user>:<password>@<cluster>.mongodb.net/
bast/prod/mongodb/craigh β†’ mongodb+srv://<user>:<password>@<cluster>.mongodb.net/

Database Selection: - Dev: Services connect to bast-nonprod cluster, use database dev_{org} (e.g., np_bastai) - Demo: Services connect to bast-demo cluster, use database demo_{org} (e.g., demo_bastai) - Prod: Services connect to dedicated prod-{org} cluster, use default database

Data Isolation per Org (Production)

Each production org cluster contains these collections:

Collection Description
organizations Org configuration
users Org users and roles
cats CAT configurations
cat_os CAT OS definitions
knowledge_domains Knowledge domain configs
agent_pools Agent pool configurations
themes Theme/branding configurations
conversations Chat conversations (PHI)
feedback User feedback
analytics Usage analytics
audit_logs Security audit trail

UI Integration Flows

Flow 1: Organization Creation (Platform Admin)

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     ORGANIZATION CREATION FLOW                                   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”               β”‚
β”‚  β”‚ Platform β”‚     β”‚  admin-  β”‚     β”‚platform- β”‚     β”‚ DuploCloudβ”‚               β”‚
β”‚  β”‚  Admin   β”‚     β”‚   ui     β”‚     β”‚   api    β”‚     β”‚   API     β”‚               β”‚
β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜               β”‚
β”‚       β”‚                β”‚                β”‚                β”‚                       β”‚
β”‚       β”‚  1. Login      β”‚                β”‚                β”‚                       β”‚
β”‚       │───────────────>β”‚                β”‚                β”‚                       β”‚
β”‚       β”‚                β”‚  2. Create Org β”‚                β”‚                       β”‚
β”‚       β”‚                β”‚   Request      β”‚                β”‚                       β”‚
β”‚       β”‚                │───────────────>β”‚                β”‚                       β”‚
β”‚       β”‚                β”‚                β”‚                β”‚                       β”‚
β”‚       β”‚                β”‚                β”‚  3. Provision  β”‚                       β”‚
β”‚       β”‚                β”‚                β”‚   Resources    β”‚                       β”‚
β”‚       β”‚                β”‚                │───────────────>β”‚                       β”‚
β”‚       β”‚                β”‚                β”‚                β”‚                       β”‚
β”‚       β”‚                β”‚                β”‚  3a. Create    β”‚                       β”‚
β”‚       β”‚                β”‚                β”‚   K8s Service  β”‚                       β”‚
β”‚       β”‚                β”‚                β”‚   (org-svc)    β”‚                       β”‚
β”‚       β”‚                β”‚                β”‚<───────────────│                       β”‚
β”‚       β”‚                β”‚                β”‚                β”‚                       β”‚
β”‚       β”‚                β”‚  4. Create DB  β”‚                β”‚                       β”‚
β”‚       β”‚                β”‚   Collections  β”‚                β”‚                       β”‚
β”‚       β”‚                β”‚   (MongoDB)    β”‚                β”‚                       β”‚
β”‚       β”‚                β”‚                β”‚                β”‚                       β”‚
β”‚       β”‚                β”‚  5. Create S3  β”‚                β”‚                       β”‚
β”‚       β”‚                β”‚   Bucket       β”‚                β”‚                       β”‚
β”‚       β”‚                β”‚                β”‚                β”‚                       β”‚
β”‚       β”‚                β”‚  6. Return     β”‚                β”‚                       β”‚
β”‚       β”‚  7. Success    β”‚   Success      β”‚                β”‚                       β”‚
β”‚       β”‚<───────────────│<───────────────│                β”‚                       β”‚
β”‚       β”‚                β”‚                β”‚                β”‚                       β”‚
β”‚                                                                                  β”‚
β”‚  RESULT:                                                                         β”‚
β”‚  - org-services deployed (ORG_NAME=new-org)                                     β”‚
β”‚  - MongoDB collections: organizations, users, cats, cat_os, etc.                β”‚
β”‚  - S3 bucket: s3://bast-{env}-{org}-data                                        β”‚
β”‚  - Org admin user created                                                        β”‚
β”‚                                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Flow 2: CAT OS / Knowledge Domain / Agent Pool Creation (CAT Builder)

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   CAT COMPONENT CREATION FLOW                                    β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”               β”‚
β”‚  β”‚   CAT    β”‚     β”‚  admin-  β”‚     β”‚   bff    β”‚     β”‚   org-   β”‚               β”‚
β”‚  β”‚ Builder  β”‚     β”‚   ui     β”‚     β”‚          β”‚     β”‚ services β”‚               β”‚
β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜               β”‚
β”‚       β”‚                β”‚                β”‚                β”‚                       β”‚
β”‚       β”‚  1. Login      β”‚                β”‚                β”‚                       β”‚
β”‚       β”‚  (org context) β”‚                β”‚                β”‚                       β”‚
β”‚       │───────────────>β”‚                β”‚                β”‚                       β”‚
β”‚       β”‚                β”‚                β”‚                β”‚                       β”‚
β”‚       β”‚  2a. Create    β”‚  3. tRPC Call  β”‚  4. API Call   β”‚                       β”‚
β”‚       β”‚  CAT OS        │───────────────>│───────────────>β”‚                       β”‚
β”‚       │───────────────>β”‚                β”‚                β”‚                       β”‚
β”‚       β”‚                β”‚                β”‚  5. Save to    β”‚                       β”‚
β”‚       β”‚                β”‚                β”‚  MongoDB       β”‚                       β”‚
β”‚       β”‚                β”‚                β”‚  (cat_os       β”‚                       β”‚
β”‚       β”‚                β”‚                β”‚   collection)  β”‚                       β”‚
β”‚       β”‚                β”‚                β”‚                β”‚                       β”‚
β”‚       β”‚  2b. Create    β”‚                β”‚                β”‚                       β”‚
β”‚       β”‚  Knowledge     │───────────────>│───────────────>β”‚                       β”‚
β”‚       β”‚  Domain        β”‚                β”‚                β”‚                       β”‚
β”‚       │───────────────>β”‚                β”‚  6. Save to    β”‚                       β”‚
β”‚       β”‚                β”‚                β”‚  MongoDB +     β”‚                       β”‚
β”‚       β”‚                β”‚                β”‚  Init Vector   β”‚                       β”‚
β”‚       β”‚                β”‚                β”‚  Index         β”‚                       β”‚
β”‚       β”‚                β”‚                β”‚                β”‚                       β”‚
β”‚       β”‚  2c. Create    β”‚                β”‚                β”‚                       β”‚
β”‚       β”‚  Agent Pool    │───────────────>│───────────────>β”‚                       β”‚
β”‚       │───────────────>β”‚                β”‚                β”‚                       β”‚
β”‚       β”‚                β”‚                β”‚  7. Save to    β”‚                       β”‚
β”‚       β”‚                β”‚                β”‚  MongoDB       β”‚                       β”‚
β”‚       β”‚                β”‚                β”‚  (agent_pools  β”‚                       β”‚
β”‚       β”‚                β”‚                β”‚   collection)  β”‚                       β”‚
β”‚       β”‚                β”‚                β”‚                β”‚                       β”‚
β”‚                                                                                  β”‚
β”‚  NOTE: These are configuration-only operations.                                  β”‚
β”‚        No new services are deployed at this stage.                               β”‚
β”‚        Configurations are stored in MongoDB and used when CAT is created.       β”‚
β”‚                                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Flow 3: CAT Creation (CAT Builder)

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         CAT CREATION FLOW                                        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”‚
β”‚  β”‚   CAT    β”‚   β”‚  admin-  β”‚   β”‚   bff    β”‚   β”‚   org-   β”‚   β”‚ DuploCloudβ”‚      β”‚
β”‚  β”‚ Builder  β”‚   β”‚   ui     β”‚   β”‚          β”‚   β”‚ services β”‚   β”‚   API     β”‚      β”‚
β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜      β”‚
β”‚       β”‚              β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚ 1. Create    β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚ CAT Form     β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       │─────────────>β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚ Select:      β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚ - CAT OS     β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚ - Knowledge  β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚   Domains    β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚ - Agent Pool β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚ 2. Submit    β”‚  3. tRPC     β”‚  4. Create   β”‚              β”‚              β”‚
β”‚       │─────────────>│─────────────>│─────────────>β”‚              β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚              β”‚              β”‚  5. Save CAT β”‚              β”‚              β”‚
β”‚       β”‚              β”‚              β”‚  config to   β”‚              β”‚              β”‚
β”‚       β”‚              β”‚              β”‚  MongoDB     β”‚              β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚              β”‚              β”‚  6. Trigger  β”‚              β”‚              β”‚
β”‚       β”‚              β”‚              β”‚  Service     β”‚              β”‚              β”‚
β”‚       β”‚              β”‚              β”‚  Creation    β”‚              β”‚              β”‚
β”‚       β”‚              β”‚              │─────────────>│─────────────>β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚ 7. Create    β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚ cat-runtime- β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚ {cat_type}   β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚ Env vars:    β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚ - ORG_NAME   β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚ - CAT_TYPE   β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚ - MONGODB_URIβ”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚ - OPENAI_KEY β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚              β”‚              β”‚  8. Wait for β”‚              β”‚              β”‚
β”‚       β”‚              β”‚              β”‚  healthy     β”‚              β”‚              β”‚
β”‚       β”‚              β”‚              β”‚<─────────────│<─────────────│              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚  9. Success  β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚<─────────────│<─────────────│<─────────────│              β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚              β”‚              β”‚
β”‚                                                                                  β”‚
β”‚  RESULT:                                                                         β”‚
β”‚  - CAT configuration saved to MongoDB                                           β”‚
β”‚  - cat-runtime-{cat_type} service deployed                                      β”‚
β”‚  - Service is ready to handle chat requests                                     β”‚
β”‚                                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Flow 4: End User Chat (Normal User)

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         END USER CHAT FLOW                                       β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”‚
β”‚  β”‚   End    β”‚   β”‚  chat-   β”‚   β”‚   bff    β”‚   β”‚   cat-   β”‚   β”‚  MongoDB β”‚      β”‚
β”‚  β”‚   User   β”‚   β”‚   ui     β”‚   β”‚          β”‚   β”‚ runtime  β”‚   β”‚          β”‚      β”‚
β”‚  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”˜      β”‚
β”‚       β”‚              β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚ 1. Access    β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚ chat.bast.ai β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       │─────────────>β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚ 2. Login     β”‚ 3. Auth      β”‚              β”‚              β”‚              β”‚
β”‚       β”‚ (org/CAT     β”‚ (WorkOS/     β”‚              β”‚              β”‚              β”‚
β”‚       β”‚  context)    β”‚  Google/MS)  β”‚              β”‚              β”‚              β”‚
β”‚       │─────────────>│─────────────>β”‚              β”‚              β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚ 4. Send      β”‚ 5. tRPC      β”‚ 6. Route to  β”‚              β”‚              β”‚
β”‚       β”‚ Message      β”‚ chat.send    β”‚ cat-runtime  β”‚              β”‚              β”‚
β”‚       │─────────────>│─────────────>│─────────────>β”‚              β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚ 7. Load CAT  β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚ config       β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              │─────────────>β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚ 8. Process   β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚ with:        β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚ - CAT OS     β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚ - Knowledge  β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚ - Agents     β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚ 9. Save      β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚ conversation β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              │─────────────>β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚ 10. Stream   β”‚              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚ Response     β”‚<─────────────│<─────────────│              β”‚              β”‚
β”‚       β”‚<─────────────│              β”‚              β”‚              β”‚              β”‚
β”‚       β”‚              β”‚              β”‚              β”‚              β”‚              β”‚
β”‚                                                                                  β”‚
β”‚  BFF ROUTING LOGIC:                                                              β”‚
β”‚  - Extract org_id and cat_type from JWT or request                              β”‚
β”‚  - Route to: cat-runtime-{cat_type} service                                     β”‚
β”‚  - Each cat-runtime knows its ORG_NAME and CAT_TYPE from env vars               β”‚
β”‚                                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Deployment Methods

Overview

The platform uses three deployment methods depending on the resource type:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         DEPLOYMENT METHODS BY RESOURCE                           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  TERRAFORM (Infrastructure)           CI/CD PIPELINE (Code Deployments)         β”‚
β”‚  ─────────────────────────────        ─────────────────────────────────         β”‚
β”‚  β€’ DuploCloud Infrastructure          β€’ cat-runtime image updates               β”‚
β”‚  β€’ Shared Tenants (dev-shared)        β€’ org-services image updates              β”‚
β”‚  β€’ AWS Services (S3, Secrets)         β€’ UI services (admin-ui, chat-ui, bff)    β”‚
β”‚  β€’ ECR Repositories                   β€’ Rollbacks                                β”‚
β”‚  β€’ Initial service templates          β€’ Triggered by: git merge/tag             β”‚
β”‚  β€’ Triggered by: manual CLI                                                      β”‚
β”‚                                                                                  β”‚
β”‚  ADMIN UI (Self-Service)              BOTH PATHS AVAILABLE                       β”‚
β”‚  ───────────────────────              ────────────────────                       β”‚
β”‚  β€’ Create Organization β†’ deploys      β€’ Organization: Admin UI (standard)       β”‚
β”‚    tenant + org-services                           or Terraform (custom)        β”‚
β”‚  β€’ Create CAT β†’ deploys cat-runtime   β€’ Org Tenant: Admin UI or Terraform       β”‚
β”‚  β€’ CAT OS (config only)               β€’ CAT Runtime: Admin UI                    β”‚
β”‚  β€’ Knowledge Domains (config only)                                               β”‚
β”‚  β€’ Agent Pools (config only)                                                     β”‚
β”‚  β€’ User management                                                               β”‚
β”‚                                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Method Summary Table

Resource Admin UI Terraform CI/CD Pipeline Notes
Infrastructure - Yes - One-time setup
Shared Tenant - Yes - {env}-shared
Organization Yes Yes - Admin UI recommended
Org Tenant Auto Yes - Created with org
org-services Auto Yes Yes Auto-deployed with org
CAT Yes - - Admin UI only
cat-runtime Auto - Yes Auto-deployed with CAT
CAT OS Yes - - Config only
Knowledge Domain Yes - - Config only
Agent Pool Yes - - Config only
UI Services - Yes Yes Pipeline for updates

When to Use Each Method

Scenario Recommended Method
New environment setup Terraform
Standard org onboarding Admin UI
Custom org config (HIPAA/SOC2) Terraform + Admin UI
Bulk org creation Terraform
New CAT deployment Admin UI
Code deployment/update CI/CD Pipeline
Emergency rollback Terraform or DuploCloud Console
Infrastructure scaling Terraform

Service Creation Workflows

Workflow 1: Environment Setup (One-time)

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    ENVIRONMENT SETUP CHECKLIST                                   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  1. AWS/DuploCloud Infrastructure                                               β”‚
β”‚     [ ] Create DuploCloud infrastructure (bast-infra)                           β”‚
β”‚     [ ] Configure EKS cluster                                                   β”‚
β”‚     [ ] Set up VPC, subnets, security groups                                    β”‚
β”‚     [ ] Create ECR repositories (bastai-cat, bast-org-services, bast-cat-runtime)β”‚
β”‚     [ ] Configure IAM roles and IRSA                                            β”‚
β”‚                                                                                  β”‚
β”‚  2. DuploCloud Tenant (per environment)                                         β”‚
β”‚     [ ] Create tenant (dev-bastai for dev, prod-bastai for demo/prod)            β”‚
β”‚     [ ] Configure tenant network policies                                       β”‚
β”‚     [ ] Set up ingress/ALB                                                      β”‚
β”‚                                                                                  β”‚
β”‚  3. External Services                                                           β”‚
β”‚     [ ] MongoDB Atlas cluster setup                                             β”‚
β”‚     [ ] Create databases and initial collections                                β”‚
β”‚     [ ] Configure network peering (VPC to Atlas)                                β”‚
β”‚     [ ] Set up connection strings as secrets                                    β”‚
β”‚                                                                                  β”‚
β”‚  4. Platform Services                                                           β”‚
β”‚     [ ] Deploy platform-api (includes auth endpoints)                           β”‚
β”‚     [ ] Configure external auth provider (WorkOS) if needed                     β”‚
β”‚                                                                                  β”‚
β”‚  5. UI Services (Shared)                                                        β”‚
β”‚     [ ] Deploy admin-ui (dev-admin-ui, demo-admin-ui)                           β”‚
β”‚     [ ] Deploy chat-ui (dev-chat-ui, demo-chat-ui)                              β”‚
β”‚     [ ] Deploy bff (dev-bff, demo-bff)                                          β”‚
β”‚     [ ] Configure ingress routes                                                β”‚
β”‚                                                                                  β”‚
β”‚  6. Bitbucket Pipeline Configuration                                            β”‚
β”‚     [ ] Set repository variables (ECR, AWS, DUPLO, etc.)                        β”‚
β”‚     [ ] Test dev branch pipeline                                                β”‚
β”‚     [ ] Test main branch pipeline                                               β”‚
β”‚                                                                                  β”‚
β”‚  7. DNS and Certificates                                                        β”‚
β”‚     [ ] Configure Route53 records                                               β”‚
β”‚     [ ] Set up SSL certificates (ACM)                                           β”‚
β”‚     [ ] Verify HTTPS access to all services                                     β”‚
β”‚                                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Workflow 2: User Registration, Login & Organization Access

This workflow defines how users register, authenticate, and gain access to organizations.

Implementation Status: βœ… Full Stack Complete

Component Status Location
User DTOs βœ… Complete src/apis/platform/bast_platform_api/dto/user.py
Auth Service (JWT) βœ… Complete src/apis/platform/bast_platform_api/svc/auth_service.py
User Service βœ… Complete src/apis/platform/bast_platform_api/svc/user_service.py
Auth Router βœ… Complete src/apis/platform/bast_platform_api/bp/auth.py
OAuth Router (Google/Microsoft) βœ… Complete src/apis/platform/bast_platform_api/bp/oauth.py
BFF Auth Router βœ… Complete bast-admin-ui/apps/bff/src/trpc/auth.ts
Admin UI Auth Types βœ… Complete bast-admin-ui/apps/admin-ui/src/types/auth.ts
Admin UI Auth Context βœ… Complete bast-admin-ui/apps/admin-ui/src/lib/auth-context.tsx
Admin UI Login Screen βœ… Complete bast-admin-ui/apps/admin-ui/src/components/auth/LoginScreen.tsx
Admin UI Register Screen βœ… Complete bast-admin-ui/apps/admin-ui/src/components/auth/RegisterScreen.tsx
Admin UI Auth Callback βœ… Complete bast-admin-ui/apps/admin-ui/src/components/auth/AuthCallback.tsx

Implemented Endpoints: | Endpoint | Method | Description | |----------|--------|-------------| | /api/v1/platform/auth/register | POST | Register new user (with optional invite_token) | | /api/v1/platform/auth/login | POST | Login, returns JWT access + refresh tokens | | /api/v1/platform/auth/refresh | POST | Refresh access token | | /api/v1/platform/auth/me | GET | Get current user info (requires Bearer token) | | /api/v1/platform/auth/password/change | POST | Change password | | /api/v1/platform/auth/invitations/{token} | GET | Get invitation details | | /api/v1/platform/auth/invitations/{token}/accept | POST | Accept invitation |

OAuth Endpoints (Sign in with Google/Microsoft): | Endpoint | Method | Description | |----------|--------|-------------| | /api/v1/platform/auth/oauth/google/auth | GET | Initiate Google OAuth flow (redirects to Google) | | /api/v1/platform/auth/oauth/google/callback | GET | Google OAuth callback (creates user, redirects to frontend) | | /api/v1/platform/auth/oauth/microsoft/auth | GET | Initiate Microsoft OAuth flow (redirects to Microsoft) | | /api/v1/platform/auth/oauth/microsoft/callback | GET | Microsoft OAuth callback (creates user, redirects to frontend) | | /api/v1/platform/auth/oauth/exchange-token | POST | Exchange OAuth session token for JWT tokens |

OAuth Flow: 1. Frontend redirects user to /auth/oauth/google/auth or /auth/oauth/microsoft/auth 2. User authenticates with OAuth provider 3. Provider redirects to callback URL with authorization code 4. Platform API creates/updates user, generates session token 5. Redirects to frontend /auth/callback?session_token=<token> 6. Frontend calls /auth/oauth/exchange-token with session token 7. Returns JWT tokens + user info (same format as login)

JWT Token Configuration: - Access Token: 15 minutes expiry - Refresh Token: 7 days expiry - Algorithm: HS256 - Claims: sub (user_id), email, name, orgs, current_org

BFF Auth Router (tRPC):

The BFF provides a tRPC router that proxies auth requests to the Platform API:

Procedure Type Description
auth.register Mutation Register new user (proxies to Platform API)
auth.login Mutation Email/password login
auth.refresh Mutation Refresh JWT access token
auth.me Query Get current user info
auth.changePassword Mutation Change user password
auth.getInvitation Query Get invitation details by token
auth.acceptInvitation Mutation Accept organization invitation
auth.getGoogleAuthUrl Query Get Google OAuth redirect URL
auth.getMicrosoftAuthUrl Query Get Microsoft OAuth redirect URL
auth.exchangeOAuthToken Mutation Exchange OAuth session token for JWT

Admin UI Auth Architecture:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         ADMIN UI AUTH ARCHITECTURE                               β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  main.tsx                                                                        β”‚
β”‚  ─────────                                                                       β”‚
β”‚  <TRPCProvider>                                                                  β”‚
β”‚    <AuthProvider>        ← Auth context wraps entire app                        β”‚
β”‚      <App />                                                                     β”‚
β”‚    </AuthProvider>                                                               β”‚
β”‚  </TRPCProvider>                                                                 β”‚
β”‚                                                                                  β”‚
β”‚  AuthProvider (lib/auth-context.tsx)                                            β”‚
β”‚  ───────────────────────────────────                                            β”‚
β”‚  - Manages auth state (user, tokens, currentOrg, isAuthenticated)               β”‚
β”‚  - Persists tokens/user to localStorage                                         β”‚
β”‚  - Provides methods: login, register, logout, loginWithGoogle,                  β”‚
β”‚                      loginWithMicrosoft, exchangeOAuthToken,                    β”‚
β”‚                      setCurrentOrg, refreshTokens                               β”‚
β”‚                                                                                  β”‚
β”‚  Auth Screens (components/auth/)                                                β”‚
β”‚  ───────────────────────────────                                                β”‚
β”‚  - LoginScreen.tsx      Email/password + Google/Microsoft OAuth buttons         β”‚
β”‚  - RegisterScreen.tsx   Account creation with password validation               β”‚
β”‚  - AuthCallback.tsx     OAuth callback handler (exchanges session token)        β”‚
β”‚                                                                                  β”‚
β”‚  Auth Types (types/auth.ts)                                                     β”‚
β”‚  ─────────────────────────                                                      β”‚
β”‚  - User, TokenPair, OrgMembership                                               β”‚
β”‚  - AuthState, AuthContextType                                                   β”‚
β”‚  - LoginInput, RegisterInput                                                    β”‚
β”‚                                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Auth State Flow:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                              AUTH STATE FLOW                                     β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  1. App Start                                                                   β”‚
β”‚     ─────────                                                                   β”‚
β”‚     AuthProvider checks localStorage for existing tokens/user                   β”‚
β”‚     If valid β†’ isAuthenticated = true, show dashboard                          β”‚
β”‚     If invalid β†’ isAuthenticated = false, show LoginScreen                     β”‚
β”‚                                                                                  β”‚
β”‚  2. Email/Password Login                                                        β”‚
β”‚     ─────────────────────                                                       β”‚
β”‚     LoginScreen β†’ useAuth().login() β†’ BFF auth.login β†’ Platform API            β”‚
β”‚     On success: store tokens + user in localStorage, set isAuthenticated       β”‚
β”‚                                                                                  β”‚
β”‚  3. OAuth Login                                                                 β”‚
β”‚     ───────────                                                                 β”‚
β”‚     a) User clicks "Continue with Google/Microsoft"                            β”‚
β”‚     b) loginWithGoogle/Microsoft() redirects to Platform API OAuth endpoint    β”‚
β”‚     c) Platform API redirects to provider (Google/Microsoft)                   β”‚
β”‚     d) User authenticates, provider redirects to callback                      β”‚
β”‚     e) Platform API creates user, generates session token                      β”‚
β”‚     f) Redirects to Admin UI /auth/callback?session_token=xxx                  β”‚
β”‚     g) AuthCallback component calls exchangeOAuthToken()                       β”‚
β”‚     h) BFF auth.exchangeOAuthToken β†’ Platform API                              β”‚
β”‚     i) On success: store tokens, set isAuthenticated                           β”‚
β”‚                                                                                  β”‚
β”‚  4. Token Storage                                                               β”‚
β”‚     ─────────────                                                               β”‚
β”‚     localStorage keys:                                                          β”‚
β”‚     - bast_auth_tokens: { access_token, refresh_token, token_type, expires_in }β”‚
β”‚     - bast_auth_user: { id, email, name, status, organizations, ... }          β”‚
β”‚                                                                                  β”‚
β”‚  5. Logout                                                                      β”‚
β”‚     ──────                                                                      β”‚
β”‚     useAuth().logout() β†’ clear localStorage β†’ set isAuthenticated = false      β”‚
β”‚                                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    USER REGISTRATION & AUTHENTICATION                            β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚ FLOW 1: New User Registration                                               β”‚β”‚
β”‚  β”‚ ─────────────────────────────                                               β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚β”‚
β”‚  β”‚  β”‚  Admin UI   │────>β”‚     BFF     │────>β”‚      Platform API           β”‚   β”‚β”‚
β”‚  β”‚  β”‚  /register  β”‚     β”‚             β”‚     β”‚  POST /auth/register        β”‚   β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚β”‚
β”‚  β”‚                                                    β”‚                        β”‚β”‚
β”‚  β”‚  Input:                                           β”‚                        β”‚β”‚
β”‚  β”‚  β€’ email                                          β–Ό                        β”‚β”‚
β”‚  β”‚  β€’ password                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                β”‚β”‚
β”‚  β”‚  β€’ name                                  β”‚    MongoDB      β”‚                β”‚β”‚
β”‚  β”‚                                          β”‚  users (status: β”‚                β”‚β”‚
β”‚  β”‚  Process:                                β”‚   "pending" or  β”‚                β”‚β”‚
β”‚  β”‚  1. Validate email uniqueness            β”‚   "active")     β”‚                β”‚β”‚
β”‚  β”‚  2. Hash password (bcrypt)               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                β”‚β”‚
β”‚  β”‚  3. Create user with status="active"                                        β”‚β”‚
β”‚  β”‚  4. Generate JWT tokens                                                     β”‚β”‚
β”‚  β”‚  5. User has NO organizations yet                                           β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  Result:                                                                    β”‚β”‚
β”‚  β”‚  β€’ User logged in but with empty organizations[]                            β”‚β”‚
β”‚  β”‚  β€’ Redirect to "Create Organization" screen                                 β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚ FLOW 2: User Login                                                          β”‚β”‚
β”‚  β”‚ ─────────────────                                                           β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚β”‚
β”‚  β”‚  β”‚  Admin UI   │────>β”‚     BFF     │────>β”‚      Platform API           β”‚   β”‚β”‚
β”‚  β”‚  β”‚   /login    β”‚     β”‚             β”‚     β”‚  POST /auth/login           β”‚   β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚β”‚
β”‚  β”‚                                                    β”‚                        β”‚β”‚
β”‚  β”‚  Input:                                           β”‚                        β”‚β”‚
β”‚  β”‚  β€’ email                                          β–Ό                        β”‚β”‚
β”‚  β”‚  β€’ password                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                β”‚β”‚
β”‚  β”‚                                          β”‚  Validate creds β”‚                β”‚β”‚
β”‚  β”‚  Process:                                β”‚  Generate JWT   β”‚                β”‚β”‚
β”‚  β”‚  1. Validate credentials                 β”‚  Update last_   β”‚                β”‚β”‚
β”‚  β”‚  2. Generate access + refresh tokens     β”‚  login          β”‚                β”‚β”‚
β”‚  β”‚  3. Check user.organizations[]           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  Routing based on organizations:                                            β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚β”‚
β”‚  β”‚  β”‚  IF organizations.length == 0:                                        β”‚  β”‚β”‚
β”‚  β”‚  β”‚    β†’ Redirect to "Create Organization" screen                         β”‚  β”‚β”‚
β”‚  β”‚  β”‚    β†’ User CANNOT access any other features until org created          β”‚  β”‚β”‚
β”‚  β”‚  β”‚                                                                        β”‚  β”‚β”‚
β”‚  β”‚  β”‚  IF organizations.length == 1:                                        β”‚  β”‚β”‚
β”‚  β”‚  β”‚    β†’ Auto-select that organization                                    β”‚  β”‚β”‚
β”‚  β”‚  β”‚    β†’ Redirect to Dashboard                                            β”‚  β”‚β”‚
β”‚  β”‚  β”‚                                                                        β”‚  β”‚β”‚
β”‚  β”‚  β”‚  IF organizations.length > 1:                                         β”‚  β”‚β”‚
β”‚  β”‚  β”‚    β†’ Show "Select Organization" screen                                β”‚  β”‚β”‚
β”‚  β”‚  β”‚    β†’ User picks org, then redirect to Dashboard                       β”‚  β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚ FLOW 3: First Organization Creation (User becomes Owner)                   β”‚β”‚
β”‚  β”‚ ────────────────────────────────────────────────────────                   β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  Trigger: User with 0 organizations clicks "Create Organization"           β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚β”‚
β”‚  β”‚  β”‚  Admin UI   │────>β”‚     BFF     │────>β”‚      Platform API           β”‚   β”‚β”‚
β”‚  β”‚  β”‚ Create Org  β”‚     β”‚             β”‚     β”‚  POST /organizations        β”‚   β”‚β”‚
β”‚  β”‚  β”‚   Form      β”‚     β”‚             β”‚     β”‚  (with user_id from JWT)    β”‚   β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚β”‚
β”‚  β”‚                                                    β”‚                        β”‚β”‚
β”‚  β”‚  Input:                                           β”‚                        β”‚β”‚
β”‚  β”‚  β€’ org name                                       β–Ό                        β”‚β”‚
β”‚  β”‚  β€’ org slug                              β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                β”‚β”‚
β”‚  β”‚  β€’ environment (dev/demo/prod)           β”‚   Platform API  β”‚                β”‚β”‚
β”‚  β”‚  β€’ (user_id from JWT automatically)      β”‚   Operations:   β”‚                β”‚β”‚
β”‚  β”‚                                          β”‚                 β”‚                β”‚β”‚
β”‚  β”‚  Process:                                β”‚  1. Create org  β”‚                β”‚β”‚
β”‚  β”‚  1. Create organization record           β”‚  2. Add user as β”‚                β”‚β”‚
β”‚  β”‚  2. Add creating user as "owner"         β”‚     owner       β”‚                β”‚β”‚
β”‚  β”‚  3. Trigger provisioning if auto_prov    β”‚  3. Provision   β”‚                β”‚β”‚
β”‚  β”‚  4. Update user.organizations[]          β”‚     (optional)  β”‚                β”‚β”‚
β”‚  β”‚  5. Issue new JWT with org access        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  User Document Update:                                                      β”‚β”‚
β”‚  β”‚  ```json                                                                    β”‚β”‚
β”‚  β”‚  {                                                                          β”‚β”‚
β”‚  β”‚    "organizations": [                                                       β”‚β”‚
β”‚  β”‚      {                                                                      β”‚β”‚
β”‚  β”‚        "org_id": "<new_org_id>",                                           β”‚β”‚
β”‚  β”‚        "role": "owner",                                                    β”‚β”‚
β”‚  β”‚        "permissions": ["*"],   // Full access                              β”‚β”‚
β”‚  β”‚        "joined_at": "<timestamp>"                                          β”‚β”‚
β”‚  β”‚      }                                                                      β”‚β”‚
β”‚  β”‚    ]                                                                        β”‚β”‚
β”‚  β”‚  }                                                                          β”‚β”‚
β”‚  β”‚  ```                                                                        β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  Result: User now has org access β†’ Redirect to Dashboard                   β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    TEAM MEMBER INVITATION WORKFLOW                               β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚ FLOW 4: Invite Team Member                                                  β”‚β”‚
β”‚  β”‚ ─────────────────────────────                                               β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  Trigger: Org owner/admin invites a user by email                          β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”‚β”‚
β”‚  β”‚  β”‚  Admin UI   │────>β”‚     BFF     │────>β”‚      Platform API           β”‚   β”‚β”‚
β”‚  β”‚  β”‚  Team Page  β”‚     β”‚             β”‚     β”‚  POST /orgs/{id}/invitationsβ”‚   β”‚β”‚
β”‚  β”‚  β”‚  "Invite"   β”‚     β”‚             β”‚     β”‚                             β”‚   β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β”‚β”‚
β”‚  β”‚                                                    β”‚                        β”‚β”‚
β”‚  β”‚  Input:                                           β”‚                        β”‚β”‚
β”‚  β”‚  β€’ invitee_email                                  β–Ό                        β”‚β”‚
β”‚  β”‚  β€’ role (admin/member/viewer)            β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                β”‚β”‚
β”‚  β”‚                                          β”‚  Check if user  β”‚                β”‚β”‚
β”‚  β”‚                                          β”‚  exists         β”‚                β”‚β”‚
β”‚  β”‚                                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜                β”‚β”‚
β”‚  β”‚                                                   β”‚                         β”‚β”‚
β”‚  β”‚                    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚β”‚
β”‚  β”‚                    β–Ό                                                      β–Ό  β”‚β”‚
β”‚  β”‚           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚β”‚
β”‚  β”‚           β”‚ User EXISTS     β”‚                               β”‚User NOT     β”‚ β”‚β”‚
β”‚  β”‚           β”‚                 β”‚                               β”‚EXISTS       β”‚ β”‚β”‚
β”‚  β”‚           β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜                               β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜ β”‚β”‚
β”‚  β”‚                    β”‚                                               β”‚        β”‚β”‚
β”‚  β”‚                    β–Ό                                               β–Ό        β”‚β”‚
β”‚  β”‚           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚β”‚
β”‚  β”‚           β”‚ Create          β”‚                               β”‚Create       β”‚ β”‚β”‚
β”‚  β”‚           β”‚ invitation      β”‚                               β”‚invitation   β”‚ β”‚β”‚
β”‚  β”‚           β”‚ (status:        β”‚                               β”‚(status:     β”‚ β”‚β”‚
β”‚  β”‚           β”‚  pending)       β”‚                               β”‚ pending)    β”‚ β”‚β”‚
β”‚  β”‚           β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜                               β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜ β”‚β”‚
β”‚  β”‚                    β”‚                                               β”‚        β”‚β”‚
β”‚  β”‚                    β–Ό                                               β–Ό        β”‚β”‚
β”‚  β”‚           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                               β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚β”‚
β”‚  β”‚           β”‚ Send email:     β”‚                               β”‚Send email:  β”‚ β”‚β”‚
β”‚  β”‚           β”‚ "You've been    β”‚                               β”‚"You've been β”‚ β”‚β”‚
β”‚  β”‚           β”‚ invited to      β”‚                               β”‚invited to   β”‚ β”‚β”‚
β”‚  β”‚           β”‚ {org}. Login    β”‚                               β”‚{org}.       β”‚ β”‚β”‚
β”‚  β”‚           β”‚ to accept."     β”‚                               β”‚Register to  β”‚ β”‚β”‚
β”‚  β”‚           β”‚                 β”‚                               β”‚join."       β”‚ β”‚β”‚
β”‚  β”‚           β”‚ Link: /login    β”‚                               β”‚Link:        β”‚ β”‚β”‚
β”‚  β”‚           β”‚ ?invite={token} β”‚                               β”‚/register    β”‚ β”‚β”‚
β”‚  β”‚           β”‚                 β”‚                               β”‚?invite=     β”‚ β”‚β”‚
β”‚  β”‚           β”‚                 β”‚                               β”‚{token}      β”‚ β”‚β”‚
β”‚  β”‚           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                               β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  Invitation Document (MongoDB: invitations):                                β”‚β”‚
β”‚  β”‚  ```json                                                                    β”‚β”‚
β”‚  β”‚  {                                                                          β”‚β”‚
β”‚  β”‚    "_id": ObjectId,                                                         β”‚β”‚
β”‚  β”‚    "org_id": ObjectId,                                                      β”‚β”‚
β”‚  β”‚    "email": "invitee@example.com",                                          β”‚β”‚
β”‚  β”‚    "role": "member",                                                        β”‚β”‚
β”‚  β”‚    "token": "<secure_random_token>",                                        β”‚β”‚
β”‚  β”‚    "status": "pending",  // pending | accepted | expired | revoked          β”‚β”‚
β”‚  β”‚    "invited_by": ObjectId,  // user who sent invite                         β”‚β”‚
β”‚  β”‚    "created_at": datetime,                                                  β”‚β”‚
β”‚  β”‚    "expires_at": datetime,  // 7 days from creation                         β”‚β”‚
β”‚  β”‚    "accepted_at": datetime  // null until accepted                          β”‚β”‚
β”‚  β”‚  }                                                                          β”‚β”‚
β”‚  β”‚  ```                                                                        β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚ FLOW 5a: Accept Invitation (Existing User)                                 β”‚β”‚
β”‚  β”‚ ───────────────────────────────────────────                                 β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚β”‚
β”‚  β”‚  β”‚ Email Link    │────>β”‚  Admin UI   │────>β”‚      Platform API           β”‚ β”‚β”‚
β”‚  β”‚  β”‚ /login?invite β”‚     β”‚  (Login)    β”‚     β”‚  POST /invitations/{token}/ β”‚ β”‚β”‚
β”‚  β”‚  β”‚ ={token}      β”‚     β”‚             β”‚     β”‚       accept                β”‚ β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚β”‚
β”‚  β”‚                                                    β”‚                        β”‚β”‚
β”‚  β”‚  Process:                                         β”‚                        β”‚β”‚
β”‚  β”‚  1. User logs in normally                         β–Ό                        β”‚β”‚
β”‚  β”‚  2. Detect ?invite={token} param        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                β”‚β”‚
β”‚  β”‚  3. Validate token (not expired)        β”‚  1. Validate    β”‚                β”‚β”‚
β”‚  β”‚  4. Show "Accept invitation" prompt     β”‚     token       β”‚                β”‚β”‚
β”‚  β”‚  5. On accept:                          β”‚  2. Add org to  β”‚                β”‚β”‚
β”‚  β”‚     - Add org to user.organizations[]   β”‚     user        β”‚                β”‚β”‚
β”‚  β”‚     - Mark invitation as accepted       β”‚  3. Update      β”‚                β”‚β”‚
β”‚  β”‚     - Issue new JWT with org access     β”‚     invitation  β”‚                β”‚β”‚
β”‚  β”‚                                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  User Document Update:                                                      β”‚β”‚
β”‚  β”‚  ```json                                                                    β”‚β”‚
β”‚  β”‚  {                                                                          β”‚β”‚
β”‚  β”‚    "organizations": [                                                       β”‚β”‚
β”‚  β”‚      { "org_id": "existing_org", "role": "owner" },                        β”‚β”‚
β”‚  β”‚      { "org_id": "invited_org", "role": "member", "joined_at": "..." }     β”‚β”‚
β”‚  β”‚    ]                                                                        β”‚β”‚
β”‚  β”‚  }                                                                          β”‚β”‚
β”‚  β”‚  ```                                                                        β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚ FLOW 5b: Accept Invitation (New User - Register First)                     β”‚β”‚
β”‚  β”‚ ──────────────────────────────────────────────────────                     β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚β”‚
β”‚  β”‚  β”‚ Email Link    │────>β”‚  Admin UI   │────>β”‚      Platform API           β”‚ β”‚β”‚
β”‚  β”‚  β”‚/register?     β”‚     β”‚ (Register)  β”‚     β”‚  POST /auth/register        β”‚ β”‚β”‚
β”‚  β”‚  β”‚invite={token} β”‚     β”‚             β”‚     β”‚  (with invite_token)        β”‚ β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚β”‚
β”‚  β”‚                                                    β”‚                        β”‚β”‚
β”‚  β”‚  Process:                                         β”‚                        β”‚β”‚
β”‚  β”‚  1. User fills registration form                  β–Ό                        β”‚β”‚
β”‚  β”‚  2. Email pre-filled from invitation     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                β”‚β”‚
β”‚  β”‚  3. Submit with invite_token             β”‚  1. Create user β”‚                β”‚β”‚
β”‚  β”‚  4. Create user account                  β”‚  2. Auto-accept β”‚                β”‚β”‚
β”‚  β”‚  5. Auto-accept invitation               β”‚     invitation  β”‚                β”‚β”‚
β”‚  β”‚  6. Add org to user.organizations[]      β”‚  3. Add org     β”‚                β”‚β”‚
β”‚  β”‚  7. Issue JWT with org access            β”‚  4. Issue JWT   β”‚                β”‚β”‚
β”‚  β”‚                                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  New User Document:                                                         β”‚β”‚
β”‚  β”‚  ```json                                                                    β”‚β”‚
β”‚  β”‚  {                                                                          β”‚β”‚
β”‚  β”‚    "email": "invitee@example.com",                                          β”‚β”‚
β”‚  β”‚    "name": "New User",                                                      β”‚β”‚
β”‚  β”‚    "status": "active",                                                      β”‚β”‚
β”‚  β”‚    "organizations": [                                                       β”‚β”‚
β”‚  β”‚      { "org_id": "invited_org", "role": "member", "joined_at": "..." }     β”‚β”‚
β”‚  β”‚    ]                                                                        β”‚β”‚
β”‚  β”‚  }                                                                          β”‚β”‚
β”‚  β”‚  ```                                                                        β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  Result: New user directly lands in Dashboard (has org access)             β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    ACCESS CONTROL SUMMARY                                        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  User State Transitions:                                                        β”‚
β”‚  ─────────────────────────                                                      β”‚
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”      β”‚
β”‚  β”‚   Guest     │───>β”‚ Registered  │───>β”‚  Has Org    │───>β”‚   Active    β”‚      β”‚
β”‚  β”‚  (No Auth)  β”‚    β”‚ (No Org)    β”‚    β”‚  Access     β”‚    β”‚   User      β”‚      β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜      β”‚
β”‚        β”‚                  β”‚                  β”‚                  β”‚              β”‚
β”‚        β”‚                  β”‚                  β”‚                  β”‚              β”‚
β”‚    Can only:          Can only:          Can access:       Full access:        β”‚
β”‚    - Register         - Create org       - Dashboard       - All features      β”‚
β”‚    - Login            - Accept invite    - Org settings    - Team mgmt         β”‚
β”‚                       - View "no org"    - CAT Builder     - Billing           β”‚
β”‚                         screen                                                  β”‚
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚ Roles & Permissions (per Organization)                                      β”‚β”‚
β”‚  β”‚ ──────────────────────────────────────                                      β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚β”‚
β”‚  β”‚  β”‚ Role       β”‚ Permissions                                              β”‚  β”‚β”‚
β”‚  β”‚  β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€  β”‚β”‚
β”‚  β”‚  β”‚ owner      β”‚ All permissions + delete org + transfer ownership        β”‚  β”‚β”‚
β”‚  β”‚  β”‚ admin      β”‚ Team management + CAT CRUD + settings                    β”‚  β”‚β”‚
β”‚  β”‚  β”‚ member     β”‚ CAT read/write + knowledge management                    β”‚  β”‚β”‚
β”‚  β”‚  β”‚ viewer     β”‚ Read-only access to CATs and analytics                   β”‚  β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                                                  β”‚
β”‚  Protected Routes (Admin UI):                                                   β”‚
β”‚  ────────────────────────────                                                   β”‚
β”‚                                                                                  β”‚
β”‚  Public (no auth):           Auth Required:          Org Required:              β”‚
β”‚  - /login                    - /create-org           - /dashboard               β”‚
β”‚  - /register                 - /select-org           - /cat-builder/*           β”‚
β”‚  - /forgot-password          - /invitations          - /team                    β”‚
β”‚  - /reset-password                                   - /settings                β”‚
β”‚                                                      - /analytics               β”‚
β”‚                                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Workflow 3: New Organization Onboarding

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    NEW ORGANIZATION ONBOARDING                                   β”‚
β”‚                    (HIPAA/SOC2 Compliant)                                        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  Trigger: Platform Admin creates org via admin-ui                               β”‚
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚ PHASE 1: MongoDB Cluster Provisioning (Production Only)                     β”‚β”‚
β”‚  β”‚ ───────────────────────────────────────────────────────                     β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  1. [ ] Create MongoDB Atlas cluster: prod-{org}                            β”‚β”‚
β”‚  β”‚         - Tier: M30 or higher (HIPAA eligible)                              β”‚β”‚
β”‚  β”‚         - Region: Same as DuploCloud tenant                                 β”‚β”‚
β”‚  β”‚         - Encryption: At-rest enabled                                       β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  2. [ ] Configure cluster security:                                         β”‚β”‚
β”‚  β”‚         - [ ] Enable audit logging                                          β”‚β”‚
β”‚  β”‚         - [ ] Configure IP allowlist (VPC peering)                          β”‚β”‚
β”‚  β”‚         - [ ] Create database user with least privilege                     β”‚β”‚
β”‚  β”‚         - [ ] Enable TLS 1.2+ enforcement                                   β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  3. [ ] Sign BAA (Business Associate Agreement):                            β”‚β”‚
β”‚  β”‚         - [ ] MongoDB Atlas BAA for cluster                                 β”‚β”‚
β”‚  β”‚         - [ ] Document BAA reference in org record                          β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  4. [ ] Set up VPC peering:                                                 β”‚β”‚
β”‚  β”‚         - [ ] Peer Atlas cluster to DuploCloud VPC                          β”‚β”‚
β”‚  β”‚         - [ ] Configure security groups                                     β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  5. [ ] Store connection string:                                            β”‚β”‚
β”‚  β”‚         - [ ] AWS Secrets Manager: bast/prod/mongodb/{org}                  β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚ PHASE 2: Database Setup                                                     β”‚β”‚
β”‚  β”‚ ──────────────────────                                                      β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  1. [ ] Create database collections:                                        β”‚β”‚
β”‚  β”‚         - organizations                                                     β”‚β”‚
β”‚  β”‚         - users                                                             β”‚β”‚
β”‚  β”‚         - cats                                                              β”‚β”‚
β”‚  β”‚         - cat_os                                                            β”‚β”‚
β”‚  β”‚         - knowledge_domains                                                 β”‚β”‚
β”‚  β”‚         - agent_pools                                                       β”‚β”‚
β”‚  β”‚         - themes                                                            β”‚β”‚
β”‚  β”‚         - conversations                                                     β”‚β”‚
β”‚  β”‚         - feedback                                                          β”‚β”‚
β”‚  β”‚         - analytics                                                         β”‚β”‚
β”‚  β”‚         - audit_logs                                                        β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  2. [ ] Create indexes for performance                                      β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  3. [ ] Initialize org record with:                                         β”‚β”‚
β”‚  β”‚         - org_id, org_name                                                  β”‚β”‚
β”‚  β”‚         - baa_signed: true, baa_date: <date>                               β”‚β”‚
β”‚  β”‚         - compliance: ["HIPAA", "SOC2"]                                    β”‚β”‚
β”‚  β”‚         - created_at, created_by                                           β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚ PHASE 3: AWS Resources                                                      β”‚β”‚
β”‚  β”‚ ────────────────────                                                        β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  1. [ ] Create S3 bucket: s3://bast-prod-{org}-data                        β”‚β”‚
β”‚  β”‚         - [ ] Enable encryption (SSE-S3 or SSE-KMS)                         β”‚β”‚
β”‚  β”‚         - [ ] Enable versioning                                             β”‚β”‚
β”‚  β”‚         - [ ] Configure lifecycle policies                                  β”‚β”‚
β”‚  β”‚         - [ ] Block public access                                           β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  2. [ ] Create DuploCloud tenant: prod-{org}                               β”‚β”‚
β”‚  β”‚         - [ ] Configure namespace                                           β”‚β”‚
β”‚  β”‚         - [ ] Set up ingress/ALB                                           β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚ PHASE 4: Service Deployment                                                 β”‚β”‚
β”‚  β”‚ ──────────────────────────                                                  β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  1. [ ] Deploy org-services:                                                β”‚β”‚
β”‚  β”‚         - Service name: org-services                                        β”‚β”‚
β”‚  β”‚         - Env: ORG_ID={org_id}         (MongoDB ObjectId)                  β”‚β”‚
β”‚  β”‚         - Env: ORG_SLUG={org_slug}     (e.g., "acme-corp")                 β”‚β”‚
β”‚  β”‚         - Env: ORG_MONGODB_URI=<from secrets manager>                      β”‚β”‚
β”‚  β”‚         - Database: {org_slug}_data    (e.g., "acme-corp_data")           β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  2. [ ] Update org infrastructure record:                                   β”‚β”‚
β”‚  β”‚         - Set tenant info (tenant_name, tenant_id, infrastructure_name)    β”‚β”‚
β”‚  β”‚         - Set org_services deployment info                                  β”‚β”‚
β”‚  β”‚         - Set mongodb_uri in infrastructure.mongodb                        β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  3. [ ] Verify deployment:                                                  β”‚β”‚
β”‚  β”‚         - [ ] Health check: /health returns 200                            β”‚β”‚
β”‚  β”‚         - [ ] Info check: /info returns org_id, org_slug, databases       β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚ PHASE 5: User Setup                                                         β”‚β”‚
β”‚  β”‚ ─────────────────                                                           β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  1. [ ] Create org admin user:                                              β”‚β”‚
β”‚  β”‚         - [ ] Add to auth service (WorkOS/Google/MS)                       β”‚β”‚
β”‚  β”‚         - [ ] Assign Org Admin role                                        β”‚β”‚
β”‚  β”‚         - [ ] Add to org's users collection                                β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β”‚  2. [ ] Send welcome email:                                                 β”‚β”‚
β”‚  β”‚         - [ ] Login URL                                                     β”‚β”‚
β”‚  β”‚         - [ ] Initial setup instructions                                   β”‚β”‚
β”‚  β”‚         - [ ] Security best practices                                      β”‚β”‚
β”‚  β”‚                                                                              β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                                                  β”‚
β”‚  Verification Checklist:                                                        β”‚
β”‚  ───────────────────────                                                        β”‚
β”‚  [ ] MongoDB cluster healthy and accessible                                     β”‚
β”‚  [ ] BAA documentation complete                                                 β”‚
β”‚  [ ] org-services /health returns healthy                                       β”‚
β”‚  [ ] Org admin can login to admin-ui                                            β”‚
β”‚  [ ] Org admin sees empty CAT Builder dashboard                                 β”‚
β”‚  [ ] Audit logging captures login event                                         β”‚
β”‚                                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Workflow 2b: Non-Production Organization Setup

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                    NON-PRODUCTION ORG SETUP (Dev/Demo)                           β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  For dev/demo environments - uses shared MongoDB cluster                        β”‚
β”‚                                                                                  β”‚
β”‚  Steps:                                                                         β”‚
β”‚  ──────                                                                         β”‚
β”‚  1. [ ] Create database in shared cluster: {org_slug}_data                      β”‚
β”‚         - Example: "acme-corp_data" for org slug "acme-corp"                   β”‚
β”‚         - Collections: cats, cat_os, knowledge_domains, agent_pools, themes    β”‚
β”‚                                                                                  β”‚
β”‚  2. [ ] Create DuploCloud tenant: {env}-{org_slug}                             β”‚
β”‚         - Example: "dev-acme-corp" within nonprod infrastructure               β”‚
β”‚                                                                                  β”‚
β”‚  3. [ ] Deploy org-services to org tenant:                                      β”‚
β”‚         - Env: ORG_ID={org_id}                                                 β”‚
β”‚         - Env: ORG_SLUG={org_slug}                                             β”‚
β”‚         - Env: ORG_MONGODB_URI=mongodb://shared-cluster/...                    β”‚
β”‚                                                                                  β”‚
β”‚  4. [ ] Update org infrastructure record in Platform API                        β”‚
β”‚                                                                                  β”‚
β”‚  5. [ ] Create test users                                                       β”‚
β”‚                                                                                  β”‚
β”‚  IMPORTANT:                                                                     β”‚
β”‚  - NO PHI/PII data in non-production                                           β”‚
β”‚  - Use synthetic/anonymized data only                                          β”‚
β”‚  - No BAA required                                                              β”‚
β”‚                                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Workflow 3: New CAT Deployment

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        NEW CAT DEPLOYMENT                                        β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  Trigger: CAT Builder creates CAT via admin-ui                                  β”‚
β”‚                                                                                  β”‚
β”‚  Prerequisites:                                                                 β”‚
β”‚  ──────────────                                                                 β”‚
β”‚  [ ] At least one CAT OS created                                                β”‚
β”‚  [ ] At least one Knowledge Domain created (optional but recommended)           β”‚
β”‚  [ ] At least one Agent Pool created                                            β”‚
β”‚                                                                                  β”‚
β”‚  Automated Steps:                                                               β”‚
β”‚  ─────────────────                                                              β”‚
β”‚  1. [ ] Validate CAT configuration                                              β”‚
β”‚         - CAT OS exists and is valid                                            β”‚
β”‚         - Knowledge Domains exist (if specified)                                β”‚
β”‚         - Agent Pool exists                                                     β”‚
β”‚  2. [ ] Save CAT config to MongoDB (cats collection)                            β”‚
β”‚  3. [ ] Trigger cat-runtime service creation:                                   β”‚
β”‚         - Service name: cat-runtime-{cat_type}                                  β”‚
β”‚         - Image: bast-cat-runtime:latest                                        β”‚
β”‚         - Env: ORG_NAME, CAT_TYPE, MONGODB_URI, OPENAI_API_KEY                 β”‚
β”‚  4. [ ] Wait for service to be healthy                                          β”‚
β”‚  5. [ ] Update CAT status to "active"                                           β”‚
β”‚  6. [ ] Configure BFF routing (if dynamic)                                      β”‚
β”‚                                                                                  β”‚
β”‚  Service Creation (DuploCloud):                                                 β”‚
β”‚  ───────────────────────────────                                                β”‚
β”‚  ```bash                                                                        β”‚
β”‚  cat <<'EOF' | duploctl service create --tenant {tenant} --file -               β”‚
β”‚  {                                                                               β”‚
β”‚    "Name": "cat-runtime-{cat_type}",                                            β”‚
β”‚    "DockerImage": "{ecr}/bast-cat-runtime:latest",                              β”‚
β”‚    "AgentPlatform": 7,                                                          β”‚
β”‚    "Replicas": 1,                                                               β”‚
β”‚    "OtherDockerConfig": {                                                       β”‚
β”‚      "Env": [                                                                   β”‚
β”‚        {"Name": "ORG_NAME", "Value": "{org}"},                                  β”‚
β”‚        {"Name": "CAT_TYPE", "Value": "{cat_type}"},                             β”‚
β”‚        {"Name": "MONGODB_URI", "Value": "..."},                                 β”‚
β”‚        {"Name": "OPENAI_API_KEY", "Value": "..."}                               β”‚
β”‚      ]                                                                          β”‚
β”‚    }                                                                            β”‚
β”‚  }                                                                               β”‚
β”‚  EOF                                                                            β”‚
β”‚  ```                                                                            β”‚
β”‚                                                                                  β”‚
β”‚  Verification:                                                                  β”‚
β”‚  ─────────────                                                                  β”‚
β”‚  [ ] cat-runtime-{cat_type} /health returns healthy                             β”‚
β”‚  [ ] CAT appears in admin-ui CAT list                                           β”‚
β”‚  [ ] End user can access CAT via chat-ui                                        β”‚
β”‚                                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Monitoring and Observability

Monitoring Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        MONITORING ARCHITECTURE                                   β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚                         METRICS COLLECTION                                   β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β”‚  Services expose:                                                             β”‚β”‚
β”‚  β”‚  - /metrics (Prometheus format)                                              β”‚β”‚
β”‚  β”‚  - /health (liveness)                                                        β”‚β”‚
β”‚  β”‚  - /ready (readiness)                                                        β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”         β”‚β”‚
β”‚  β”‚  β”‚ org-servicesβ”‚  β”‚cat-runtime-*β”‚  β”‚  admin-ui   β”‚  β”‚   chat-ui   β”‚         β”‚β”‚
β”‚  β”‚  β”‚  :8080      β”‚  β”‚   :9090     β”‚  β”‚   :9090     β”‚  β”‚   :9090     β”‚         β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜         β”‚β”‚
β”‚  β”‚         β”‚                β”‚                β”‚                β”‚                 β”‚β”‚
β”‚  β”‚         β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                 β”‚β”‚
β”‚  β”‚                                   β”‚                                          β”‚β”‚
β”‚  β”‚                                   β–Ό                                          β”‚β”‚
β”‚  β”‚                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                 β”‚β”‚
β”‚  β”‚                          β”‚   Prometheus    β”‚                                 β”‚β”‚
β”‚  β”‚                          β”‚   (scraping)    β”‚                                 β”‚β”‚
β”‚  β”‚                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                 β”‚β”‚
β”‚  β”‚                                   β”‚                                          β”‚β”‚
β”‚  β”‚                                   β–Ό                                          β”‚β”‚
β”‚  β”‚                          β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                                 β”‚β”‚
β”‚  β”‚                          β”‚    Grafana      β”‚                                 β”‚β”‚
β”‚  β”‚                          β”‚  (dashboards)   β”‚                                 β”‚β”‚
β”‚  β”‚                          β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                                 β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚                         LOGGING                                              β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β”‚  All services log to stdout (JSON format)                                    β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”     β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”                    β”‚β”‚
β”‚  β”‚  β”‚ CloudWatch  β”‚ or  β”‚  Datadog    β”‚ or  β”‚    ELK      β”‚                    β”‚β”‚
β”‚  β”‚  β”‚   Logs      β”‚     β”‚             β”‚     β”‚   Stack     β”‚                    β”‚β”‚
β”‚  β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜     β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                    β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                                                  β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”β”‚
β”‚  β”‚                         ALERTING                                             β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β”‚  Alert Rules:                                                                β”‚β”‚
β”‚  β”‚  - Service down (health check fails)                                         β”‚β”‚
β”‚  β”‚  - High error rate (> 5% 5xx)                                                β”‚β”‚
β”‚  β”‚  - High latency (p99 > 5s)                                                   β”‚β”‚
β”‚  β”‚  - Resource exhaustion (CPU > 80%, Memory > 80%)                             β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β”‚  Channels:                                                                    β”‚β”‚
β”‚  β”‚  - Slack                                                                      β”‚β”‚
β”‚  β”‚  - PagerDuty                                                                  β”‚β”‚
β”‚  β”‚  - Email                                                                      β”‚β”‚
β”‚  β”‚                                                                               β”‚β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜β”‚
β”‚                                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Key Metrics per Service

Service Key Metrics
org-services Request rate, error rate, latency, DB connection pool
cat-runtime Chat messages/sec, LLM latency, knowledge retrieval time
admin-ui Page load time, API call latency, error rate
chat-ui Message send latency, WebSocket connections, stream errors
bff Request routing latency, upstream errors, connection pool

Summary: Service Count Formula

Per Environment

Component Count
Shared Infrastructure Fixed (MongoDB, Redis, S3, ECR, ALB)
Platform Services 1 (platform-api with auth)
UI Services 3 (admin-ui, chat-ui, bff)
Total Shared ~6-8 services

Per Organization

Component Count
org-services 1
monitoring 1 (Prometheus + Grafana)
Total per Org 2 services + cat-runtimes

Per CAT

Component Count
cat-runtime-{type} 1
Total per CAT 1 service

Example: 3 Orgs with varying CATs

Org org-services CAT Runtimes Total
bastai 1 3 (advisor, support, sales) 4
lurie 1 2 (patient, scheduling) 3
acme 1 1 (demo) 2
Org Total 3 6 9

Grand Total: 8 shared + 9 org/CAT = 17 services


Compliance Requirements

HIPAA Compliance Checklist

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        HIPAA COMPLIANCE CHECKLIST                                β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  Technical Safeguards:                                                          β”‚
β”‚  ─────────────────────                                                          β”‚
β”‚  [ ] Access Control                                                             β”‚
β”‚      - [ ] Unique user identification (user IDs)                               β”‚
β”‚      - [ ] Automatic logoff (session timeout)                                  β”‚
β”‚      - [ ] Encryption at rest (MongoDB, S3)                                    β”‚
β”‚      - [ ] Encryption in transit (TLS 1.2+)                                    β”‚
β”‚                                                                                  β”‚
β”‚  [ ] Audit Controls                                                             β”‚
β”‚      - [ ] MongoDB audit logging enabled                                       β”‚
β”‚      - [ ] Application-level audit logs                                        β”‚
β”‚      - [ ] CloudWatch/logging aggregation                                      β”‚
β”‚      - [ ] Log retention (6+ years)                                            β”‚
β”‚                                                                                  β”‚
β”‚  [ ] Integrity Controls                                                         β”‚
β”‚      - [ ] Data validation on input                                            β”‚
β”‚      - [ ] Checksums for data transfer                                         β”‚
β”‚                                                                                  β”‚
β”‚  [ ] Transmission Security                                                      β”‚
β”‚      - [ ] TLS 1.2+ for all connections                                        β”‚
β”‚      - [ ] VPC peering (no public internet for DB)                            β”‚
β”‚      - [ ] API authentication (JWT/OAuth)                                      β”‚
β”‚                                                                                  β”‚
β”‚  Administrative Safeguards:                                                     β”‚
β”‚  ──────────────────────────                                                     β”‚
β”‚  [ ] BAA signed with:                                                           β”‚
β”‚      - [ ] MongoDB Atlas (per production cluster)                              β”‚
β”‚      - [ ] AWS                                                                  β”‚
β”‚      - [ ] DuploCloud                                                          β”‚
β”‚      - [ ] OpenAI (if using for PHI)                                           β”‚
β”‚                                                                                  β”‚
β”‚  [ ] Workforce training documentation                                           β”‚
β”‚  [ ] Security incident procedures                                               β”‚
β”‚  [ ] Data backup and disaster recovery plan                                    β”‚
β”‚                                                                                  β”‚
β”‚  Physical Safeguards:                                                           β”‚
β”‚  ────────────────────                                                           β”‚
β”‚  [ ] Cloud provider certifications (AWS, MongoDB Atlas)                        β”‚
β”‚  [ ] No on-premise PHI storage                                                 β”‚
β”‚                                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

SOC2 Compliance Checklist

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                         SOC2 COMPLIANCE CHECKLIST                                β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚                                                                                  β”‚
β”‚  Security (Common Criteria):                                                    β”‚
β”‚  ───────────────────────────                                                    β”‚
β”‚  [ ] Access control policies                                                    β”‚
β”‚  [ ] Network security (firewalls, VPC)                                         β”‚
β”‚  [ ] Vulnerability management                                                   β”‚
β”‚  [ ] Security monitoring and alerting                                          β”‚
β”‚  [ ] Incident response procedures                                              β”‚
β”‚                                                                                  β”‚
β”‚  Availability:                                                                  β”‚
β”‚  ─────────────                                                                  β”‚
β”‚  [ ] Uptime SLA defined (99.9%)                                                β”‚
β”‚  [ ] Disaster recovery plan                                                    β”‚
β”‚  [ ] Backup procedures (daily, tested)                                         β”‚
β”‚  [ ] Multi-AZ deployment                                                        β”‚
β”‚                                                                                  β”‚
β”‚  Confidentiality:                                                               β”‚
β”‚  ────────────────                                                               β”‚
β”‚  [ ] Data classification                                                        β”‚
β”‚  [ ] Encryption at rest and in transit                                         β”‚
β”‚  [ ] Data retention policies                                                   β”‚
β”‚  [ ] Secure data disposal                                                       β”‚
β”‚                                                                                  β”‚
β”‚  Processing Integrity:                                                          β”‚
β”‚  ─────────────────────                                                          β”‚
β”‚  [ ] Input validation                                                           β”‚
β”‚  [ ] Error handling                                                             β”‚
β”‚  [ ] Quality assurance processes                                               β”‚
β”‚                                                                                  β”‚
β”‚  Privacy:                                                                       β”‚
β”‚  ────────                                                                       β”‚
β”‚  [ ] Privacy notice                                                             β”‚
β”‚  [ ] Consent management                                                         β”‚
β”‚  [ ] Data subject rights (access, deletion)                                    β”‚
β”‚                                                                                  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

BAA Tracking

Vendor BAA Required BAA Signed Date Reference
AWS Yes [ ] - -
MongoDB Atlas Yes (per cluster) [ ] - -
DuploCloud Yes [ ] - -
OpenAI Conditional* [ ] - -
WorkOS Yes [ ] - -

*OpenAI BAA required only if PHI is sent to OpenAI APIs. Consider using Azure OpenAI with BAA for healthcare use cases.

Per-Organization Compliance Record

Each production org should have documentation for:

Item Description Location
BAA Record MongoDB Atlas BAA for org's cluster org.baa_reference
Encryption Keys KMS key ARN (if BYOK) AWS Secrets Manager
Data Classification PHI/PII data inventory org.data_classification
Access Log Who has access to org data org.access_log
Audit Trail Security events audit_logs collection

Document History

Date Author Changes
2026-01-10 Claude Initial architecture document
2026-01-10 Claude Added HIPAA/SOC2 compliant MongoDB architecture (separate cluster per prod org)
2026-01-10 Claude Updated org onboarding workflow with BAA and compliance phases
2026-01-10 Claude Added Compliance Requirements section with HIPAA/SOC2 checklists
2026-01-10 Claude Updated environment structure: dev-shared/demo-shared/prod-shared infrastructures
2026-01-10 Claude Added shared tenant per env ({env}-shared) + org tenants ({env}-{org})
2026-01-10 Claude Updated MongoDB: bast-nonprod (dev), bast-demo (demo), prod-{org} (prod)
2026-01-10 Claude Replaced np-poc with dev-shared infrastructure; standardized naming to {env}-shared pattern
2026-01-10 Claude Added Deployment Methods section clarifying Terraform vs CI/CD vs Admin UI deployment paths
2026-01-10 Claude Implemented Platform API Authentication: user DTOs, auth service (JWT/bcrypt), user service (CRUD, memberships, invitations), auth router with register/login/refresh/me endpoints
2026-01-10 Claude Added OAuth support (Google/Microsoft Sign-In) to Platform API with oauth.py router, session token exchange flow
2026-01-10 Claude Implemented Admin UI Authentication: BFF auth tRPC router (auth.ts), auth context (auth-context.tsx), auth types (auth.ts), LoginScreen with OAuth buttons, RegisterScreen with password validation, AuthCallback for OAuth flow handling
2026-01-26 Claude Added Theme management to CAT model: Theme entity (1:N with Org, 1:1 optional with CAT), themes collection, theme_id field in CAT, ThemeConfig properties (colors, typography, radius, shadow, button_style, etc.)