The Modal Vibe repo demonstrates how you can build a scalable AI coding platform on Modal.
Users of the application can prompt an LLM to create sandboxed applications that service React through a UI.
Each application lives on a Modal Sandbox and contains a webserver accessible through Modal Tunnels.
For a high-level overview of Modal Vibe, including performance numbers and why they matter, see the accompanying blog post. For details on the implementation, read on.
main.pyis the entrypoint that runs the FastAPI controller that serves the web app and manages the sandbox apps.corecontains the logic forSandboxAppmodel and LLM logic.sandboxcontains a small HTTP server that gets put inside every Sandbox that's created, as well as some sandbox lifecycle management code.webcontains the Modal Vibe website that users see and interact with, as well as the api server that manages Sandboxes.
First, set up the local environment:
python3 -m venv venv && source venv/bin/activate && pip install -r requirements.dev.txtTo deploy to Modal, copy .env.example to a file called .env and add your ANTHROPIC_API_KEY.
Also, create a Modal Secret called anthropic-secret so our applications can access it.
Then, deploy the application with Modal:
modal deploy -m mainRun a load test:
modal run main.py::create_app_loadtest_function --num-apps 10Delete a sandbox:
modal run main.py::delete_sandbox_admin_function --app-id <APP_ID>Run an example sandbox HTTP server:
python -m sandbox.server