Skip to content

DLhugly/OpenClawdCloud

Repository files navigation

OpenClawdBox

Enterprise-grade AI Bot Management Platform powered by Cloudflare's edge infrastructure. Deploy, manage, and scale AI agents with full isolation per customer.

Architecture

┌─────────────────────────────────────────────────────────────────────────┐
│                         OpenClawdBox Platform                           │
├─────────────────────────────────────────────────────────────────────────┤
│  Super Admin Dashboard (Master Control)                                 │
│  ├── All Organizations Overview                                         │
│  ├── All Bots Monitoring                                               │
│  ├── User Management                                                    │
│  └── Revenue Analytics (MRR)                                           │
├─────────────────────────────────────────────────────────────────────────┤
│  Customer Portal (Per Organization)                                     │
│  ├── Organization Dashboard                                             │
│  ├── Teams Management                                                   │
│  │   └── Bots (Per Team)                                               │
│  │       ├── Start/Stop/Restart                                        │
│  │       ├── LLM Configuration (Workers AI / BYOK)                     │
│  │       └── Test Chat Interface                                       │
│  ├── Settings (LLM Provider, API Keys)                                 │
│  └── Billing (Stripe Integration)                                      │
└─────────────────────────────────────────────────────────────────────────┘

Tech Stack

  1. Frontend: React 18 + Vite + TypeScript + Tailwind CSS v4 + Shadcn/UI
  2. Backend: Cloudflare Workers + Hono.js
  3. Database: Cloudflare D1 (SQLite)
  4. AI/LLM: Cloudflare Workers AI (default) + BYOK (Anthropic/OpenAI)
  5. State: Cloudflare Durable Objects (Bot lifecycle management)
  6. Billing: Stripe (subscriptions, customer portal)
  7. Mobile: Capacitor-ready (iOS/Android wrapper)

Features

  1. Multi-Tenant Architecture: Full isolation per customer (org, data, LLM access)
  2. Hierarchical Organization: Organization → Teams → Bots
  3. LLM Flexibility: Workers AI included, or Bring Your Own Key (BYOK)
  4. Self-Serve Portal: Customers manage their own teams and bots
  5. Master Dashboard: Super admin oversight of all customers and bots
  6. Subscription Tiers: Starter ($500/mo), Business ($1,500/mo), Enterprise ($5,000/mo)
  7. Real-Time Bot Control: Start, stop, restart from dashboard
  8. Test Chat Interface: Interact with bots directly in the dashboard

Project Structure

OpenClawdBox/
├── apps/
│   ├── web/                    # React frontend
│   │   ├── src/
│   │   │   ├── components/     # UI components
│   │   │   ├── pages/          
│   │   │   │   ├── admin/      # Super admin pages
│   │   │   │   └── org/        # Customer portal pages
│   │   │   ├── stores/         # Zustand state
│   │   │   └── lib/            # API client, utils
│   │   └── package.json
│   └── worker/                 # Cloudflare Worker backend
│       ├── src/
│       │   ├── routes/         # API routes
│       │   ├── middleware/     # Auth, org access
│       │   ├── services/       # Auth, crypto
│       │   └── durable-objects/# Bot manager
│       ├── migrations/         # D1 schema
│       └── wrangler.toml
└── packages/
    └── shared/                 # Shared types, validators, constants

Quick Start

Prerequisites

  1. Node.js 18+
  2. pnpm 8+
  3. Cloudflare account
  4. Stripe account (for billing)

Setup

# 1. Install dependencies
pnpm install

# 2. Configure Cloudflare resources
cd apps/worker

# Create D1 database
pnpm exec wrangler d1 create openclawdbox
# Update wrangler.toml with database_id

# Create KV namespace
pnpm exec wrangler kv:namespace create KV
# Update wrangler.toml with KV id

# 3. Run migrations
pnpm exec wrangler d1 execute openclawdbox --local --file=migrations/0001_init.sql
pnpm exec wrangler d1 execute openclawdbox --local --file=migrations/0002_multi_tenant.sql

