A self-hosted studio where you can watch an AI agent draw UI live, piece by piece or page by page.
Browser (you)
| HTTPS
v
Caddy (public, auto-HTTPS, auth gate)
|-- /studio/* -> Studio UI (Vite dev server)
|-- /api/* -> FastAPI (auth, agent tools, events, git)
|-- /ws -> WebSocket (live updates)
'-- /preview/* -> Vite dev server (hot reload)
FastAPI --writes files--> Workspace volume <-- Vite watches
| ^
| '-- git (commit per agent turn)
'-- WebSocket events --> Browser activity feed
Playwright (headless) --screenshots--> back to the agent
- Docker & Docker Compose
- A domain name (for production)
- GitHub account (for pushing)
# Clone and enter
cd live-preview
# Copy environment example
cp .env.example .env
# Edit .env with your values
# Start all services
docker-compose up -d
# View logs
docker-compose logs -f
# Access
# Studio UI: http://localhost/studio/
# API: http://localhost/api/
# Health: http://localhost/health- Set up a VM with Docker
- Point your domain (e.g.,
preview.yourdomain.com) to the VM - Configure
.envwith your domain and secure secrets - Run
docker-compose up -d - Caddy will automatically provision HTTPS certificates
live-preview/
├── docker-compose.yml # Main orchestration
├── Caddyfile # Reverse proxy config
├── .env.example # Environment template
├── .gitignore
├── backend/ # FastAPI server
│ ├── Dockerfile
│ ├── requirements.txt
│ └── app/
│ ├── main.py
│ ├── core/
│ ├── api/
│ ├── services/
│ └── models/
├── workspace/ # Agent's design project (Vite + React)
│ ├── Dockerfile
│ ├── package.json
│ ├── vite.config.ts
│ ├── tailwind.config.js
│ └── src/
│ ├── components/
│ ├── layout/
│ ├── sections/
│ ├── styles/
│ └── lib/
└── screenshotter/ # Playwright service
├── Dockerfile
├── package.json
└── index.js
POST /api/auth/register- Register new userPOST /api/auth/login- Login (returns JWT)GET /api/auth/me- Get current user
GET /api/files?path=- List filesGET /api/files/content?path=- Read filePOST /api/files- Write filePATCH /api/files- Edit file (patch)DELETE /api/files?path=- Delete file
GET /api/components- List available component previews
POST /api/git/commit- Commit changesGET /api/git/history- Get commit historyPOST /api/git/checkout- Checkout commit
WS /api/ws- Real-time events (file changes, commits)
The FastAPI backend provides these tools for the AI agent:
list_files(path)- Browse workspaceread_file(path)- Read file contentwrite_file(path, content)- Create/update fileedit_file(path, old_string, new_string)- Patch editdelete_file(path)- Delete filelist_components()- Discover preview componentscommit(message)- Save versionscreenshot(viewport, component)- Capture preview
Components auto-discover via *.preview.tsx files:
src/
├── components/
│ ├── Button.tsx
│ └── Button.preview.tsx
├── layout/
│ ├── Header.tsx
│ └── Header.preview.tsx
└── sections/
├── Hero.tsx
└── Hero.preview.tsx
Views:
- Single: One component full-size
- Grid: All components as thumbnails
- Page: Sections stacked in order
- Agent receives design request
- Agent writes/edits files via API
- Vite detects changes → hot reloads browser
- WebSocket broadcasts file change events
- (Optional) Screenshotter captures preview
- Agent reviews screenshots, iterates
- Agent commits version
Private project - all rights reserved.