Skip to Content

Schema Diagram

SAM AI Database Schema - Entity Relationship Diagram

SAM AI Database Schema MAINTAINED FILE

Entity Relationship Diagram

Model Categories
Conversation System
Canvas/Workflow System
Memory/Graph System
Agent System
N8N/Workflow Types
SAM Personality/Settings

📘 Section 1: Conversation & AI Services System

Core models for AI conversations, messages, token tracking, and AI service configuration

erDiagram %% ======================================================================== %% CONVERSATION SYSTEM (Blue) %% ======================================================================== AI_CONVERSATION ||--o{ AI_MESSAGE : "has messages" AI_CONVERSATION ||--o{ AI_TOKEN_USAGE : "tracks tokens" AI_CONVERSATION }o--|| RES_USERS : "belongs to user" AI_CONVERSATION }o--o{ AI_WORKSPACE : "shared in workspaces" AI_CONVERSATION { int id PK string name int user_id FK string context_model int context_id string conversation_type string imported_from string original_uuid datetime last_message_date } AI_MESSAGE { int id PK int conversation_id FK string role text content int token_count string ai_model string ai_provider int response_time_ms } AI_TOKEN_USAGE { int id PK int conversation_id FK int input_tokens int output_tokens int total_tokens float cost_usd } RES_USERS { int id PK string name string email } AI_WORKSPACE { int id PK string name text description } %% ======================================================================== %% AI SERVICES %% ======================================================================== AI_SERVICE ||--o{ AI_SERVICE_CONFIG : "has config" AI_SERVICE }o--|| AI_SERVICE_PROVIDER : "uses provider" AI_SERVICE { int id PK string name int provider_id FK string model_name boolean active } AI_SERVICE_CONFIG { int id PK int service_id FK string config_key string config_value } AI_SERVICE_PROVIDER { int id PK string name string api_endpoint string provider_type }

🎨 Section 2: Canvas/Workflow System

Visual workflow canvas, nodes, connections, executions, and N8N integration

erDiagram %% ======================================================================== %% CANVAS/WORKFLOW SYSTEM (Purple) %% ======================================================================== CANVAS ||--o{ NODES : "contains nodes" CANVAS ||--o{ EXECUTIONS : "has executions" CANVAS ||--o{ CONNECTIONS : "defines connections" CANVAS }o--|| WORKFLOW_TYPES : "has type" CANVAS }o--|| WORKFLOW_BUSINESS_UNIT : "belongs to unit" CANVAS }o--|| WORKFLOW_TEMPLATE : "created from template" CANVAS }o--|| AI_BRANCH : "implements branch" CANVAS { int id PK string name string branch_type int branch_id FK string canvas_type text json_definition string execution_mode string cron_expression string webhook_url } NODES ||--o{ CONNECTIONS : "source node" NODES ||--o{ CONNECTIONS : "target node" NODES }o--|| NODE_TYPES : "has type" NODES }o--|| API_CREDENTIALS : "uses credentials" NODES { int id PK int canvas_id FK string node_id string name int node_type_id FK text parameters float x_cord float y_cord boolean disabled text input_connections text output_connections } EXECUTIONS { int id PK int canvas_id FK string state datetime start_time datetime end_time string trigger_type int triggered_by FK text input_data text output_data text error_message } CONNECTIONS { int id PK int canvas_id FK int from_node_id FK int to_node_id FK string connection_type } WORKFLOW_TYPES { int id PK string workflow_type string name text description } WORKFLOW_TEMPLATE { int id PK string name int workflow_type_id FK text json_definition int author_id FK } NODE_TYPES { int id PK string node_type string name string category text icon_data text default_parameters } API_CREDENTIALS { int id PK string name string credential_type text encrypted_data } WORKFLOW_BUSINESS_UNIT { int id PK string name } AI_BRANCH { int id PK string technical_name string display_name }

🧠 Section 3: Memory, Agents & SAM Personality

Graph memory services, agent registry/execution, and SAM personality adaptation

