self-replicating/README.md

11 KiB

Self-Replicating Business Meta-System

Autonomous business lifecycle management - from idea validation to exit

A fully autonomous system that takes business ideas as input and executes the complete journey from market validation to scaling/exit decisions, with zero human intervention.

🎯 Overview

This system autonomously manages the entire business lifecycle:

  1. Market Validation - Analyzes viability, competitors, and demand
  2. MVP Development - Generates and deploys functional products
  3. Marketing Automation - SEO, paid ads, content, email campaigns
  4. Continuous Optimization - Daily A/B testing and budget reallocation
  5. Autonomous Decisions - Scales at $10K, exits at $50K, shuts down at <$1K for 6 months

🏗️ Architecture

┌─────────────────────────────────────────────────────────────────┐
│                    META-ORCHESTRATOR                             │
│            (Node.js/TypeScript + n8n)                           │
└─────────────────────────────────────────────────────────────────┘
                              │
        ┌─────────────────────┼─────────────────────┐
        ▼                     ▼                     ▼
┌───────────────┐    ┌──────────────────┐   ┌─────────────────┐
│ 8 WORKFLOWS   │    │  DATA LAYER      │   │ DECISION ENGINE │
│ (Autonomous)  │◄──►│  (PostgreSQL +   │◄─►│ (Revenue Rules) │
│               │    │   Redis)         │   │                 │
└───────────────┘    └──────────────────┘   └─────────────────┘

🚀 Quick Start

Prerequisites

  • Node.js 20+
  • Docker & Docker Compose
  • pnpm (npm install -g pnpm)
  • API Keys (see .env.example)

Installation

# Clone and navigate
cd self-replicating-business

# Copy environment template
cp .env.example .env

# Edit .env and add your API keys (at minimum, ANTHROPIC_API_KEY is required)
nano .env

# Install dependencies
pnpm install

# Start infrastructure (PostgreSQL, Redis, n8n)
pnpm docker:up

# Run database migrations
pnpm db:migrate

# Start the orchestrator
cd packages/orchestrator
pnpm dev

Create Your First Business

# CLI method
pnpm create-business --idea "AI-powered meal planning SaaS" --name "MealMaster"

# Or programmatically
import { MetaOrchestrator } from '@srb/orchestrator';

const orchestrator = new MetaOrchestrator();
await orchestrator.initialize();

const business = await orchestrator.createBusiness({
  name: 'MealMaster',
  idea: 'AI-powered meal planning SaaS that generates personalized weekly meal plans',
  targetAudience: 'busy professionals',
  budget: 1000,
});

console.log(`Business created: ${business.id}`);
// System now runs autonomously!

📋 The 8 Autonomous Workflows

Phase 1: Validation & Development (Sequential)

  1. Market Validation (MARKET_VALIDATION)

    • Competitor analysis via web search
    • Demand analysis using Google Trends
    • Claude AI viability scoring (0-100)
    • Auto decision: viable → proceed, not viable → shutdown
  2. MVP Development (MVP_DEVELOPMENT)

    • Claude generates Next.js code
    • Saves to local directory
    • Auto-deploys to Vercel (if configured)
    • Returns live URL

Phase 2: Marketing Launch (Parallel)

  1. Landing Page + SEO (LANDING_PAGE_SEO)

    • Keyword research
    • SEO strategy via Claude skills
    • Content optimization
    • Blog post ideas
  2. Paid Ads (PAID_ADS)

    • Facebook Ads campaign creation
    • Google Ads campaign creation
    • Claude-powered ad copy generation
    • Initial budget allocation
  3. Content Marketing (CONTENT_MARKETING)

    • SEO blog content generation
    • Publishing automation
    • Social media sharing
  4. Email Automation (EMAIL_AUTOMATION)

    • Sendgrid template creation
    • Welcome sequence
    • Onboarding emails
  5. Analytics Setup (ANALYTICS_SETUP)

    • Google Analytics configuration
    • Meta Pixel installation
    • Conversion tracking

Phase 3: Continuous Optimization (Forever Loop)

  1. Optimization Loop (OPTIMIZATION_LOOP)
    • Runs daily (configurable)
    • Collects metrics from all sources
    • Analyzes campaign performance
    • Reallocates budgets automatically
    • Pauses underperformers (ROAS < 0.5)
    • Increases budgets for high performers (ROAS > 3)
    • A/B tests ad variations

🤖 Autonomous Decision Engine

The system makes three types of autonomous decisions based on revenue:

1. Scale Decision ($10K/month)

Trigger: Monthly revenue ≥ $10,000 Actions:

  • Post VA job on Upwork ($500/month budget)
  • Increase all ad budgets by 50%
  • Update status to SCALING
  • Send Slack/email alert

2. Exit Decision ($50K/month)

Trigger: Monthly revenue ≥ $50,000 Actions:

  • Calculate valuation (3.5x annual profit)
  • List on Acquire.com automatically
  • Update status to SELLING
  • Send Slack/email alert

3. Shutdown Decision (<$1K for 6 months)

Trigger: Monthly revenue < $1,000 for 6+ months Actions:

  • Pause all ad campaigns
  • Archive business data
  • Update status to SHUTDOWN
  • Send Slack/email alert

🗄️ Database Schema

model Business {
  id              String
  name            String
  idea            String
  status          BusinessStatus  // VALIDATING, RUNNING_ADS, SCALING, etc.
  viable          Boolean?
  mvpUrl          String?
  monthlyRevenue  Float
  seoOptimized    Boolean
  adsActive       Boolean

  workflows       WorkflowRun[]
  campaigns       Campaign[]
  metrics         Metric[]
  decisions       Decision[]
}

