SAM AI Architecture Brainstorming Session
SAM AI Architecture Brainstorming Session
Date: 2025-12-06
Participants: Anthony (User), Claude (CTO Architect)
Repo: D:\SAMAI-18-SaaS\github-repos\05-samai-core
Status: π‘ Draft - Brainstorming in Progress
π Table of Contents
- Current State Analysis
- The Problem Statement
- Current Architecture Map
- Open Questions
- Brainstorming: Possible Solutions
- Next Steps
π― Current State Analysis
What We Know (Verified 2025-12-06)
Repository Structure
D:\SAMAI-18-SaaS\github-repos\
βββ 04-samai-brain/ # OLD: ai_brain module (in "debug hold")
βββ 05-samai-core/ # CURRENT: Active development
βββ ai_sam_base/ # DATA LAYER: Models that were split from ai_brain
βββ ai_sam/ # SKIN LAYER: Views, static assets, no models
βββ ai_sam_workflows_base/ # DATA LAYER: Workflow-specific models
βββ ai_sam_workflows/ # SKIN LAYER: Workflow UI, controllers, static
βββ ai_sam_cache_manager/ # Utility module
Module Breakdown: What Lives Where
ai_sam_base (Data Layer - 44 Models)
Purpose: Core SAM AI data models (split from original ai_brain)
Key Models:
- ai_conversation.py - Conversation management
- ai_message.py - Message storage
- ai_agent_definition.py - Agent configurations
- ai_agent_knowledge.py - Agent knowledge base
- ai_workspace.py - Workspace management
- ai_context_builder.py - Context assembly
- ai_memory_*.py - Memory system (config, search logs, import)
- ai_provider_*.py - AI provider/model management
- ai_service*.py - Service definitions
- api_credentials.py - API credential storage
- canvas_platform.py - Canvas platform definitions
- sam_*.py - SAM behavior, environment, user profiles, settings
- mcp_*.py - MCP server configs
Contains:
- β
Python models (.py files)
- β
Security rules (security/)
- β
Data files (data/)
- β NO views
- β NO static assets
- β NO controllers
ai_sam (Skin Layer - Presentation)
Purpose: UI/UX for core SAM AI features
Structure:
ai_sam/
βββ __manifest__.py
βββ views/ # XML views for ai_sam_base models
βββ static/
β βββ src/
β βββ vendor_library/ # π¨ N8N icons & metadata JSONs live here
β βββ [other JS/CSS]
βββ data/ # UI-related data (menus, actions)
βββ security/ # View-level security
Contains:
- β
XML views (forms, trees, search views)
- β
Static assets (JS, CSS, icons, vendor_library)
- β
Menu definitions
- β NO Python models
- β NO business logic
Key Asset: static/src/vendor_library/
- N8N node icons (SVG/PNG)
- N8N metadata registry (_registry/node_metadata.json)
- API config files
ai_sam_workflows_base (Data Layer - 15 Models)
Purpose: Workflow automation data models (split from original ai_brain)
Key Models:
- n8n_simple_nodes.py - N8N node definitions (computes icon URLs pointing to ai_sam)
- n8n_simple_extractor.py - N8N node extraction/scanning
- canvas.py - Canvas data model
- nodes.py - Workflow node definitions
- executions.py - Workflow execution tracking
- workflow_templates.py - Template storage
- business_unit.py - Business unit management
- api_credentials.py - Workflow-specific credentials
Contains:
- β
Python models
- β
Security rules
- β
Data files
- β NO views
- β NO static assets
- β NO controllers
ai_sam_workflows (Skin Layer - Presentation)
Purpose: UI/UX for workflow automation
Structure:
ai_sam_workflows/
βββ __manifest__.py
βββ controllers/ # HTTP endpoints (RPC, canvas API)
βββ views/ # XML views for workflow models
βββ static/
β βββ src/
β βββ automator/
β βββ n8n/
β βββ overlays/
β βββ overlay_manager.js # Frontend that USES icons from ai_sam
βββ data/
Contains:
- β
Controllers (Python HTTP endpoints)
- β
XML views
- β
Frontend JavaScript (overlay UI)
- β NO Python models
- β NO icon files (uses ai_sam's vendor_library)
π΄ The Problem Statement
What Anthony Said:
"ai_brain basically became too big, then there was a nightmare to find a bug, so currently ai_brain models are split across the sam ai base and sam ai workflows base modules, there is still models in ai_brain needing to be 'worked on' yet not for now. then we had 'the skins' on top of the base modules this was 'views' .js etc, not data as such, although we have json and icons sitting at the skin level"
Translation to Technical Problems:
Problem 1: ai_brain Explosion
- Symptom: ai_brain module grew too large
- Impact: Debugging became a nightmare
- Solution Attempted: Split models into
ai_sam_baseandai_sam_workflows_base - Current Status: ai_brain still exists (in 04-samai-brain repo, "debug hold")
- Question: What models still live in ai_brain? What's the migration plan?
Problem 2: Data vs Presentation Confusion
- Symptom: "Skins" (ai_sam, ai_sam_workflows) contain data assets (JSON, icons)
- Expected: Skins = views + JS only
- Reality: Skins = views + JS + vendor_library (icons/metadata)
- Impact: Unclear where AI agents should put code/assets
Problem 3: Cross-Module Dependencies
- Symptom: ai_sam_workflows frontend depends on ai_sam static assets
- Example:
n8n_simple_nodes.py(in workflows_base) computes URLs pointing toai_sam/static/vendor_library - Impact:
- Frontend constructs wrong paths (icon bug we just fixed)
- Duplication risk (temptation to copy icons to workflows module)
- AI agents don't know which module owns what
πΊοΈ Current Architecture Map
The "Base + Skin" Pattern (As Implemented)
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β LAYER 1: DATA (Base Modules) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β ai_sam_base/ ai_sam_workflows_base/ β
β βββ 44 models βββ 15 models β
β βββ Core SAM logic βββ Workflow logic β
β βββ NO views/UI βββ NO views/UI β
β β
ββββββββββββββββββββ¬βββββββββββββββββββββββββββββββββββββββββββ
β (depends on)
ββββββββββββββββββββΌβββββββββββββββββββββββββββββββββββββββββββ
β LAYER 2: PRESENTATION (Skin Modules) β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β β
β ai_sam/ ai_sam_workflows/ β
β βββ Views for ai_sam_base βββ Views for workflows_baseβ
β βββ Static assets βββ Controllers β
β βββ π¨ vendor_library/ βββ Frontend JS β
β β (icons, JSON metadata) βββ Uses ai_sam assets β
β βββ NO models β
β β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
π¨ ANOMALY: vendor_library is DATA, but lives in SKIN layer
The Dependency Web
ai_sam_workflows (skin)
β
ββββ depends on βββ ai_sam_workflows_base (data)
β β
β ββββ n8n_simple_nodes.py
β βββ computes icon_svg_url
β pointing to: /ai_sam/static/vendor_library/
β
ββββ depends on βββ ai_sam (skin) π¨ SKIN DEPENDS ON SKIN!
β
βββ static/src/vendor_library/
βββ [Supplier]/icon.svg
βββ _registry/node_metadata.json
Problem: Skins depending on other skins violates layer separation!
β Open Questions
Strategic Questions (Need Anthony's Input)
Q1: What is the ai_brain endgame?
- [ ] Option A: Fully deprecate ai_brain (all models migrated to base modules)
- [ ] Option B: Keep ai_brain as a separate module (distinct purpose)
- [ ] Option C: Merge base modules back into ai_brain (reverse the split)
Anthony, which direction?
Q2: Where SHOULD vendor_library live?
Current: ai_sam/static/src/vendor_library/ (skin layer)
Option A: Keep in ai_sam (Shared Assets Module)
ai_sam/
βββ static/src/vendor_library/
β βββ [Supplier]/icons.svg
β βββ _registry/node_metadata.json
βββ (no models, no business logic)
Pros:
- β
Already there
- β
Reusable across multiple modules
- β
Single source of truth
Cons:
- β ai_sam is a "skin" but contains data
- β Violates "skins have no data" principle
Option B: Move to ai_sam_workflows_base (Data Module)
ai_sam_workflows_base/
βββ models/
β βββ n8n_simple_nodes.py (already here)
βββ static/vendor_library/ (MOVE HERE)
βββ [Supplier]/icons.svg
βββ _registry/node_metadata.json
Pros:
- β
Data lives in data layer (clean separation)
- β
Close to models that use it
Cons:
- β Can't reuse N8N knowledge in other modules
- β Static assets in a "base" module is unusual in Odoo
Option C: Create ai_sam_n8n_library (Dedicated Module)
ai_sam_n8n_library/
βββ static/vendor_library/
β βββ [Supplier]/icons.svg
β βββ _registry/node_metadata.json
βββ __manifest__.py (no models, pure asset library)
Pros:
- β
Clear ownership (N8N library owns N8N assets)
- β
Reusable across modules
- β
Follows single-responsibility principle
Cons:
- β More modules to manage
- β Might be overkill for one folder
Anthony, which option feels right?
Q3: Should base modules have ANY static assets?
Current:
- ai_sam_base: NO static assets β
- ai_sam_workflows_base: NO static assets β
But:
- ai_sam (skin): Has vendor_library (data assets) β
Standard Odoo Practice:
- Base modules CAN have static assets (like default images)
- But usually: models in base, views/assets in skin
Question: Is vendor_library an exception (shared asset library), or should it follow strict separation?
Q4: What is the three-layer architecture intent?
You mentioned earlier:
"ai_brain (data) β ai_sam (framework) β branches (features)"
But current reality:
ai_sam_base (data)
β
ai_sam (framework/skin)
β
ai_sam_workflows_base (data) β π¨ BREAKS LAYER!
β
ai_sam_workflows (skin)
Question: Should it be:
Option A: Two-Layer (Base + Skin)
Data Layer: ai_sam_base, ai_sam_workflows_base
Skin Layer: ai_sam, ai_sam_workflows
Option B: Three-Layer (Data β Framework β Features)
Layer 1 (Data): ai_sam_base
Layer 2 (Framework): ai_sam
Layer 3 (Features): ai_sam_workflows_base + ai_sam_workflows
Option C: Something else entirely?
π‘ Brainstorming: Possible Solutions
Approach 1: Strict Two-Layer Separation
Principle: Data in base, presentation in skin, assets follow purpose
DATA LAYER (Models + Related Assets)
βββ ai_sam_base/
β βββ models/ (44 core models)
β βββ data/
β
βββ ai_sam_workflows_base/
βββ models/ (15 workflow models)
βββ static/vendor_library/ β MOVE HERE
βββ [Supplier]/icons.svg
βββ _registry/node_metadata.json
PRESENTATION LAYER (Views + Controllers + UI)
βββ ai_sam/
β βββ views/ (for ai_sam_base)
β βββ static/src/ (UI JS/CSS)
β βββ NO vendor_library
β
βββ ai_sam_workflows/
βββ controllers/
βββ views/ (for workflows_base)
βββ static/src/ (overlay_manager.js)
Pros:
- β
Clean separation (data vs presentation)
- β
Assets live with models that use them
Cons:
- β If you want to reuse N8N library elsewhere, it's locked in workflows_base
- β Breaking change (move assets)
Effort: Medium (file moves + path updates)
Approach 2: Shared Asset Library Pattern
Principle: Create dedicated modules for shared assets
ASSET LIBRARY LAYER
βββ ai_sam_library/
βββ static/vendor_library/
β βββ [Supplier]/icons.svg
β βββ _registry/node_metadata.json
βββ __manifest__.py (no models, pure library)
DATA LAYER
βββ ai_sam_base/ (depends on ai_sam_library)
βββ ai_sam_workflows_base/ (depends on ai_sam_library)
PRESENTATION LAYER
βββ ai_sam/ (depends on ai_sam_base + ai_sam_library)
βββ ai_sam_workflows/ (depends on workflows_base + ai_sam_library)
Pros:
- β
Reusable across any module
- β
Clear ownership (library owns assets)
- β
Follows "shared resources" pattern
Cons:
- β More modules (complexity)
- β Every module depends on library
Effort: Medium-High (new module + dependency updates)
Approach 3: Keep Current, Document Rules
Principle: Accept that ai_sam is a "framework module" (not pure skin)
FRAMEWORK LAYER (Shared Services + Assets)
βββ ai_sam/
βββ static/vendor_library/ (shared N8N library)
βββ views/ (core views)
βββ static/src/ (core JS)
DATA LAYERS
βββ ai_sam_base/ (core data)
βββ ai_sam_workflows_base/ (workflow data)
βββ models/n8n_simple_nodes.py
βββ computes URLs β /ai_sam/static/vendor_library/
FEATURE LAYER
βββ ai_sam_workflows/
βββ controllers/
βββ views/
βββ static/ (uses ai_sam assets)
Pros:
- β
No file moves (works today)
- β
Pragmatic (ai_sam already acts as framework)
- β
Low effort (just document the pattern)
Cons:
- β Violates "pure separation" principle
- β AI agents might still be confused
Effort: Low (documentation only)
Approach 4: Merge Base Modules into Skins
Principle: Each feature is self-contained (models + views together)
CORE MODULE
βββ ai_sam/
βββ models/ (MERGE ai_sam_base models here)
βββ views/
βββ static/
βββ data/
WORKFLOW MODULE
βββ ai_sam_workflows/
βββ models/ (MERGE workflows_base models here)
βββ controllers/
βββ views/
βββ static/vendor_library/ (MOVE HERE)
βββ data/
Pros:
- β
Self-contained (everything for workflows in one place)
- β
Easier for AI agents (one module = one feature)
- β
Standard Odoo pattern (models + views together)
Cons:
- β Reverses the split you already did
- β Might re-create "too big" problem
- β Can't separate data from presentation
Effort: High (merge modules, extensive testing)
π― Next Steps
What We Need to Decide Together:
- Answer Q1: What happens to ai_brain? (Deprecate, keep, merge back)
- Answer Q2: Where should vendor_library live? (Keep, move, or create library module)
- Answer Q3: Is ai_sam a "skin" or a "framework"? (Naming/purpose clarity)
- Answer Q4: Two-layer or three-layer architecture? (Data β Presentation, or Data β Framework β Features)
Proposed Discussion Flow:
Step 1: Answer Strategic Questions (This document)
- Anthony provides answers to Q1-Q4
- We discuss trade-offs of each approach
Step 2: Choose Approach (Next session)
- Pick one of the 4 approaches (or hybrid)
- Identify migration steps (if needed)
Step 3: Create Migration Plan (If changes needed)
- List files to move
- Update dependencies
- Test plan
Step 4: Document Architecture Rules (Always needed)
- Write AI agent guidance: "Where to put X"
- Create ownership matrix (module β responsibilities)
- Define forbidden patterns
π Notes for Next Discussion
Things to Explore:
- [ ] List models still in ai_brain (04-samai-brain repo)
- [ ] Check if any code references old ai_brain imports
- [ ] Identify other "data living in skins" cases (besides vendor_library)
- [ ] Review manifest dependencies (who depends on whom)
Questions for Anthony:
- What's your gut feeling on the 4 approaches?
- Is there urgency to fix this, or can we evolve gradually?
- Are there other modules (beyond these 5) we should consider?
- Do you have a preference: fewer modules (simple) vs more modules (separated)?
π End of Brainstorming Document
Status: Awaiting Anthony's input on strategic questions
Next Action: Anthony reviews Q1-Q4 and picks preferred approach
Created by: Claude (CTO Architect)
Date: 2025-12-06