Skip to main content
Vibra Code connects three distinct environments — your phone, a Next.js backend, and E2B cloud sandboxes — through a real-time pipeline. This page explains how those pieces fit together and what happens at each stage when you describe an app.

System diagram

The phone never talks to the sandbox directly. All communication flows through the backend and Convex, which decouples the mobile client from the long-running build process and lets the phone reconnect at any time without losing progress.

Data flow

1

User describes an app

The user types or speaks a description in VibraCreateAppScreen. The mobile app calls the backend API (POST /api/create-session) with the prompt, chosen template, and any attached images or audio.
2

Session created in Convex

The backend creates a sessions record in Convex with status IN_PROGRESS. The mobile app subscribes to this session via Convex’s real-time client — any future status change streams to the phone immediately.
3

Inngest queues sandbox creation

The backend triggers an Inngest event that queues the create-session function. Inngest handles retries, timeouts, and fan-out, so the Next.js request returns immediately without waiting for the sandbox to be ready.
4

E2B sandbox starts and clones the template

The create-session Inngest function spawns an E2B sandbox from the pre-built template image. Inside the sandbox, the Expo template repository is cloned, npm dependencies are installed, the Expo dev server is started, and a public tunnel URL is created. The session status in Convex advances through each phase:IN_PROGRESS → CLONING_REPO → INSTALLING_DEPENDENCIES → STARTING_DEV_SERVER → CREATING_TUNNEL → RUNNING
5

AI agent generates code

Once the sandbox is ready, Inngest runs the run-agent function. The AI agent (Claude Code, Cursor, or Gemini — configured by AGENT_TYPE) reads the user’s prompt and system prompt from lib/prompts.ts, then writes, edits, and runs files inside the sandbox. Every tool operation (file read, file edit, bash command) is written to the messages table in Convex as it happens.
6

Updates stream to the phone in real time

The mobile app’s Convex subscription receives each new messages record the moment it is written. The native chat UI (built with Texture + IGListKit) renders each message type in a different cell: blue for file reads, orange for file edits, green for bash commands, and Liquid Glass cards for todo task lists.
7

Phone previews the running app via tunnel URL

When the tunnel URL is available in the sessions record, the mobile app loads the live preview. For Expo React Native templates, the preview renders natively. For Next.js and other web templates, a WKWebView is used. The user can send follow-up messages to the same session — the agent resumes in the existing sandbox without re-cloning.

Backend stack

Mobile stack

Convex schema overview

The Convex database is shared between the backend and mobile app. The mobile convex/ directory is a symlink to vibracode-backend/convex/.

users table

Stores Clerk user profiles alongside billing and credit state.

sessions table

Each build is one session. The session record tracks the full lifecycle from sandbox creation to completion.

messages table

Every agent action and user message is stored as a messages record. The mobile chat UI reads these in real time.

Session status lifecycle

A session advances through the following statuses as the sandbox is created and the agent runs. All transitions are written to Convex and stream to the mobile app in real time.
The CUSTOM status is used when the agent sends a status message of its own (for example, “Building the authentication flow”). Additional statuses (CREATING_GITHUB_REPO, PUSHING_TO_GITHUB, PUSH_COMPLETE) are used during the optional GitHub push flow.

Project structure

Ready to set up your own instance? Follow the quick start to get the backend and mobile app running end to end.