erDiagram %% ======================================================================== %% MEMORY/GRAPH SYSTEM (Red) %% ======================================================================== AI_CONVERSATION { int id PK string name int user_id FK } AI_GRAPH_SERVICE ||--o{ AI_CONVERSATION : "indexes conversations" AI_VECTOR_SERVICE ||--o{ AI_CONVERSATION : "embeds conversations" AI_CONVERSATION_IMPORT ||--o{ AI_CONVERSATION : "imports to" AI_GRAPH_SERVICE { int id PK string service_type string connection_string boolean active } AI_VECTOR_SERVICE { int id PK string service_type string connection_string boolean active } AI_CONVERSATION_IMPORT { int id PK string import_source int conversations_imported datetime import_date } %% ======================================================================== %% AGENT SYSTEM (Green) %% ======================================================================== AI_AGENT_DEFINITION ||--o{ AI_AGENT_EXECUTION : "executes" AI_AGENT_DEFINITION ||--o{ AI_AGENT_KNOWLEDGE : "has knowledge" AI_AGENT_DEFINITION { int id PK string name string agent_type text system_prompt text capabilities boolean active } AI_AGENT_EXECUTION { int id PK int agent_id FK datetime start_time datetime end_time string status text input_data text output_data } AI_AGENT_KNOWLEDGE { int id PK int agent_id FK string knowledge_type text knowledge_content } %% ======================================================================== %% SAM PERSONALITY SYSTEM (Teal) %% ======================================================================== SAM_PERSONALITY ||--o{ SAM_USER_PROFILE : "adapts to users" SAM_PERSONALITY ||--o{ SAM_MODE_CONTEXT : "has modes" SAM_PERSONALITY { int id PK string name text personality_traits text communication_style } SAM_USER_PROFILE { int id PK int user_id FK int personality_id FK text preferences text conversation_history } SAM_MODE_CONTEXT { int id PK string mode_name text mode_prompt text capabilities } RES_USERS { int id PK string name string email } SAM_USER_PROFILE }o--|| RES_USERS : "belongs to user"

Model Browser

AI Conversation
ai.conversation
Key Fields
name, user_id, context_model, context_id, conversation_type, status
Relationships
One2many: ai_message_ids → ai.message
Many2one: user_id → res.users
Many2many: workspace_ids → ai.workspace
Used by: ai_sam, ai_sam_ui, ai_sam_memory
AI Message
ai.message
Key Fields
role, content, token_count, ai_model, ai_provider
Relationships
Many2one: conversation_id → ai.conversation
Used by: ai_sam, ai_sam_ui
Canvas
canvas
Key Fields
name, branch_type, canvas_type, json_definition, execution_mode
Relationships
One2many: node_ids → nodes
One2many: execution_ids → executions
Many2one: workflow_type_id → workflow_types
Used by: ai_sam, ai_sam_workflows, ai_sam_creatives
Nodes
nodes
Key Fields
node_id, name, node_type_id, parameters, x_cord, y_cord
Relationships
Many2one: canvas_id → canvas
Many2one: node_type_id → node_types
Used by: ai_sam, ai_sam_workflows
Executions
executions
Key Fields
state, start_time, end_time, trigger_type, input_data, output_data
Relationships
Many2one: canvas_id → canvas
Many2one: triggered_by → res.users
Used by: ai_sam, ai_sam_workflows
Connections
connections
Key Fields
from_node_id, to_node_id, connection_type
Relationships
Many2one: canvas_id → canvas
Many2one: from_node_id → nodes
Many2one: to_node_id → nodes
Used by: ai_sam, ai_sam_workflows
AI Agent Definition
ai.agent.definition
Key Fields
name, agent_type, system_prompt, capabilities, active
Relationships
One2many: execution_ids → ai.agent.execution
One2many: knowledge_ids → ai.agent.knowledge
Used by: ai_sam_intelligence
AI Graph Service
ai.graph.service
Key Fields
service_type, connection_string, active
Relationships
Indexes: ai.conversation (graph nodes)
Used by: ai_sam_memory
SAM Personality
sam.personality
Key Fields
name, personality_traits, communication_style
Relationships
One2many: user_profile_ids → sam.user.profile
Used by: ai_sam

Capability Matrix

What features exist where? Quick reference for architects and developers.

Conversation Management
Models
ai.conversation, ai.message, ai.token.usage
Modules
ai_brain (data), ai_sam (logic), ai_sam_ui (interface)
Extension Points
Add context_model/context_id to link conversations to any Odoo model
Extend ai.message with attachments
Workflow Automation
Models
canvas, nodes, connections, executions
Modules
ai_brain (data), ai_sam (core), ai_sam_workflows (UI)
Extension Points
Add node_types for new node types
Extend canvas.platform for new canvas types
Graph Memory
Models
ai.graph.service, ai.vector.service, ai.conversation.import
Modules
ai_brain (data), ai_sam_memory (UI + Apache AGE)
Extension Points
Add graph node types
Extend vector embedding models
Agent Registry
Models
ai.agent.definition, ai.agent.execution, ai.agent.knowledge
Modules
ai_brain (data), ai_sam_intelligence (registry)
Extension Points
Register new agent types
Add agent knowledge sources
Member Management
Models
sam.member, res.partner (extended)
Modules
ai_brain (data), ai_sam_members (management)
Extension Points
Extend sam.member with custom fields
Add membership tiers
Content Generation
Models
canvas (multimedia), ai.conversation (chat)
Modules
ai_brain (data), ai_sam_creatives (UI)
Extension Points
Add creative templates
Extend canvas with new media types

SAM AI Database Schema - Generated from ai_brain models

Path: C:\Working With AI\ai_sam\ai_sam\ai_brain\models

This file is automatically maintained by /docs or /schema agents

Was this helpful?