alexwelcing/mmp

multicharacter economy thing

0

stars

11

commits

Python

primary language

May 6, 2026

updated

README

๐ŸŽฎ Autonomous AI Director: GCP-Native Pipeline for Web3 Game Asset Generation

Tutorial Repository โ€” A production-quality reference implementation for building a real-time, AI-driven game asset pipeline with on-chain monetization on Base (Ethereum L2).

License: MIT Python 3.11+ Solidity ^0.8.20


๐Ÿ“– Overview

This project demonstrates a Dual-Horizon Strategy for Web3 game monetization:

HorizonDescriptionRevenue
H1 (Now)Free-to-play with gasless onboardingViral growth
H2 (Scale)On-chain character ownership + royalty splitsSustainable revenue

Players claim a free AI-generated character (no wallet required), then optionally mint it on-chain with full ownership. An autonomous AI Director orchestrates the entire pipeline โ€” from Pub/Sub request to on-chain NFT โ€” using GCP-native services.

โ˜๏ธ Google Cloud NEXT '26 Refresh

For the Google Cloud NEXT '26 coverage update, this tutorial now anchors itself on three conference signals that fit MMP especially well:

NEXT '26 session / updateWhy it matters hereMMP upgrade direction
Google MCP Services: Connect AI agents to cloud infrastructure in minutesThe AI Director is already an orchestration layer; MCP is the cleanest way to connect that layer to cloud tools without bespoke glue code.This refresh now adds a real /mcp tool surface for generation jobs plus Kubernetes AI-serving inspection.
What's new for AI on GKE: Training, serving, and agentsMMP already uses GKE GPU workers for image and 3D generation, so the repo naturally fits the new โ€œtraining, serving, and agentsโ€ framing.Treat ComfyUI and ReSplat as a reusable AI serving plane with clearer scaling and reliability guidance.
What's new in streaming: Real-time data for agentic AIThe project already depends on Pub/Sub, but only as a request queue. NEXT '26 pushes the bigger idea: agent systems need real-time event backbones.This refresh now adds a dedicated Pub/Sub lifecycle topic so MMP emits job status events in addition to request intake.

See docs/architecture.md for the concrete upgrade path and docs/google-cloud-next-2026-submission-draft.md for the draft contest post.


๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                        FRONTEND (React/Vite)                    โ”‚
โ”‚  FreeRollStep โ†’ CharacterCard โ†’ PaidRollStep โ†’ WalletProvider   โ”‚
โ”‚                         โ†‘                                       โ”‚
โ”‚              GaussianSplatViewer (WebGL .ply)                   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                           โ”‚ REST API
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    AI DIRECTOR SERVICE (FastAPI)                 โ”‚
โ”‚                                                                 โ”‚
โ”‚  OrchestratorAgent                                              โ”‚
โ”‚  โ”œโ”€โ”€ ImageAgent  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ ComfyUI Worker (GKE + GPU)         โ”‚
โ”‚  โ”‚   (2D draft โ†’ upscale)        โ–ฒ                              โ”‚
โ”‚  โ”œโ”€โ”€ EvaluatorAgent              โ”‚ Webhook (AIDirectorWebhook)  โ”‚
โ”‚  โ”œโ”€โ”€ AudioAgent  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ Audio Worker (AudioGen)            โ”‚
โ”‚  โ”œโ”€โ”€ ResplatAgent โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ ReSplat Worker (GPU)               โ”‚
โ”‚  โ”‚   (Stable Zero123 โ†’ COLMAP โ†’ 3DGS)                           โ”‚
โ”‚  โ””โ”€โ”€ Web3Agent   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ Base L2 (ERC-4337)                 โ”‚
โ”‚                                       โ”‚                        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                           โ”‚            โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                       GCP INFRASTRUCTURE                        โ”‚
โ”‚                                                                 โ”‚
โ”‚  Pub/Sub Topics          GKE Cluster          Filestore NFS     โ”‚
โ”‚  asset-generation  โ”€โ”€โ”€โ–บ  GPU Node Pool  โ—„โ”€โ”€โ”€  Model Cache       โ”‚
โ”‚  (requests/dlq)          (gVisor + CUDA)      (ReadWriteMany)   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                           โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    BASE L2 SMART CONTRACTS                      โ”‚
โ”‚                                                                 โ”‚
โ”‚  CharacterNFT (ERC-721)                                         โ”‚
โ”‚  โ”œโ”€โ”€ AIDirectorPaymaster (ERC-4337) โ† Gasless for new users     โ”‚
โ”‚  โ””โ”€โ”€ CharacterSplits (0xSplits)    โ† Royalty distribution       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“‹ Prerequisites

