A monorepo containing a ContainerManager service that creates and manages Docker containers with WebContainer-like API endpoints and WebSocket interactions.
- Backend (
apps/backend): NestJS service that manages Docker containers - Frontend (
apps/frontend): Next.js AgentApp client with Material-UI and Tailwind CSS - Monorepo: pnpm workspaces with shared configurations
- Create/delete Docker containers via REST API
- WebContainer-compatible API endpoints for easy client migration
- WebSocket support for real-time container interactions
- File system operations (read/write files, create directories)
- Process spawning and terminal emulation
- Modern UI with Material-UI components and dark theme
- Node.js 18+
- Docker Desktop
- pnpm (recommended) or npm
# Install dependencies
pnpm install
# Copy environment variables
cp apps/frontend/.env.local.example apps/frontend/.env.local
# Start development servers
pnpm devThis will start:
- Backend API server on
http://localhost:3001 - Frontend application on
http://localhost:3000
POST /containers- Create a new containerGET /containers- List all containersGET /containers/:id- Get container infoDELETE /containers/:id- Delete container
POST /webcontainer/boot- Boot a WebContainer instancePOST /webcontainer/:id/fs/writeFile- Write fileGET /webcontainer/:id/fs/readFile/:path- Read fileGET /webcontainer/:id/fs/readdir/:path- List directoryPOST /webcontainer/:id/fs/mkdir- Create directoryDELETE /webcontainer/:id/fs/rm- Remove file/directoryPOST /webcontainer/:id/spawn- Spawn process
Connect to /container namespace:
join-container- Join a container sessionfs-operation- File system operationsprocess-operation- Process operationsterminal-input- Terminal input
# Run all services in development mode
pnpm dev
# Build all packages
pnpm build
# Run linting
pnpm lint
# Clean all build artifacts
pnpm clean
# Install dependencies for all workspaces
pnpm install├── apps/
│ ├── backend/ # NestJS backend service
│ │ ├── src/
│ │ │ ├── container-manager/ # Docker container management
│ │ │ ├── websocket/ # WebSocket gateway
│ │ │ └── types/ # TypeScript types
│ │ └── package.json
│ └── frontend/ # Next.js frontend application
│ ├── src/
│ │ ├── app/ # Next.js app router
│ │ ├── components/ # React components
│ │ ├── lib/ # API clients and utilities
│ │ └── types/ # TypeScript types
│ └── package.json
├── packages/ # Shared packages (if needed)
└── package.json # Root package.json
import { webContainerAPI } from '@/lib/api'
// Boot a new container with files
const container = await webContainerAPI.boot({
files: {
'package.json': {
file: {
contents: JSON.stringify({ name: 'my-app', version: '1.0.0' })
}
}
}
})
// Write a file
await webContainerAPI.writeFile(container.containerId, '/server.js', `
const http = require('http')
const server = http.createServer((req, res) => {
res.end('Hello World!')
})
server.listen(3000)
`)
// Spawn a process
await webContainerAPI.spawn(container.containerId, 'node', ['server.js'])import { ContainerWebSocket } from '@/lib/websocket'
const ws = new ContainerWebSocket()
const socket = ws.connect(containerId)
// Listen for terminal output
ws.onMessage('terminal-output', (data) => {
console.log(data.output)
})
// Send terminal input
ws.sendTerminalInput('ls -la')- Backend: NestJS, TypeScript, Docker API, Socket.IO
- Frontend: Next.js 14, React 18, Material-UI, Tailwind CSS, Socket.IO Client
- Build System: pnpm workspaces, TypeScript, ESLint
- Container Runtime: Docker
MIT