A modern, full-stack AI-powered code generation platform built with Next.js, tRPC, and Prisma.
Bolt is an advanced web application that enables users to generate, execute, and manage code through AI-powered interactions. It provides secure sandboxed environments for code execution, real-time collaboration, and comprehensive project management.
- AI-Powered Code Generation: Generate code using OpenAI's GPT models
- Secure Code Execution: Run code safely in sandboxed E2B environments
- Real-time Processing: Background job processing with Inngest
- User Authentication: Secure authentication with Clerk
- Project Management: Organize code generations into projects
- Usage Tracking: Built-in credit system and rate limiting
- Modern UI: Beautiful, responsive interface with Radix UI and Tailwind CSS
- Type-Safe API: Full-stack type safety with tRPC
graph TB
subgraph "Frontend"
A[Next.js App Router] --> B[React Components]
B --> C[tRPC Client]
C --> D[TanStack Query]
end
subgraph "Backend"
E[tRPC Server] --> F[Prisma ORM]
F --> G[PostgreSQL]
E --> H[Inngest Jobs]
H --> I[E2B Sandboxes]
E --> J[OpenAI API]
end
subgraph "Auth & Services"
K[Clerk Auth]
L[Rate Limiting]
M[Usage Tracking]
end
C --> E
A --> K
F --> L
F --> M
style A fill:#0ea5e9
style G fill:#10b981
style I fill:#f59e0b
style J fill:#8b5cf6
sequenceDiagram
participant U as User
participant F as Frontend
participant A as API/tRPC
participant D as Database
participant I as Inngest
participant E as E2B Sandbox
participant O as OpenAI
U->>F: Create new project
F->>A: projects.create()
A->>D: Save project & message
A->>I: Trigger code-agent job
A-->>F: Return project ID
I->>O: Generate code
O-->>I: Return generated code
I->>E: Execute in sandbox
E-->>I: Return execution results
I->>D: Save results & fragments
I-->>F: Update UI via polling/webhook
U->>F: View results
F->>A: messages.getMany()
A->>D: Fetch project messages
A-->>F: Return messages & fragments
bolt/
βββ π prisma/ # Database schema & migrations
β βββ schema.prisma # Database schema definition
β βββ migrations/ # Database migration files
βββ π public/ # Static assets
βββ π sandbox-templates/ # E2B sandbox configurations
β βββ nextjs/ # Next.js sandbox template
βββ π src/
β βββ π app/ # Next.js App Router
β β βββ layout.tsx # Root layout
β β βββ page.tsx # Home page
β β βββ globals.css # Global styles
β β βββ π (home)/ # Home route group
β β β βββ layout.tsx # Home layout
β β β βββ page.tsx # Landing page
β β β βββ π pricing/ # Pricing page
β β βββ π api/ # API routes
β β β βββ π inngest/ # Inngest webhook handler
β β β βββ π trpc/ # tRPC API endpoint
β β βββ π sign-in/ # Authentication pages
β β βββ π sign-up/
β β βββ π projects/ # Project pages
β β βββ [projectId]/ # Dynamic project page
β βββ π components/ # Reusable UI components
β β βββ π ui/ # Base UI components (Radix)
β β βββ file-explorer.tsx # File tree component
β β βββ tree-view.tsx # Tree view utilities
β β βββ π code-view/ # Code display components
β βββ π generated/ # Generated Prisma client
β βββ π hooks/ # Custom React hooks
β βββ π inngest/ # Background job definitions
β β βββ client.ts # Inngest client setup
β β βββ functions.ts # Job function definitions
β β βββ utils.ts # Utility functions
β βββ π lib/ # Utility libraries
β β βββ db.ts # Database client
β β βββ usage.ts # Usage tracking & rate limiting
β β βββ utils.ts # General utilities
β βββ π modules/ # Feature modules
β β βββ π home/ # Home page features
β β βββ π messages/ # Message management
β β βββ π projects/ # Project management
β β βββ π usage/ # Usage tracking
β βββ π trpc/ # tRPC configuration
β βββ client.tsx # Client-side tRPC setup
β βββ init.ts # tRPC initialization
β βββ server.tsx # Server-side tRPC setup
β βββ π routers/ # API route definitions
βββ π components.json # Shadcn/ui configuration
βββ π next.config.ts # Next.js configuration
βββ π package.json # Dependencies & scripts
βββ π tailwind.config.js # Tailwind CSS configuration
βββ π tsconfig.json # TypeScript configuration
- Node.js (v20 or later)
- PostgreSQL database
- Package manager: npm, yarn, pnpm, or bun
git clone https://github.com/Pruthvik-P/bolt.git
cd boltnpm install
# or
yarn install
# or
pnpm installCreate a .env file in the root directory:
# Database
DATABASE_URL="postgresql://username:password@localhost:5432/bolt"
# Clerk Authentication
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_xxxxx
CLERK_SECRET_KEY=sk_test_xxxxx
NEXT_PUBLIC_CLERK_SIGN_IN_URL=/sign-in
NEXT_PUBLIC_CLERK_SIGN_UP_URL=/sign-up
# OpenAI
OPENAI_API_KEY=sk-xxxxx
# E2B Code Interpreter
E2B_API_KEY=e2b_xxxxx
# Inngest
INNGEST_EVENT_KEY=xxxxx
INNGEST_SIGNING_KEY=signkey-xxxxx# Generate Prisma client
npx prisma generate
# Push schema to database
npx prisma db push
# (Optional) View data in Prisma Studio
npx prisma studionpm run devOpen http://localhost:3000 in your browser.
In a separate terminal, run the Inngest dev server:
npx inngest-cli@latest dev -u http://localhost:3000/api/inngestThis launches the Inngest UI at http://localhost:8288.
-
Database Changes
# Modify prisma/schema.prisma npx prisma db push npx prisma generate -
API Routes
- Add procedures to
src/modules/*/server/procedures.ts - Export from
src/trpc/routers/_app.ts
- Add procedures to
-
UI Components
- Create in
src/components/ - Use existing UI components from
src/components/ui/
- Create in
-
Background Jobs
- Define in
src/inngest/functions.ts - Test via Inngest dev UI
- Define in
flowchart TD
A[User Input] --> B{User Authenticated?}
B -->|No| C[Redirect to Sign In]
B -->|Yes| D[Check Usage Credits]
D --> E{Credits Available?}
E -->|No| F[Show Upgrade Message]
E -->|Yes| G[Create Project/Message]
G --> H[Trigger Inngest Job]
H --> I[Generate Code with OpenAI]
I --> J[Execute in E2B Sandbox]
J --> K[Save Results to Database]
K --> L[Update UI]
L --> M[Show Results to User]
erDiagram
Project ||--o{ Message : has
Message ||--o| Fragment : contains
User ||--o{ Project : owns
User ||--o{ Usage : tracks
Project {
string id PK
string name
string userId FK
datetime createdAt
datetime updatedAt
}
Message {
string id PK
string content
enum role
enum type
string projectId FK
datetime createdAt
datetime updatedAt
}
Fragment {
string id PK
string messageId FK
string sandboxUrl
string title
json files
datetime createdAt
datetime updatedAt
}
Usage {
string key PK
int points
datetime expire
}
# Development
npm run dev # Start development server with Turbopack
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint
# Database
npx prisma studio # Open Prisma Studio
npx prisma generate # Generate Prisma client
npx prisma db push # Push schema changes
npx prisma db pull # Pull schema from database
npx prisma migrate dev # Create and apply migration
# Deployment
vercel --prod # Deploy to Vercel- Environment Variables: Set all required environment variables in Vercel dashboard
- Database: Use a managed PostgreSQL service (Vercel Postgres, Supabase, etc.)
- Deploy:
vercel --prod
Build and run with Docker:
# Build image
docker build -t bolt:latest .
# Run container
docker run -p 3000:3000 --env-file .env bolt:latest- Authentication: Clerk-powered user authentication
- Rate Limiting: Credit-based usage tracking with
rate-limiter-flexible - Input Validation: Zod schema validation on all inputs
- Sandboxed Execution: Secure code execution in E2B containers
- Environment Isolation: Separate environments for development and production
- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Documentation: Check this README and inline code comments
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Next.js - The React framework
- tRPC - End-to-end typesafe APIs
- Prisma - Next-generation ORM
- Clerk - Authentication and user management
- Inngest - Background job processing
- E2B - Code execution environments
- OpenAI - AI-powered code generation
Before you begin, ensure you have the following installed:
- Node.js (v18 or later recommended)
- A package manager: npm, yarn, pnpm, or bun
- Access to a database (e.g., PostgreSQL, MySQL)
Follow these steps to get your development environment set up and running.
git clone https://github.com/Pruthvik-P/bolt.git
cd boltChoose the command that corresponds to your package manager:
npm install
# or
yarn install
# or
pnpm install
# or
bun install// ...existing code...
Create a .env.local file in the project root and add any required variables for your setup (database, API keys, etc.). Example:
# PowerShell (Windows)
Copy-Item .env.example .env.localUpdate .env.local with values such as:
- DATABASE_URL=...
- Any keys required by your integrations (e.g., E2B, OpenAI, etc.)
Start the Next.js dev server:
# Windows (PowerShell or CMD)
npm run dev
# or: yarn dev
# or: pnpm dev
# or: bun devOpen http://localhost:3000 in your browser.
You can start editing the page by modifying app/page.tsx. The page auto-updates as you edit the file.
You can run Inngestβs local dev server alongside the app.
-
Start the app (see step 4).
-
In a separate terminal, run the Inngest CLI pointing to your Inngest handler (Next.js default is /api/inngest):
# Use npx (recommended to get latest)
npx inngest-cli@latest dev -u http://localhost:3000/api/inngestNotes:
- If your Inngest route differs, replace /api/inngest with the correct URL.
- The CLI launches a local dev UI at http://localhost:8288.
- Send a test event (optional):
npx inngest-cli@latest event send -n app/user.created -d "{\"id\":\"123\"}"Troubleshooting:
- If port 8288 is in use, pass -p 8289 (or another port).
- Ensure the Next.js server is running before starting the CLI.
This project uses next/font to automatically optimize and load Geist, a new font family for Vercel.
To learn more about Next.js, take a look at the following resources:
- Next.js Documentation - learn about Next.js features and API.
- Learn Next.js - an interactive Next.js tutorial.
You can check out the Next.js GitHub repository - your feedback and contributions are welcome!
The easiest way to deploy your Next.js app is to use the Vercel Platform from the creators of Next.js.
Check out our Next.js deployment documentation for more details.npx