A monorepo project for building and managing sandbox environments with support for Docker and Firecracker executors.
This Turborepo monorepo includes:
apps/server: Express.js backend with Prisma ORM and PostgreSQL databaseapps/web: React frontend built with Vite, TypeScript, and Tailwind CSS
packages/ui: Shared React component librarypackages/eslint-config: Shared ESLint configurationspackages/typescript-config: Shared TypeScript configurations
- Node.js >= 18
- pnpm >= 9.0.0 (package manager)
- PostgreSQL database
- Docker (required for running sandboxes)
-
Clone the repository
git clone <repository-url> cd mini-e2b
-
Install dependencies
pnpm install
-
Set up environment variables (see Environment Variables section below)
-
Set up the database
cd apps/server pnpm db:migrate # Run database migrations pnpm db:generate # Generate Prisma client
-
Start development servers
# From the root directory pnpm devThis will start:
- Backend server at
http://localhost:3000 - Frontend app at
http://localhost:5173
- Backend server at
Create a .env file in the root directory:
# Root .env (used for both apps)
DATABASE_URL="postgresql://username:password@localhost:5432/sandbox_db?schema=public"
FRONTEND_URL="http://localhost:5173"
PORT="3000"
VITE_API_BASE_URL="http://localhost:3000"
EXECUTOR="docker"Create a .env file in apps/server/:
PORT=3000
FRONTEND_URL=http://localhost:5173
DATABASE_URL="postgresql://username:password@localhost:5432/sandbox_db?schema=public"
# Executor type: "docker" or "firecracker" firecracker only works on linux
EXECUTOR="docker"Create a .env file in apps/web/:
# API Configuration
VITE_API_BASE_URL=http://localhost:3000| Variable | Location | Description | Default |
|---|---|---|---|
DATABASE_URL |
server | PostgreSQL connection string | Required |
PORT |
server | Server port | 3000 |
FRONTEND_URL |
server | Frontend URL for CORS | http://localhost:5173 |
VITE_API_BASE_URL |
web | Backend API URL | http://localhost:3000 |
EXECUTOR |
server | Executor type (docker or firecracker) |
docker |
-
Local PostgreSQL
# Install PostgreSQL (macOS) brew install postgresql brew services start postgresql # Create database createdb sandbox_db
-
Using Neon (Cloud PostgreSQL)
- Sign up at neon.tech
- Create a new project
- Copy the connection string to
DATABASE_URL
-
Run migrations
cd apps/server pnpm db:migrate
# Development
pnpm dev # Start all apps in development mode
# Build
pnpm build # Build all apps and packages
# Code Quality
pnpm lint # Lint all packages
pnpm format # Format code with Prettier
pnpm check-types # Type-check all packagescd apps/server
pnpm dev # Start server with nodemon
pnpm build # Build server
pnpm db:generate # Generate Prisma client
pnpm db:migrate # Run database migrations
pnpm db:push # Push schema changes to database
pnpm db:studio # Open Prisma Studiocd apps/web
pnpm dev # Start Vite dev server
pnpm build # Build for production
pnpm preview # Preview production build
pnpm lint # Run ESLintYou can run specific apps using Turbo filters:
# Run only the server
turbo dev --filter=server
# Run only the web app
turbo dev --filter=web
# Run both apps
turbo dev-
Database Changes
cd apps/server # Edit prisma/schema.prisma pnpm db:migrate # Create and apply migration
-
Adding Dependencies
# Root dependency (shared across apps) pnpm add -w <package> # App-specific dependency pnpm --filter server add <package> pnpm --filter web add <package>
This project uses Docker for sandbox execution. Make sure Docker is running:
# Check Docker status
docker ps
# If not running, start Docker Desktop
# (macOS: open Docker Desktop app)- Frontend: React, TypeScript, Vite, Tailwind CSS, React Router
- Backend: Express.js, TypeScript, Prisma, Dockerode
- Database: PostgreSQL
- Monorepo: Turborepo
- Package Manager: pnpm
# Check PostgreSQL is running
pg_isready
# Connect to database to verify credentials
psql -d sandbox_dbChange the PORT in your .env files if port 3000 or 5173 are already in use.
cd apps/server
pnpm db:generate# Clean and reinstall
rm -rf node_modules apps/*/node_modules packages/*/node_modules
pnpm installISC
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request