CMOClaw Marketing
Automation Platform
AI-Powered Campaign Creation at Scale for eToro
๐ Live Demos
Interactive prototypes showcasing key capabilities
Segmentation Engine
CHAID-based user clustering with Sankey visualization and drill-down exploration
โCampaign Dashboard
Real-time campaign performance monitoring with multi-channel analytics
๐ฆ Development Phases
Five phases of systematic platform development
Complete Phase 1
Foundation โ NestJS server setup, module architecture, base API endpoints, authentication framework
Complete Phase 2
AI Engine โ GPT-4 content generation, compliance AI, copy optimization, RAG campaign memory
Complete Phase 3
Channel Integrations โ Meta, Google, TikTok, Taboola, DV360, Bing, X API connections
Complete Phase 4
Data & ML โ Segmentation engine, CHAID trees, engagement prediction, Databricks integration
Complete Phase 5
Frontend & Ops โ Dashboard, visualization, n8n workflows, email builder, monitoring
๐๏ธ Architecture Overview
๐ง NestJS Core Server
18 modules ยท TypeScript ยท Node.js
๐ค AI Engine
GPT-4 ยท Compliance ยท RAG
๐ก Channels (7)
Meta ยท Google ยท TikTok ยท X ยท More
๐พ Data Layer
Salesforce MC ยท Databricks
๐ฅ๏ธ Frontend
D3.js ยท Chart.js ยท Vercel
โก n8n Workflows
Email Builder ยท Reports
๐ฅ Team
Yoni
CEO
Shiloh
Marketing Lead
Ran
Operations
The Vision
From manual campaign creation to fully autonomous AI-powered marketing at scale
๐ฏ The Problem
โฑ๏ธ Manual Campaign Creation is Broken
The average campaign takes 52 minutes to create manually. That means a team can produce maybe 8-10 campaigns per day. For a global platform like eToro with millions of users across dozens of segments โ that's not scalable.
๐ The Solution
๐ค๏ธ The Journey
Today
Manual campaign creation. 52 min per campaign. Limited personalization.
Week 1
Platform live. AI generates content, humans approve. 2 min per campaign.
Month 1
Fully autonomous. AI creates, optimizes, and distributes. Humans oversee.
๐๏ธ Five Pillars
AI-First Content Generation
GPT-4 powered copy generation with compliance awareness. Every piece of content is automatically checked against UK, EU, AU, and US regulations before distribution. The AI learns from past campaign performance to continuously improve.
Dynamic Segmentation
CHAID/ML-based user clustering that goes beyond simple demographics. Sankey visualization shows user flow through segments. Real-time updates as user behavior changes โ segments are living, breathing entities.
Multi-Channel Orchestration
Email, Push, Meta, Google, TikTok, WhatsApp, X โ all from one platform. Thompson Sampling selects the optimal channel for each user. Unified creative management across all touchpoints.
RAG-Powered Campaign Memory
A vector database stores every campaign ever run โ what worked, what didn't, and why. When creating new campaigns, the AI searches this memory to find proven approaches. Institutional knowledge that never leaves.
Real-Time Optimization
Performance prediction before launch using LightGBM models. Fatigue detection via Cox Survival analysis prevents over-messaging. Dynamic budget optimization shifts spend to top-performing channels in real-time.
๐ฎ Future Roadmap
๐ฆ ClawX
Social media automation engine โ automated posting, engagement tracking, and community management across X, LinkedIn, and more.
๐ Databricks Integration
Full production connection to Databricks for real-time user data, ML model training on actual behavioral data, and unified analytics.
๐ค Production ML
Production-grade CHAID segmentation, LightGBM engagement prediction, and Thompson Sampling models running on live data.
Technical Design
Interactive exploration of CMOClaw's architecture, tech stack, and data flows
๐๏ธ System Architecture
Click any component to expand details
๐ง NestJS Core Server โ 18 Modules
The central orchestration layer
Architecture: Each module follows NestJS conventions with Controller โ Service โ Repository layers. Guards handle authentication. Interceptors manage logging and error handling. Pipes validate DTOs.
๐ค AI Engine
GPT-4o ยท Compliance AI ยท Copy Gen
Compliance AI: Automated regulatory check against UK (FCA), EU (ESMA), AU (ASIC), and US (SEC) guidelines.
RAG Pipeline: ChromaDB vector store + embedding search for campaign memory retrieval.
๐ก Channel Integrations
7 platforms connected
Google Ads: Campaign/ad group/keyword management via Google Ads API v15
TikTok: Campaign + creative management via TikTok Marketing API v1.3
X/Twitter: Promoted tweets, audience targeting via Ads API v12
Also: Taboola, DV360, Bing Ads
๐พ Data Layer
SFMC ยท Databricks ยท ChromaDB
Databricks: User warehouse, behavioral data, ML feature store
ChromaDB: Vector DB for campaign embeddings and semantic search
Schema: Users, Segments, Campaigns, Creatives, Performance, AuditLog
๐ฅ๏ธ Frontend Apps
Segmentation ยท Dashboard ยท Builder
Dashboard: Chart.js real-time analytics โ campaign performance, channel comparison, ROI tracking
Campaign Builder: Step-by-step wizard with AI content generation and preview
โก n8n Workflows
Email Builder ยท Report API
Report API: Automated report generation combining data from all channels into unified analytics.
Scheduling: Campaign scheduling and trigger-based workflow execution.
๐ง Tech Stack
Click to explore each technology layer
Backend
AI & ML
Data
Channels
Frontend
Workflow
ML Models
๐ Data Flow
Animated pipeline from user data to campaign delivery
Databricks
CHAID Engine
AI-Powered
GPT-4 + RAG
7 Channels
Analytics
Feedback Loop
๐ API Endpoints
47+ endpoints across all modules โ click to expand
Campaign Management (8 endpoints)
AI Content Generation (6 endpoints)
Segmentation (6 endpoints)
Channel โ Meta (5 endpoints)
Channel โ Google Ads (5 endpoints)
Channel โ TikTok (4 endpoints)
Channel โ X/Twitter (4 endpoints)
Email & Templates (5 endpoints)
RAG & Campaign Memory (4 endpoints)
Documentation
Complete technical guide to CMOClaw setup, architecture, and operations
๐ Getting Started
Prerequisites
- Node.js 18+ (recommended: v20 LTS)
- npm 9+ or yarn
- Vercel CLI (
npm i -g vercel) - Git
Clone & Install
git clone https://github.com/etoro/cmoclaw-server.git
cd cmoclaw-server
npm install
Environment Variables
# .env
NODE_ENV=development
PORT=3000
# OpenAI
OPENAI_API_KEY=sk-...
OPENAI_MODEL=gpt-4o
# Salesforce Marketing Cloud
SFMC_INSTANCE_URL=https://mcXXXXXX.rest.marketingcloudapis.com
SFMC_CLIENT_ID=...
SFMC_CLIENT_SECRET=...
SFMC_ACCOUNT_ID=...
# Databricks
DATABRICKS_HOST=https://xxx.cloud.databricks.com
DATABRICKS_TOKEN=dapi...
DATABRICKS_WAREHOUSE_ID=...
# Meta Marketing API
META_APP_ID=...
META_APP_SECRET=...
META_ACCESS_TOKEN=...
META_AD_ACCOUNT_ID=act_...
# Google Ads
GOOGLE_ADS_DEVELOPER_TOKEN=...
GOOGLE_ADS_CLIENT_ID=...
GOOGLE_ADS_CLIENT_SECRET=...
GOOGLE_ADS_REFRESH_TOKEN=...
GOOGLE_ADS_CUSTOMER_ID=...
# TikTok
TIKTOK_APP_ID=...
TIKTOK_SECRET=...
TIKTOK_ACCESS_TOKEN=...
TIKTOK_ADVERTISER_ID=...
# ChromaDB
CHROMA_HOST=localhost
CHROMA_PORT=8000
Running Locally
# Development mode with hot reload
npm run start:dev
# Production build
npm run build
npm run start:prod
# Run tests
npm test
๐๏ธ Architecture
Module Structure (18 Modules)
src/
โโโ app.module.ts # Root module
โโโ auth/ # Authentication & guards
โโโ campaign/ # Campaign CRUD & lifecycle
โโโ content/ # AI content generation
โโโ segmentation/ # CHAID trees & clustering
โโโ channels/
โ โโโ meta/ # Meta/Facebook Ads
โ โโโ google/ # Google Ads
โ โโโ tiktok/ # TikTok Ads
โ โโโ taboola/ # Taboola
โ โโโ dv360/ # Display & Video 360
โ โโโ bing/ # Bing Ads
โ โโโ x/ # X/Twitter Ads
โโโ email/ # MJML templates & sending
โโโ compliance/ # Regulatory AI checks
โโโ analytics/ # Performance tracking
โโโ rag/ # Vector DB & campaign memory
โโโ workflow/ # n8n integration
โโโ common/ # Shared utilities, DTOs, guards
Database Schema
Users โ id, email, segment_id, behavior_data, created_at
Segments โ id, name, chaid_tree, criteria, user_count
Campaigns โ id, name, status, channels[], content_id, segment_id
Creatives โ id, campaign_id, type, content, channel, variants[]
Performance โ id, campaign_id, channel, impressions, clicks, conversions
AuditLog โ id, action, user_id, campaign_id, timestamp, details
Authentication Flow
JWT-based authentication with refresh tokens. API keys for service-to-service communication. Rate limiting per API key (100 req/min default).
POST /api/auth/login โ { access_token, refresh_token }
POST /api/auth/refresh โ { access_token }
GET /api/auth/me โ { user profile }
๐ Deployment
Vercel (Frontend)
# Install Vercel CLI
npm i -g vercel
# Deploy
vercel --prod
AWS (Backend โ EC2/ECS)
# Build Docker image
docker build -t cmoclaw-server .
# Push to ECR
aws ecr get-login-password | docker login --username AWS --password-stdin ACCOUNT.dkr.ecr.REGION.amazonaws.com
docker tag cmoclaw-server:latest ACCOUNT.dkr.ecr.REGION.amazonaws.com/cmoclaw-server:latest
docker push ACCOUNT.dkr.ecr.REGION.amazonaws.com/cmoclaw-server:latest
# Deploy to ECS
aws ecs update-service --cluster cmoclaw --service cmoclaw-server --force-new-deployment
CI/CD Pipeline
# .github/workflows/deploy.yml
name: Deploy
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: '20' }
- run: npm ci
- run: npm test
- run: npm run build
- run: vercel --prod --token ${{ secrets.VERCEL_TOKEN }}
โ๏ธ Configuration
Channel API Setup
Each channel requires OAuth2 credentials. See the Gap Analysis for what's needed per channel.
Salesforce Marketing Cloud
// src/channels/sfmc/sfmc.service.ts
// Requires: Server-to-Server API integration package
// Auth: OAuth2 client credentials flow
// Endpoints: REST API for data extensions, SOAP API for sends
Databricks Connection
// Uses Databricks SQL connector
// Connection via personal access token
// SQL warehouse for query execution
// Unity Catalog for data governance
n8n Workflow Setup
# Install n8n locally
npm install -g n8n
# Start n8n
n8n start
# Import workflows from /workflows directory
# Configure webhook URLs in .env
OpenAI Configuration
// Default model: gpt-4o
// Fallback: gpt-4o-mini (for compliance checks)
// Temperature: 0.7 (content), 0.1 (compliance)
// Max tokens: 2000 (content), 500 (compliance)
๐ง Operations
Monitoring & Logging
Structured JSON logging via NestJS Logger. Ready for DataDog/New Relic integration. Key metrics: request latency, AI generation time, channel API response times, error rates.
Error Handling
// Global exception filter catches all errors
// Channel-specific retry logic (3 retries, exponential backoff)
// Dead letter queue for failed campaign sends
// Alert on >5% error rate per channel
Rate Limiting
// Per-client: 100 requests/minute
// AI generation: 10 requests/minute (OpenAI limits)
// Channel APIs: Varies (Meta: 200/hr, Google: 15000/day)
// Configurable via environment variables
Feature Flags
// Feature flags via environment variables
FEATURE_RAG_ENABLED=true
FEATURE_ML_PREDICTIONS=false
FEATURE_REALTIME_OPTIMIZATION=false
FEATURE_MULTI_CHANNEL=true
Build Plan & Gap Analysis
From prototype to production in 5 days โ AI builds the code, humans provide the keys
Overall Build Progress
AI writes all code in hours. Testing and environment validation takes a day. This phase has zero external dependencies โ we can start immediately.
- Docker + Local Dev EnvironmentDockerfile, docker-compose.yml with PostgreSQL, Redis, ChromaDB. Hot-reload dev setup.~2 hrs
- Database Migrations (15 tables)Users, Segments, Campaigns, Creatives, Performance, AuditLog, ApiKeys, Roles, Permissions, Schedules, Templates, Channels, Audiences, ABTests, FeatureFlags~3 hrs
- Health Check Endpoints/health, /ready, /live โ checks DB, Redis, external services. Kubernetes-ready probes.~1 hr
- Auth System (JWT + Roles)JWT access/refresh tokens, RBAC with admin/editor/viewer roles, API key auth for services.~3 hrs
- Environment Config ValidationJoi/Zod schema validation on startup. Fail fast if missing required vars. Secrets management.~1 hr
Code is ready โ we need Databricks and SFMC credentials from the data team and marketing ops to connect real data pipelines.
- Databricks Real ConnectionSQL connector with personal access token. Unity Catalog for governance. Connection pooling.~2 hrs
- User Segmentation QueriesCHAID tree queries on real behavioral data. User clustering by trading patterns, deposit history, engagement.~4 hrs
- Campaign Performance Data PipelineETL from channel APIs โ Databricks. Unified performance schema across all 7 channels.~4 hrs
- Salesforce MC OAuth + Email SendingOAuth2 client credentials flow. Data extensions sync. Triggered sends via REST API.~3 hrs
- Audience Sync Between PlatformsDatabricks segments โ SFMC data extensions โ Channel custom audiences. Bidirectional sync.~4 hrs
Code for all 7 channels exists. We need API tokens from Guy's team to switch from mock to real. Code changes are minimal โ mostly credential injection.
- Meta Ads API (real campaigns)Marketing API v18 โ campaign CRUD, audience targeting, creative upload, insights. OAuth2 long-lived token.~2 hrs
- Google Ads API (real campaigns)API v15 โ campaign/ad group/keyword management. Service account or OAuth2 refresh token.~2 hrs
- TikTok Ads APIMarketing API v1.3 โ campaign + creative management. App ID + secret + advertiser ID.~2 hrs
- X Ads APIAds API v12 โ promoted tweets, audience targeting. May reuse existing bird CLI tokens.~1 hr
- Taboola APIBackstage API โ native content campaigns, widget management.~1 hr
- DV360 APIDisplay & Video 360 โ programmatic display/video campaigns.~2 hrs
- Bing Ads APIMicrosoft Advertising API โ search campaigns, audience network.~1 hr
- Connection Testing for AllAutomated health check per channel: auth validation, test API call, rate limit detection.~2 hrs
Move all AI from client-side demos to production server-side pipelines. OpenAI API key is the only dependency โ already available.
- Real OpenAI Copy Generation (server-side)GPT-4o for ad copy, email subjects, push notifications. Prompt templates with brand voice. Streaming responses.~2 hrs
- Real Compliance AI ReviewGPT-4o-mini checks against FCA/ESMA/ASIC/SEC rules. Structured output: pass/fail/warnings with citations.~2 hrs
- Real Creative Scoring (GPT-4V)Vision model scores ad creatives for brand consistency, visual hierarchy, regulatory compliance, engagement potential.~2 hrs
- Performance Prediction PromptsFew-shot prompts using RAG-retrieved past campaigns to predict CTR, conversion rate, and optimal budget allocation.~2 hrs
- Personalization EngineUser segment โ content variant mapping. Dynamic copy generation per audience cluster. Localization support.~3 hrs
- Learning Loop (store + analyze outcomes)Campaign results โ ChromaDB embeddings. RAG retrieval for "what worked" context. Continuous prompt refinement.~2 hrs
Infrastructure as Code โ AI writes the Terraform, GitHub Actions, and monitoring configs. Needs AWS account access and SSO details from IT.
- AWS Infrastructure (Terraform)ECS Fargate cluster, RDS PostgreSQL, ElastiCache Redis, ECR repos, ALB, Route53, ACM certs. Full IaC.~4 hrs
- CI/CD Pipeline (GitHub Actions)Lint โ Test โ Build โ Docker โ ECR โ ECS deploy. Staging + production environments. Rollback support.~2 hrs
- Monitoring (Health Checks, Sentry)Sentry for error tracking. Custom health dashboard. Alert on >5% error rate or >500ms p95 latency.~2 hrs
- Security (SSO, RBAC, Audit Logs)SAML/OIDC SSO with eToro IdP. Role-based access control. Full audit trail for compliance.~4 hrs
- Settings Page for API Key ManagementAdmin UI to manage channel credentials, test connections, rotate keys. Encrypted storage.~3 hrs
๐ What Humans Need to Provide
Click items to check them off as they're delivered. Progress is saved locally.
- Databricks API credentialsPini Krisher / Data Team
- Salesforce MC credentialsMarketing Ops
- Meta Ads API tokensGuy's Team
- Google Ads API tokensGuy's Team
- TikTok API tokensGuy's Team
- X API tokensExisting bird CLI?
- AWS account accessDevOps / IT
- SSO / IdP detailsIT
- Domain for SPF/DKIM/DMARCIT
- Security review sign-offHaim (Security)
- Compliance review sign-offHedva / Shifra
๐ Component Status Matrix
| Component | Status | Phase | AI Effort | Human Effort |
|---|---|---|---|---|
| Docker + Dev Environment | โ Code Ready | A | 2 hrs | โ |
| Database (15 tables) | โ Code Ready | A | 3 hrs | โ |
| Auth (JWT + RBAC) | โ Code Ready | A | 3 hrs | โ |
| Databricks Connection | ๐ก Needs Creds | B | 2 hrs | Get token |
| Salesforce MC | ๐ก Needs Creds | B | 3 hrs | Get OAuth creds |
| Meta Ads API | ๐ก Needs Creds | C | 2 hrs | Get token |
| Google Ads API | ๐ก Needs Creds | C | 2 hrs | Get token |
| TikTok / X / Taboola / DV360 / Bing | ๐ก Needs Creds | C | 6 hrs | Get tokens |
| AI Engine (server-side) | โ Code Ready | D | ~13 hrs | โ |
| AWS Infrastructure | ๐ด Needs Access | E | 4 hrs | AWS account |
| CI/CD + Monitoring | โ Code Ready | E | 4 hrs | โ |
| SSO + Security | ๐ด Needs Access | E | 4 hrs | IdP + sign-off |
๐๏ธ AI-Speed Rollout Plan
With AI building code in hours, the bottleneck is credentials and approvals โ not development time.
Day 1 โ Foundation
Docker environment, database migrations, auth system, health checks. No blockers โ start immediately.
Day 2 โ Data Layer
Databricks connection, SFMC OAuth, segmentation queries, audience sync. Needs: Databricks + SFMC credentials.
Day 3 โ Channels
Connect all 7 ad platforms with real API tokens. Test each connection. Needs: API tokens from Guy's team.
Day 4 โ AI + Infra
Production AI engine, Terraform AWS setup, CI/CD pipeline. Needs: AWS account access.
Day 5 โ Ship
Security review, SSO integration, monitoring, settings UI. Go live. Needs: Security sign-off from Haim.
The Symbiotic Architecture
Two Minds, One Mission โ How CMOClaw and Splinter work together to create autonomous marketing at scale
๐ The Symbiotic Process
An endless cycle of creation, execution, and learning
๐ The Daily Cycle
How a typical day flows between CMOClaw and Splinter
๐ Morning โ CMOClaw Wakes Up
- Reviews overnight campaign performance from Splinter
- Analyzes what worked, what didn't
- Updates learning patterns and knowledge base
- Generates new campaign ideas based on trends + data
- Researches competitors, market conditions, news
โ๏ธ Midday โ Strategy & Build
- Creates new campaign briefs with AI
- Generates creative variants (copy, images, video)
- Runs compliance pre-checks
- Builds audience segments from Databricks insights
- Pushes approved campaigns to Splinter
๐ Afternoon โ Splinter Executes
- Receives new campaigns from CMOClaw
- Distributes across Meta, Google, TikTok, Email, Push, WhatsApp
- Manages budget pacing and bid optimization
- Handles real-time compliance monitoring
- Pauses underperformers, scales winners
๐ Night โ The Learning Loop
- Splinter collects full day performance data
- Sends metrics back to CMOClaw's brain
- CMOClaw's learning engine processes results
- Updates campaign memory (Vector DB)
- Adjusts models and strategies for tomorrow
- Cycle repeats โ each day smarter than the last
๐ Version Evolution
How CMOClaw evolves โ each version builds on lessons learned
๐๏ธ Architecture: What Lives Where
Click to explore each side of the architecture
๐ง CMOClaw Side
OpenClaw Workspace
Scheduled Jobs
Shared Vector DB
๐ฅท Splinter Side
eToro Production
๐ก Why This Architecture?
๐ Separation of Concerns
R&D doesn't touch production. Production doesn't do experimentation. Clean boundaries, no accidents.
๐งฌ Always Evolving
CMOClaw can update its brain without touching live campaigns. Evolution without risk.
๐ก๏ธ Safe Execution
Splinter has compliance guardrails and human approval gates. Nothing goes live unchecked.
๐ Continuous Learning
Every campaign makes both systems smarter. Compound intelligence, compounding results.
๐ Scale
CMOClaw can design 1,000 campaigns. Splinter decides which 100 to run. Quality at quantity.
๐๏ธ Resilience
If CMOClaw goes down, Splinter keeps running existing campaigns. If Splinter pauses, CMOClaw keeps learning.