model WorkflowRun {
  id          String
  businessId  String
  type        WorkflowType  // MARKET_VALIDATION, MVP_DEVELOPMENT, etc.
  status      WorkflowStatus
  outputData  Json
  attempts    Int
}

model Campaign {
  id          String
  platform    Platform  // FACEBOOK, GOOGLE
  budget      Float
  impressions Int
  clicks      Int
  conversions Int
  revenue     Float
}

model Decision {
  id                String
  decisionType      DecisionType  // SCALE_PRODUCT, SELL_BUSINESS, SHUTDOWN
  action            String
  reasoning         String
  revenueAtDecision Float
  executed          Boolean
}

📊 Monitoring & Alerts

Dashboard

Access at http://localhost:3001/dashboard

  • Business overview (all businesses)
  • Real-time metrics
  • Workflow execution status
  • Decision history
  • Health scores

n8n Visual Workflows

Access at http://localhost:5678 (admin/admin123)

  • Visual workflow builder
  • Monitor workflow execution
  • Create custom automations

Alerts

Automatic notifications via Slack/Email for:

  • Workflow failures
  • Workflow completions
  • 💰 Revenue milestones ($10K, $50K)
  • 🤖 Autonomous decisions executed
  • ⚠️ Budget thresholds reached

🔧 Configuration

Required API Keys

Minimum (to run system):

  • ANTHROPIC_API_KEY - Claude API for AI operations

Optional (for full functionality):

  • FACEBOOK_ACCESS_TOKEN - Facebook Ads
  • GOOGLE_ADS_DEVELOPER_TOKEN - Google Ads
  • SENDGRID_API_KEY - Email automation
  • VERCEL_TOKEN - MVP deployment
  • ACQUIRE_COM_API_KEY - Business marketplace
  • UPWORK_API_KEY - VA hiring
  • SLACK_WEBHOOK_URL - Alerts
  • GOOGLE_SEARCH_API_KEY - Competitor research

Decision Thresholds (Customizable)

REVENUE_SCALE_THRESHOLD=10000      # Scale at $10K/month
REVENUE_SELL_THRESHOLD=50000       # Exit at $50K/month
REVENUE_SHUTDOWN_THRESHOLD=1000    # Consider shutdown if below
SHUTDOWN_WAIT_MONTHS=6             # Wait 6 months before shutdown

Budget Limits (Safety)

MAX_AD_SPEND_PER_BUSINESS=5000     # Max $5K/month per business
MAX_VALIDATION_BUDGET=100          # Max $100 for validation
MAX_MVP_BUDGET=500                 # Max $500 for MVP development

📁 Project Structure

self-replicating-business/
├── packages/
│   ├── orchestrator/           # Main system
│   │   ├── src/
│   │   │   ├── workflows/      # 8 autonomous workflows
│   │   │   ├── decision-engine/ # Autonomous decisions
│   │   │   ├── integrations/   # API clients
│   │   │   ├── monitoring/     # Logging, metrics, alerts
│   │   │   └── orchestrator.ts # Main controller
│   │   └── prisma/
│   │       └── schema.prisma   # Database schema
│   ├── web-dashboard/          # Next.js monitoring UI
│   ├── n8n-workflows/          # Visual workflows
│   └── shared/                 # Shared types
├── infra/
│   └── docker/
│       └── docker-compose.yml  # Full infrastructure
├── data/
│   └── businesses/             # Business data storage
└── .env.example                # Configuration template

🧪 Testing

# Unit tests
pnpm test

# Test specific workflow
pnpm test:workflow -- --type market-validation

# End-to-end test
pnpm test:e2e

# Smoke tests (production)
pnpm smoke-test

📈 Metrics & Success Criteria

System Performance

  • Launch 1 business/month with <24h to MVP
  • >99% system uptime
  • <5% workflow failure rate

Business Performance

  • >20% of businesses reach $1K/month
  • 2-3 profitable businesses/year
  • 1 exit/year at $100K-500K valuation
  • $5-10K/month aggregate passive income

🛣️ Roadmap

  • Web dashboard (Next.js) - In Progress
  • Multi-language support for global markets
  • Advanced A/B testing framework
  • Machine learning for better decision-making
  • Integration with Shopify for e-commerce
  • Cryptocurrency payment support

🔒 Security

  • API keys stored in environment variables
  • Database credentials not committed
  • Rate limiting on all external APIs
  • Budget caps prevent runaway spending
  • Audit logs for all decisions
  • Encrypted backups

💰 Cost Breakdown

Infrastructure (~$40-80/month)

  • VPS (4 CPU, 8GB RAM): $40-80

APIs (Per Business)

  • Claude API: $50-100/month
  • Sendgrid: $15/month
  • Analytics: Free

Ad Spend (Per Business)

  • Validation: $50
  • Launch: $500-1000/month
  • Scaling: $2000-5000/month

Total System: ~$100-200/month (infrastructure + APIs) Per Business: ~$500-1000/month (ads + operations)

🤝 Contributing

This is a private/personal project, but open to collaboration.

📄 License

Proprietary - All Rights Reserved

🆘 Support

For issues or questions:

⚠️ Disclaimer

This system makes autonomous financial decisions. Use at your own risk. Always monitor the dashboard and set appropriate budget limits. The system is designed with safety mechanisms but should be supervised, especially in production.


Built with: TypeScript, Node.js, Prisma, PostgreSQL, Redis, n8n, Claude AI

Status: Core System Implemented | 🔄 Dashboard In Progress

Last Updated: 2026-02-04