ToolVersionPurpose
Python3.11+AI Director service
Node.js18+Contracts & frontend
Pulumi3.120+GCP infrastructure (Python)
kubectl1.28+Kubernetes management
Docker24+Container builds
Makeโ€”One-command local dev
GCP Accountโ€”Cloud infrastructure

๐Ÿš€ Quick Start (Local Dev)

The fastest way to run locally is hybrid mode: ComfyUI, AudioGen, and optional ReSplat run in Docker; the AI Director and Frontend run natively for fast hot-reload.

# 1. Install dependencies once
make install

# 2. Start ComfyUI + AudioGen containers
make dev-native

# 3. Deploy local contracts (creates .env.contracts)
make contracts-local
export $(cat .env.contracts | xargs)

# 4. Start the AI Director (in a second terminal)
cd services/ai-director
source .venv/bin/activate
uvicorn main:app --reload --port 8080

# 5. Start the frontend (in a third terminal)
cd frontend
npm run dev
# Open http://localhost:5173

Optional: ReSplat 3D Mode

If you have an NVIDIA GPU with CUDA 12.8 support, start the full stack including ReSplat:

make dev-resplat

Then set USE_RESPLAT_FOR_3D=true in your .env to route 3D generation through ReSplat instead of ComfyUI.


๐Ÿ—‚๏ธ Component Breakdown

services/ai-director/

The core orchestration service. Subscribes to GCP Pub/Sub, routes requests through a multi-agent pipeline, and coordinates asset delivery.

agents/
โ”œโ”€โ”€ orchestrator.py    # Main pipeline coordinator
โ”œโ”€โ”€ image_agent.py     # 2D draft + upscale (ComfyUI)
โ”œโ”€โ”€ evaluator_agent.py # Aesthetic scoring & selection
โ”œโ”€โ”€ audio_agent.py     # Soundscape generation (AudioGen)
โ”œโ”€โ”€ resplat_agent.py   # 3D Gaussian Splatting (ReSplat)
โ””โ”€โ”€ web3_agent.py      # ERC-4337 gasless minting + splits

services/comfyui-worker/

Containerized ComfyUI with custom workflows and the AIDirectorWebhook custom node for push notifications:

  • lightning_2d_draft.json โ€” Fast SDXL-Lightning draft generation
  • mesh_generation.json โ€” 3D mesh generation fallback

services/audio-worker/

Facebook AudioGen inference service via Hugging Face Hub. Generates character soundscapes on CPU.

services/resplat-worker/

Full 3D Gaussian Splatting pipeline: Stable Zero123 multi-view synthesis โ†’ COLMAP sparse reconstruction โ†’ ReSplat inference โ†’ .ply output.

infrastructure/pulumi/

GCP infrastructure as code using Python Component Resources:

  • MMPCluster: VPC, GKE, system/GPU node pools, Workload Identity
  • FilestoreCache: NFS-backed shared model cache (ReadWriteMany)
  • PubSubPipeline: Request queue with dead-letter topic
  • ComfyUIWorkerPool, AIDirectorService, ResplatWorker, AudioWorker: Kubernetes deployments via pulumi_kubernetes

infrastructure/kubernetes/

Reference Kubernetes manifests (deprecated in favour of Pulumi, but useful for debugging).

contracts/src/

Base L2 (Ethereum) contracts:

  • CharacterNFT: ERC-721 with free/paid/custom mint tiers
  • AIDirectorPaymaster: ERC-4337 paymaster sponsoring first-time gas
  • CharacterSplits: 0xSplits-compatible royalty distribution

frontend/src/

React + TypeScript progressive onboarding UI:

  • No crypto jargon for new users
  • Social login โ†’ character reveal โ†’ optional Web3 upgrade
  • Integrated @mkkellogg/gaussian-splats-3d WebGL viewer for .ply files

๐ŸŒฉ๏ธ GCP Deployment

โš ๏ธ Cost Warning

TierIdle CostActive CostBest For
Max Mini (dev)~$50-70/mo~$100-200/moSolo dev, 2D only
Standard Dev~$150/mo~$300-500/moTeam dev, full pipeline
Production~$285/mo~$1,500-9,000/moLive users, high availability