# 4. Set secrets
pnpm exec wrangler secret put STRIPE_SECRET_KEY
pnpm exec wrangler secret put STRIPE_WEBHOOK_SECRET
pnpm exec wrangler secret put ENCRYPTION_KEY  # 32 char string

# 5. Start development
cd ../..
pnpm dev

Create Super Admin

  1. Navigate to http://localhost:3000/setup
  2. Enter admin email and password
  3. Login at /login

API Endpoints

Authentication

  • POST /api/auth/register - Register new user
  • POST /api/auth/login - Login
  • POST /api/auth/logout - Logout
  • GET /api/auth/session - Get current session

Organizations

  • GET /api/orgs - List user's orgs
  • POST /api/orgs - Create org
  • GET /api/orgs/:orgId - Get org
  • PUT /api/orgs/:orgId - Update org
  • GET /api/orgs/:orgId/stats - Get org stats

Teams

  • GET /api/orgs/:orgId/teams - List teams
  • POST /api/orgs/:orgId/teams - Create team
  • PUT /api/orgs/:orgId/teams/:teamId - Update team
  • DELETE /api/orgs/:orgId/teams/:teamId - Delete team

Bots

  • GET /api/orgs/:orgId/teams/:teamId/bots - List bots
  • POST /api/orgs/:orgId/teams/:teamId/bots - Create bot
  • GET /api/orgs/:orgId/teams/:teamId/bots/:botId - Get bot
  • PUT /api/orgs/:orgId/teams/:teamId/bots/:botId - Update bot
  • DELETE /api/orgs/:orgId/teams/:teamId/bots/:botId - Delete bot
  • POST /api/orgs/:orgId/teams/:teamId/bots/:botId/start - Start bot
  • POST /api/orgs/:orgId/teams/:teamId/bots/:botId/stop - Stop bot
  • POST /api/orgs/:orgId/teams/:teamId/bots/:botId/restart - Restart bot
  • POST /api/orgs/:orgId/teams/:teamId/bots/:botId/chat - Chat with bot

Billing

  • GET /api/orgs/:orgId/billing/subscription - Get subscription
  • POST /api/orgs/:orgId/billing/checkout - Create checkout session
  • POST /api/orgs/:orgId/billing/portal - Create customer portal session

Admin (Super Admin only)

  • GET /api/admin/stats - Platform stats
  • GET /api/admin/orgs - List all orgs
  • GET /api/admin/bots - List all bots
  • GET /api/admin/users - List all users
  • POST /api/admin/bots/bulk-restart - Restart all running bots

Subscription Tiers

Feature Starter ($500/mo) Business ($1,500/mo) Enterprise ($5,000/mo)
Teams 2 10 Unlimited
Bots 5 25 Unlimited
Team Members 5 20 Unlimited
Included Tokens 1M 5M Unlimited
Support Email Priority Dedicated

LLM Configuration

Workers AI (Default - Included)

Cloudflare-hosted models, no additional API keys required:

  • Llama 3.1 8B/70B
  • Mistral 7B
  • Gemma 7B

Bring Your Own Key (BYOK)

Customers can use their own API keys:

  • Anthropic: Claude 3.5 Sonnet, Claude 3 Opus/Haiku
  • OpenAI: GPT-4o, GPT-4o Mini, GPT-4 Turbo

Keys are encrypted with AES-GCM before storage.

Deployment

# Deploy worker
cd apps/worker
pnpm exec wrangler deploy

# Deploy frontend to Pages
cd ../web
pnpm build
pnpm exec wrangler pages deploy dist --project-name=openclawdbox

Environment Variables

Worker (.dev.vars)

STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...
STRIPE_PRICE_STARTER=price_...
STRIPE_PRICE_BUSINESS=price_...
STRIPE_PRICE_ENTERPRISE=price_...
ENCRYPTION_KEY=32-character-secret-key-here!!!

License

MIT

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages