Skip to content

Entity-Relationship Diagram

Tenancy Hierarchy

Organization
├── OrganizationMember (→ User, role)
├── Team
│   ├── TeamMembership (→ User, role)
│   └── Workspace
│       └── Project
│           ├── Task
│           └── WorkflowInstance
├── Skill (org-scoped)
├── Config (org-scoped)
└── Secret (org/team/workspace-scoped)

Core Models

┌──────────────────┐     ┌──────────────────┐     ┌──────────────────┐
│   Organization   │     │      Team        │     │    Workspace     │
│──────────────────│     │──────────────────│     │──────────────────│
│ name             │◄────│ organization_id  │◄────│ team_id          │
│ website          │     │ name, slug       │     │ name, slug       │
│ groups M2M       │     │                  │     │ is_active        │
└──────────────────┘     └──────────────────┘     └────────┬─────────┘
                                                  ┌────────▼─────────┐
                                                  │     Project      │
                                                  │──────────────────│
                                                  │ workspace_id     │
                                                  │ name, slug       │
                                                  │ settings JSON    │
                                                  └────────┬─────────┘
                              ┌─────────────────────────────┼──────────────────┐
                              │                             │                  │
                     ┌────────▼─────────┐          ┌────────▼─────────┐        │
                     │      Task        │          │ WorkflowInstance │        │
                     │──────────────────│          │──────────────────│        │
                     │ project_id       │          │ project_id       │        │
                     │ agent_image      │          │ template_id      │        │
                     │ status           │          │ status           │        │
                     │ brief_key        │          │ temporal_wf_id   │        │
                     │ dispatcher_id    │          │ input_context    │        │
                     │ callback_url     │          │ stage_results    │        │
                     │ skills M2M       │          └──────────────────┘        │
                     │ configs M2M      │                                      │
                     │ tools M2M        │                                      │
                     └──────────────────┘                                      │

## Skills & Configs

┌──────────────────┐     ┌──────────────────┐     ┌──────────────────┐
│      Skill       │     │   SkillVersion   │     │     ToolDef      │
│──────────────────│     │──────────────────│     │──────────────────│
│ organization_id  │◄────│ skill_id         │     │ name, slug       │
│ category         │     │ version_number   │     │ input_schema     │
│ content_hash     │     │ content_hash     │     │ handler_ref      │
│ storage_ref      │     │ storage_ref      │     │ adapter_ref      │
│ instructions     │     │ created_by       │     └──────────────────┘
│ current_version  │     └──────────────────┘
└──────────────────┘

┌──────────────────┐     ┌──────────────────┐
│     Config       │     │  ConfigVersion   │
│──────────────────│     │──────────────────│
│ organization_id  │◄────│ config_id        │
│ category         │     │ version_number   │
│ content          │     │ content          │
│ content_hash     │     │ content_hash     │
└──────────────────┘     └──────────────────┘

## Workflow Engine

┌──────────────────┐     ┌──────────────────┐     ┌──────────────────────┐
│WorkflowTemplate  │     │  WorkflowStage   │     │WorkflowStageExecution│
│──────────────────│     │──────────────────│     │─────────────────────-│
│ category         │◄────│ template_id      │◄────│ workflow_instance_id │
│ is_published     │     │ order            │     │ stage_id             │
│ default_config   │     │ stage_type       │     │ task_id (nullable)   │
└──────────────────┘     │ agent_definition │     │ status               │
                         │ skills M2M       │     │ attempt_number       │
                         │ configs M2M      │     └──────────────────────┘
                         │ on_failure       │
                         └──────────────────┘

## Infrastructure

┌──────────────────┐     ┌──────────────────┐     ┌──────────────────┐
│AgentDefinition   │     │  RuntimeTarget   │     │  InfraService    │
│──────────────────│     │──────────────────│     │──────────────────│
│ tier             │     │ backend_type     │     │ service_type     │
│ runtime          │     │ endpoint         │     │ connection_url   │
│ image            │     │ namespace        │     │ is_healthy       │
│ default_cpu      │     │ is_default       │     │ consecutive_fails│
│ default_memory   │     └──────────────────┘     └──────────────────┘
│ cmd_override     │
└──────────────────┘

┌──────────────────┐     ┌──────────────────┐
│DispatcherInstance│     │    EventRoute    │
│──────────────────│     │──────────────────│
│ endpoint_url     │     │ event_type       │
│ dispatch_mode    │     │ source           │
│ bus_config       │     │ target_wf_id     │
│ status           │     │ signal_name      │
│ last_heartbeat   │     │ transform        │
└──────────────────┘     └──────────────────┘

## Secrets

┌──────────────────┐
│     Secret       │
│──────────────────│
│ organization_id  │
│ team_id (null)   │
│ workspace_id(null│
│ category         │
│ backend          │
│ path_or_arn      │
│ encrypted_value  │
└──────────────────┘

## Base Model (BaseCoreModel)

All business models inherit from BaseCoreModel which provides:
- `guid` (UUID, unique, external identifier)
- `slug` (auto-generated, unique within scope)
- `name`, `description`
- `version` (optimistic locking)
- `created_at`, `updated_at`, `deleted_at` (soft deletes)
- `created_by`, `updated_by`, `deleted_by` (audit trail)