Note: First deployment takes 15-20 minutes. Ensure you have GPU quota before deploying.

Quick Deploy (Makefile)

# 1. Check prerequisites
make check

# 2. Set your project
export GCP_PROJECT_ID=your-project-id

# 3. Deploy (choose one)
make deploy-dev      # Max Mini tier (~$50/mo idle)
make deploy-staging  # Standard Dev tier (~$150/mo idle)
make deploy-prod     # Production tier (~$285/mo idle)

# 4. Test the API
make test-api

Manual Deploy

# 1. Setup gcloud
export GCP_PROJECT_ID=your-project-id
./infrastructure/scripts/gcloud-setup.sh

# 2. Build images
make build-images

# 3. Deploy with Pulumi
cd infrastructure/pulumi
pulumi stack init dev
pulumi config set project_id $GCP_PROJECT_ID
pulumi config set environment dev
pulumi up

# 4. Get the load balancer IP
make get-ip

Required GCP Quotas

Before deploying, ensure your project has these quotas:

ResourceMinimumRequest Increase
CPUS50GCP Console
NVIDIA_T4_GPUS4GCP Console
IN_USE_ADDRESSES20Usually automatic
FILESTORE_INSTANCES2Usually automatic

2. Build & Push Docker Images

export REGION=us-central1
export PROJECT_ID=YOUR_PROJECT
export REGISTRY=${REGION}-docker.pkg.dev/${PROJECT_ID}/mmp-images

# AI Director
docker build -t ${REGISTRY}/ai-director:latest services/ai-director/
docker push ${REGISTRY}/ai-director:latest

# ComfyUI Worker
docker build -t ${REGISTRY}/comfyui-worker:latest services/comfyui-worker/
docker push ${REGISTRY}/comfyui-worker:latest

# Audio Worker
docker build -t ${REGISTRY}/audio-worker:latest services/audio-worker/
docker push ${REGISTRY}/audio-worker:latest

# ReSplat Worker (optional)
docker build -t ${REGISTRY}/resplat-worker:latest services/resplat-worker/
docker push ${REGISTRY}/resplat-worker:latest

3. Deploy Contracts

cd contracts
npx hardhat run scripts/deploy.ts --network base-sepolia

๐Ÿ”‘ Environment Variables

VariableDescription
GCP_PROJECT_IDYour GCP project ID
PUBSUB_TOPICPub/Sub topic for generation requests
PUBSUB_SUBSCRIPTIONPull subscription consumed by the AI Director
PUBSUB_STATUS_TOPICOptional Pub/Sub topic for emitted job lifecycle events
AI_K8S_NAMESPACESComma-separated Kubernetes namespaces exposed through MCP tools
COMFYUI_ENDPOINTComfyUI service URL
AUDIO_ENDPOINTAudio worker URL
USE_RESPLAT_FOR_3DRoute 3D generation through ReSplat (true / false)
RESPLAT_ENDPOINTReSplat worker URL
BASE_RPC_URLBase L2 RPC endpoint
BUNDLER_URLERC-4337 bundler endpoint
CHARACTER_NFT_ADDRESSDeployed CharacterNFT contract
PAYMASTER_ADDRESSDeployed AIDirectorPaymaster contract
SPLITS_ADDRESSDeployed CharacterSplits contract
ENABLE_MCP_SERVEREnable the AI Director's MCP-compatible /mcp endpoint
AI_DIRECTOR_PRIVATE_KEYOperational wallet private key (required in prod)

MCP tools

The AI Director now exposes a small MCP-compatible JSON-RPC endpoint at POST /mcp. Current tools:

  • submit_generation_job
  • get_generation_job_status
  • list_ai_k8s_resources
  • get_ai_k8s_resource

This gives external agents a standard way to drive generation and inspect the GKE AI-serving plane without adding another bespoke control API.


๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Follow the code style (Black for Python, ESLint for TS, Solhint for Solidity)
  4. Add tests for new functionality
  5. Submit a pull request

๐Ÿ“„ License

MIT โ€” see LICENSE for details.

Contributors

alexwelcing

7 commits

Copilot

4 commits

alexwelcing/mmp

multicharacter economy thing

0

stars

11

commits

Python

primary language

May 6, 2026

updated

README

