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).
This project demonstrates a Dual-Horizon Strategy for Web3 game monetization:
| Horizon | Description | Revenue |
|---|---|---|
| H1 (Now) | Free-to-play with gasless onboarding | Viral growth |
| H2 (Scale) | On-chain character ownership + royalty splits | Sustainable 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.
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 / update | Why it matters here | MMP upgrade direction |
|---|---|---|
Google MCP Services: Connect AI agents to cloud infrastructure in minutes | The 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 agents | MMP 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 AI | The 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.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 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 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
| Tool | Version | Purpose |
|---|---|---|
| Python | 3.11+ | AI Director service |
| Node.js | 18+ | Contracts & frontend |
| Pulumi | 3.120+ | GCP infrastructure (Python) |
| kubectl | 1.28+ | Kubernetes management |
| Docker | 24+ | Container builds |
| Make | โ | One-command local dev |
| GCP Account | โ | Cloud infrastructure |
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
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.
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 generationmesh_generation.json โ 3D mesh generation fallbackservices/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:
pulumi_kubernetesinfrastructure/kubernetes/Reference Kubernetes manifests (deprecated in favour of Pulumi, but useful for debugging).
contracts/src/Base L2 (Ethereum) contracts:
frontend/src/React + TypeScript progressive onboarding UI:
@mkkellogg/gaussian-splats-3d WebGL viewer for .ply files| Tier | Idle Cost | Active Cost | Best For |
|---|---|---|---|
| Max Mini (dev) | ~$50-70/mo | ~$100-200/mo | Solo dev, 2D only |
| Standard Dev | ~$150/mo | ~$300-500/mo | Team dev, full pipeline |
| Production | ~$285/mo | ~$1,500-9,000/mo | Live users, high availability |
Note: First deployment takes 15-20 minutes. Ensure you have GPU quota before deploying.
# 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
# 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
Before deploying, ensure your project has these quotas:
| Resource | Minimum | Request Increase |
|---|---|---|
| CPUS | 50 | GCP Console |
| NVIDIA_T4_GPUS | 4 | GCP Console |
| IN_USE_ADDRESSES | 20 | Usually automatic |
| FILESTORE_INSTANCES | 2 | Usually automatic |
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
cd contracts
npx hardhat run scripts/deploy.ts --network base-sepolia
| Variable | Description |
|---|---|
GCP_PROJECT_ID | Your GCP project ID |
PUBSUB_TOPIC | Pub/Sub topic for generation requests |
PUBSUB_SUBSCRIPTION | Pull subscription consumed by the AI Director |
PUBSUB_STATUS_TOPIC | Optional Pub/Sub topic for emitted job lifecycle events |
AI_K8S_NAMESPACES | Comma-separated Kubernetes namespaces exposed through MCP tools |
COMFYUI_ENDPOINT | ComfyUI service URL |
AUDIO_ENDPOINT | Audio worker URL |
USE_RESPLAT_FOR_3D | Route 3D generation through ReSplat (true / false) |
RESPLAT_ENDPOINT | ReSplat worker URL |
BASE_RPC_URL | Base L2 RPC endpoint |
BUNDLER_URL | ERC-4337 bundler endpoint |
CHARACTER_NFT_ADDRESS | Deployed CharacterNFT contract |
PAYMASTER_ADDRESS | Deployed AIDirectorPaymaster contract |
SPLITS_ADDRESS | Deployed CharacterSplits contract |
ENABLE_MCP_SERVER | Enable the AI Director's MCP-compatible /mcp endpoint |
AI_DIRECTOR_PRIVATE_KEY | Operational wallet private key (required in prod) |
The AI Director now exposes a small MCP-compatible JSON-RPC endpoint at POST /mcp.
Current tools:
submit_generation_jobget_generation_job_statuslist_ai_k8s_resourcesget_ai_k8s_resourceThis gives external agents a standard way to drive generation and inspect the GKE AI-serving plane without adding another bespoke control API.
git checkout -b feature/amazing-feature)MIT โ see LICENSE for details.
7 commits
4 commits
Python
62.7%
TypeScript
18.3%
Solidity
7.3%
Shell
4.6%
HCL
3.8%
Dockerfile
1.8%
Makefile
1.3%
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).
This project demonstrates a Dual-Horizon Strategy for Web3 game monetization:
| Horizon | Description | Revenue |
|---|---|---|
| H1 (Now) | Free-to-play with gasless onboarding | Viral growth |
| H2 (Scale) | On-chain character ownership + royalty splits | Sustainable 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.
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 / update | Why it matters here | MMP upgrade direction |
|---|---|---|
Google MCP Services: Connect AI agents to cloud infrastructure in minutes | The 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 agents | MMP 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 AI | The 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.
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ 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 โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
| Tool | Version | Purpose |
|---|---|---|
| Python | 3.11+ | AI Director service |
| Node.js | 18+ | Contracts & frontend |
| Pulumi | 3.120+ | GCP infrastructure (Python) |
| kubectl | 1.28+ | Kubernetes management |
| Docker | 24+ | Container builds |
| Make | โ | One-command local dev |
| GCP Account | โ | Cloud infrastructure |
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
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.
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 generationmesh_generation.json โ 3D mesh generation fallbackservices/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:
pulumi_kubernetesinfrastructure/kubernetes/Reference Kubernetes manifests (deprecated in favour of Pulumi, but useful for debugging).
contracts/src/Base L2 (Ethereum) contracts:
frontend/src/React + TypeScript progressive onboarding UI:
@mkkellogg/gaussian-splats-3d WebGL viewer for .ply files| Tier | Idle Cost | Active Cost | Best For |
|---|---|---|---|
| Max Mini (dev) | ~$50-70/mo | ~$100-200/mo | Solo dev, 2D only |
| Standard Dev | ~$150/mo | ~$300-500/mo | Team dev, full pipeline |
| Production | ~$285/mo | ~$1,500-9,000/mo | Live users, high availability |
Note: First deployment takes 15-20 minutes. Ensure you have GPU quota before deploying.
# 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
# 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
Before deploying, ensure your project has these quotas:
| Resource | Minimum | Request Increase |
|---|---|---|
| CPUS | 50 | GCP Console |
| NVIDIA_T4_GPUS | 4 | GCP Console |
| IN_USE_ADDRESSES | 20 | Usually automatic |
| FILESTORE_INSTANCES | 2 | Usually automatic |
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
cd contracts
npx hardhat run scripts/deploy.ts --network base-sepolia
| Variable | Description |
|---|---|
GCP_PROJECT_ID | Your GCP project ID |
PUBSUB_TOPIC | Pub/Sub topic for generation requests |
PUBSUB_SUBSCRIPTION | Pull subscription consumed by the AI Director |
PUBSUB_STATUS_TOPIC | Optional Pub/Sub topic for emitted job lifecycle events |
AI_K8S_NAMESPACES | Comma-separated Kubernetes namespaces exposed through MCP tools |
COMFYUI_ENDPOINT | ComfyUI service URL |
AUDIO_ENDPOINT | Audio worker URL |
USE_RESPLAT_FOR_3D | Route 3D generation through ReSplat (true / false) |
RESPLAT_ENDPOINT | ReSplat worker URL |
BASE_RPC_URL | Base L2 RPC endpoint |
BUNDLER_URL | ERC-4337 bundler endpoint |
CHARACTER_NFT_ADDRESS | Deployed CharacterNFT contract |
PAYMASTER_ADDRESS | Deployed AIDirectorPaymaster contract |
SPLITS_ADDRESS | Deployed CharacterSplits contract |
ENABLE_MCP_SERVER | Enable the AI Director's MCP-compatible /mcp endpoint |
AI_DIRECTOR_PRIVATE_KEY | Operational wallet private key (required in prod) |
The AI Director now exposes a small MCP-compatible JSON-RPC endpoint at POST /mcp.
Current tools:
submit_generation_jobget_generation_job_statuslist_ai_k8s_resourcesget_ai_k8s_resourceThis gives external agents a standard way to drive generation and inspect the GKE AI-serving plane without adding another bespoke control API.
git checkout -b feature/amazing-feature)MIT โ see LICENSE for details.
7 commits
4 commits
Python
62.7%
TypeScript
18.3%
Solidity
7.3%
Shell
4.6%
HCL
3.8%
Dockerfile
1.8%
Makefile
1.3%