๐ŸŽฎ Autonomous AI Director: GCP-Native Pipeline for Web3 Game Asset Generation

Tutorial Repository โ€” A production-quality reference implementation for building a real-time, AI-driven game asset pipeline with on-chain monetization on Base (Ethereum L2).

License: MIT Python 3.11+ Solidity ^0.8.20


๐Ÿ“– Overview

This project demonstrates a Dual-Horizon Strategy for Web3 game monetization:

HorizonDescriptionRevenue
H1 (Now)Free-to-play with gasless onboardingViral growth
H2 (Scale)On-chain character ownership + royalty splitsSustainable revenue

Players claim a free AI-generated character (no wallet required), then optionally mint it on-chain with full ownership. An autonomous AI Director orchestrates the entire pipeline โ€” from Pub/Sub request to on-chain NFT โ€” using GCP-native services.

โ˜๏ธ Google Cloud NEXT '26 Refresh

For the Google Cloud NEXT '26 coverage update, this tutorial now anchors itself on three conference signals that fit MMP especially well:

NEXT '26 session / updateWhy it matters hereMMP upgrade direction
Google MCP Services: Connect AI agents to cloud infrastructure in minutesThe AI Director is already an orchestration layer; MCP is the cleanest way to connect that layer to cloud tools without bespoke glue code.This refresh now adds a real /mcp tool surface for generation jobs plus Kubernetes AI-serving inspection.
What's new for AI on GKE: Training, serving, and agentsMMP already uses GKE GPU workers for image and 3D generation, so the repo naturally fits the new โ€œtraining, serving, and agentsโ€ framing.Treat ComfyUI and ReSplat as a reusable AI serving plane with clearer scaling and reliability guidance.
What's new in streaming: Real-time data for agentic AIThe project already depends on Pub/Sub, but only as a request queue. NEXT '26 pushes the bigger idea: agent systems need real-time event backbones.This refresh now adds a dedicated Pub/Sub lifecycle topic so MMP emits job status events in addition to request intake.

See docs/architecture.md for the concrete upgrade path and docs/google-cloud-next-2026-submission-draft.md for the draft contest post.


๐Ÿ—๏ธ Architecture

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                        FRONTEND (React/Vite)                    โ”‚
โ”‚  FreeRollStep โ†’ CharacterCard โ†’ PaidRollStep โ†’ WalletProvider   โ”‚
โ”‚                         โ†‘                                       โ”‚
โ”‚              GaussianSplatViewer (WebGL .ply)                   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                           โ”‚ REST API
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    AI DIRECTOR SERVICE (FastAPI)                 โ”‚
โ”‚                                                                 โ”‚
โ”‚  OrchestratorAgent                                              โ”‚
โ”‚  โ”œโ”€โ”€ ImageAgent  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ ComfyUI Worker (GKE + GPU)         โ”‚
โ”‚  โ”‚   (2D draft โ†’ upscale)        โ–ฒ                              โ”‚
โ”‚  โ”œโ”€โ”€ EvaluatorAgent              โ”‚ Webhook (AIDirectorWebhook)  โ”‚
โ”‚  โ”œโ”€โ”€ AudioAgent  โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ Audio Worker (AudioGen)            โ”‚
โ”‚  โ”œโ”€โ”€ ResplatAgent โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ ReSplat Worker (GPU)               โ”‚
โ”‚  โ”‚   (Stable Zero123 โ†’ COLMAP โ†’ 3DGS)                           โ”‚
โ”‚  โ””โ”€โ”€ Web3Agent   โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–บ Base L2 (ERC-4337)                 โ”‚
โ”‚                                       โ”‚                        โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ฌโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                           โ”‚            โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                       GCP INFRASTRUCTURE                        โ”‚
โ”‚                                                                 โ”‚
โ”‚  Pub/Sub Topics          GKE Cluster          Filestore NFS     โ”‚
โ”‚  asset-generation  โ”€โ”€โ”€โ–บ  GPU Node Pool  โ—„โ”€โ”€โ”€  Model Cache       โ”‚
โ”‚  (requests/dlq)          (gVisor + CUDA)      (ReadWriteMany)   โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
                           โ”‚
โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ–ผโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚                    BASE L2 SMART CONTRACTS                      โ”‚
โ”‚                                                                 โ”‚
โ”‚  CharacterNFT (ERC-721)                                         โ”‚
โ”‚  โ”œโ”€โ”€ AIDirectorPaymaster (ERC-4337) โ† Gasless for new users     โ”‚
โ”‚  โ””โ”€โ”€ CharacterSplits (0xSplits)    โ† Royalty distribution       โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜

๐Ÿ“‹ Prerequisites

ToolVersionPurpose
Python3.11+AI Director service
Node.js18+Contracts & frontend
Pulumi3.120+GCP infrastructure (Python)
kubectl1.28+Kubernetes management
Docker24+Container builds
Makeโ€”One-command local dev
GCP Accountโ€”Cloud infrastructure

๐Ÿš€ Quick Start (Local Dev)

The fastest way to run locally is hybrid mode: ComfyUI, AudioGen, and optional ReSplat run in Docker; the AI Director and Frontend run natively for fast hot-reload.

# 1. Install dependencies once
make install

# 2. Start ComfyUI + AudioGen containers
make dev-native

# 3. Deploy local contracts (creates .env.contracts)
make contracts-local
export $(cat .env.contracts | xargs)

# 4. Start the AI Director (in a second terminal)
cd services/ai-director
source .venv/bin/activate
uvicorn main:app --reload --port 8080

# 5. Start the frontend (in a third terminal)
cd frontend
npm run dev
# Open http://localhost:5173

Optional: ReSplat 3D Mode

If you have an NVIDIA GPU with CUDA 12.8 support, start the full stack including ReSplat:

make dev-resplat

Then set USE_RESPLAT_FOR_3D=true in your .env to route 3D generation through ReSplat instead of ComfyUI.


๐Ÿ—‚๏ธ Component Breakdown

services/ai-director/

The core orchestration service. Subscribes to GCP Pub/Sub, routes requests through a multi-agent pipeline, and coordinates asset delivery.

agents/
โ”œโ”€โ”€ orchestrator.py    # Main pipeline coordinator
โ”œโ”€โ”€ image_agent.py     # 2D draft + upscale (ComfyUI)
โ”œโ”€โ”€ evaluator_agent.py # Aesthetic scoring & selection
โ”œโ”€โ”€ audio_agent.py     # Soundscape generation (AudioGen)
โ”œโ”€โ”€ resplat_agent.py   # 3D Gaussian Splatting (ReSplat)
โ””โ”€โ”€ web3_agent.py      # ERC-4337 gasless minting + splits

services/comfyui-worker/

Containerized ComfyUI with custom workflows and the AIDirectorWebhook custom node for push notifications:

  • lightning_2d_draft.json โ€” Fast SDXL-Lightning draft generation
  • mesh_generation.json โ€” 3D mesh generation fallback

services/audio-worker/

Facebook AudioGen inference service via Hugging Face Hub. Generates character soundscapes on CPU.

services/resplat-worker/

Full 3D Gaussian Splatting pipeline: Stable Zero123 multi-view synthesis โ†’ COLMAP sparse reconstruction โ†’ ReSplat inference โ†’ .ply output.

infrastructure/pulumi/

GCP infrastructure as code using Python Component Resources:

  • MMPCluster: VPC, GKE, system/GPU node pools, Workload Identity
  • FilestoreCache: NFS-backed shared model cache (ReadWriteMany)
  • PubSubPipeline: Request queue with dead-letter topic
  • ComfyUIWorkerPool, AIDirectorService, ResplatWorker, AudioWorker: Kubernetes deployments via pulumi_kubernetes

infrastructure/kubernetes/

Reference Kubernetes manifests (deprecated in favour of Pulumi, but useful for debugging).

contracts/src/

Base L2 (Ethereum) contracts:

  • CharacterNFT: ERC-721 with free/paid/custom mint tiers
  • AIDirectorPaymaster: ERC-4337 paymaster sponsoring first-time gas
  • CharacterSplits: 0xSplits-compatible royalty distribution

frontend/src/

React + TypeScript progressive onboarding UI:

  • No crypto jargon for new users
  • Social login โ†’ character reveal โ†’ optional Web3 upgrade
  • Integrated @mkkellogg/gaussian-splats-3d WebGL viewer for .ply files

๐ŸŒฉ๏ธ GCP Deployment

โš ๏ธ Cost Warning

TierIdle CostActive CostBest For
Max Mini (dev)~$50-70/mo~$100-200/moSolo dev, 2D only
Standard Dev~$150/mo~$300-500/moTeam dev, full pipeline
Production~$285/mo~$1,500-9,000/moLive users, high availability

Note: First deployment takes 15-20 minutes. Ensure you have GPU quota before deploying.

Quick Deploy (Makefile)

# 1. Check prerequisites
make check

# 2. Set your project
export GCP_PROJECT_ID=your-project-id

# 3. Deploy (choose one)
make deploy-dev      # Max Mini tier (~$50/mo idle)
make deploy-staging  # Standard Dev tier (~$150/mo idle)
make deploy-prod     # Production tier (~$285/mo idle)

# 4. Test the API
make test-api

Manual Deploy

# 1. Setup gcloud
export GCP_PROJECT_ID=your-project-id
./infrastructure/scripts/gcloud-setup.sh

# 2. Build images
make build-images

# 3. Deploy with Pulumi
cd infrastructure/pulumi
pulumi stack init dev
pulumi config set project_id $GCP_PROJECT_ID
pulumi config set environment dev
pulumi up

# 4. Get the load balancer IP
make get-ip

Required GCP Quotas

Before deploying, ensure your project has these quotas:

ResourceMinimumRequest Increase
CPUS50GCP Console
NVIDIA_T4_GPUS4GCP Console
IN_USE_ADDRESSES20Usually automatic
FILESTORE_INSTANCES2Usually automatic

2. Build & Push Docker Images

export REGION=us-central1
export PROJECT_ID=YOUR_PROJECT
export REGISTRY=${REGION}-docker.pkg.dev/${PROJECT_ID}/mmp-images

# AI Director
docker build -t ${REGISTRY}/ai-director:latest services/ai-director/
docker push ${REGISTRY}/ai-director:latest

# ComfyUI Worker
docker build -t ${REGISTRY}/comfyui-worker:latest services/comfyui-worker/
docker push ${REGISTRY}/comfyui-worker:latest

# Audio Worker
docker build -t ${REGISTRY}/audio-worker:latest services/audio-worker/
docker push ${REGISTRY}/audio-worker:latest

# ReSplat Worker (optional)
docker build -t ${REGISTRY}/resplat-worker:latest services/resplat-worker/
docker push ${REGISTRY}/resplat-worker:latest

3. Deploy Contracts

cd contracts
npx hardhat run scripts/deploy.ts --network base-sepolia

๐Ÿ”‘ Environment Variables

VariableDescription
GCP_PROJECT_IDYour GCP project ID
PUBSUB_TOPICPub/Sub topic for generation requests
PUBSUB_SUBSCRIPTIONPull subscription consumed by the AI Director
PUBSUB_STATUS_TOPICOptional Pub/Sub topic for emitted job lifecycle events
AI_K8S_NAMESPACESComma-separated Kubernetes namespaces exposed through MCP tools
COMFYUI_ENDPOINTComfyUI service URL
AUDIO_ENDPOINTAudio worker URL
USE_RESPLAT_FOR_3DRoute 3D generation through ReSplat (true / false)
RESPLAT_ENDPOINTReSplat worker URL
BASE_RPC_URLBase L2 RPC endpoint
BUNDLER_URLERC-4337 bundler endpoint
CHARACTER_NFT_ADDRESSDeployed CharacterNFT contract
PAYMASTER_ADDRESSDeployed AIDirectorPaymaster contract
SPLITS_ADDRESSDeployed CharacterSplits contract
ENABLE_MCP_SERVEREnable the AI Director's MCP-compatible /mcp endpoint
AI_DIRECTOR_PRIVATE_KEYOperational wallet private key (required in prod)

MCP tools

The AI Director now exposes a small MCP-compatible JSON-RPC endpoint at POST /mcp. Current tools:

  • submit_generation_job
  • get_generation_job_status
  • list_ai_k8s_resources
  • get_ai_k8s_resource

This gives external agents a standard way to drive generation and inspect the GKE AI-serving plane without adding another bespoke control API.


๐Ÿค Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Follow the code style (Black for Python, ESLint for TS, Solhint for Solidity)
  4. Add tests for new functionality
  5. Submit a pull request

๐Ÿ“„ License

MIT โ€” see LICENSE for details.

Contributors

alexwelcing

7 commits

Copilot

4 commits

Languages

Python

62.7%

TypeScript

18.3%

Solidity

7.3%

Shell

4.6%

HCL

3.8%

Dockerfile

1.8%

Makefile

1.3%