Thanks to visit codestin.com
Credit goes to Github.com

Skip to content
/ Vibe Public

An AI-powered code generation and project management platform built with Next.js, Prisma, and Inngest.

Notifications You must be signed in to change notification settings

igamanraj/Vibe

Repository files navigation

Vibe

An AI-powered code generation and project management platform built with Next.js, Prisma, and Inngest.

πŸš€ Overview

Vibe is a modern web application that empowers developers to create, manage, and execute code projects with AI-assisted features. It combines real-time code execution, user authentication, and intelligent project organization into a seamless development experience.

✨ Features

  • AI-Powered Code Generation: Generate and execute code snippets with AI assistance
  • Project Management: Create and organize multiple projects with intuitive interfaces
  • Real-Time Code Execution: Execute code in isolated sandboxes using E2B Code Interpreter
  • Message-Based Architecture: Structured message system for tracking code generation and execution results
  • Code Fragments: Save and manage code fragments with sandboxes and file tracking
  • Usage Tracking: Monitor API usage with rate limiting and point-based system
  • User Authentication: Secure authentication with Clerk
  • Dark/Light Theme Support: Built-in theme switching with next-themes
  • Responsive UI: Comprehensive component library with Radix UI and custom styling

πŸ› οΈ Tech Stack

Frontend

Backend

Authentication

Development Tools

πŸ“ Project Structure

vibe/
β”œβ”€β”€ prisma/                 # Database schema and migrations
β”‚   β”œβ”€β”€ schema.prisma       # Prisma data models
β”‚   β”œβ”€β”€ seed.ts            # Database seeding script
β”‚   └── migrations/        # Migration history
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ app/               # Next.js app router
β”‚   β”‚   β”œβ”€β”€ (home)/        # Home page routes
β”‚   β”‚   β”œβ”€β”€ api/           # API routes and webhooks
β”‚   β”‚   β”œβ”€β”€ projects/      # Project-related pages
β”‚   β”‚   └── layout.tsx     # Root layout
β”‚   β”œβ”€β”€ components/        # React components
β”‚   β”‚   β”œβ”€β”€ ui/            # Reusable UI components
β”‚   β”‚   └── code-view/     # Code display component
β”‚   β”œβ”€β”€ trpc/              # tRPC setup and routers
β”‚   β”œβ”€β”€ inngest/           # Inngest functions and workflows
β”‚   β”œβ”€β”€ lib/               # Utility functions and helpers
β”‚   β”œβ”€β”€ modules/           # Feature modules (home, messages, projects, usage)
β”‚   β”œβ”€β”€ hooks/             # Custom React hooks
β”‚   β”œβ”€β”€ middleware.ts      # Next.js middleware
β”‚   β”œβ”€β”€ types.ts           # TypeScript type definitions
β”‚   └── prompt.ts          # AI prompt configurations
β”œβ”€β”€ public/                # Static assets
β”œβ”€β”€ sandbox-templates/     # E2B sandbox templates
└── package.json          # Project dependencies

πŸ“Š Database Schema

User

  • Stores user information linked to Clerk authentication
  • Relationship with posts and projects

Project

  • Represents user projects with unique IDs and timestamps
  • Contains multiple messages related to code generation
  • Tracks project metadata

Message

  • Records AI interactions (user queries and assistant responses)
  • Stores message content, role, and type
  • Links to associated fragments
  • Tracks creation and update timestamps

Fragment

  • Represents executable code fragments
  • Contains sandbox URL for code execution
  • Stores file structure in JSON format
  • References parent message

Usage

  • Tracks API/feature usage with points
  • Supports rate limiting and usage quotas
  • Includes expiration dates for time-based limits

πŸš€ Getting Started

Prerequisites

  • Node.js 18+ and npm/pnpm/yarn
  • PostgreSQL database
  • Clerk account (for authentication)
  • E2B account (for code execution)
  • Inngest account (for job processing)

Installation

  1. Clone the repository

    git clone <repository-url>
    cd vibe
  2. Install dependencies

    npm install
  3. Set up environment variables

    Create a .env.local file in the root directory:

    # Database
    DATABASE_URL=postgresql://user:password@localhost:5432/vibe
    
    # Clerk Authentication
    NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=your_clerk_key
    CLERK_SECRET_KEY=your_clerk_secret
    
    # E2B Code Interpreter
    E2B_API_KEY=your_e2b_api_key
    
    # Inngest
    INNGEST_EVENT_KEY=your_inngest_key
    INNGEST_SIGNING_KEY=your_inngest_signing_key
  4. Set up the database

    npx prisma migrate dev
    npm run seed  # Optional: populate with sample data

Development

Start the development server with Turbopack:

npm run dev

The application will be available at http://localhost:3000

Build & Production

Build for production:

npm run build

Start the production server:

npm start

Run linting:

npm run lint

πŸ”‘ Key Components

tRPC Routers

  • End-to-end typesafe API calls between frontend and backend
  • Automatic type inference for client-side queries and mutations
  • Located in src/trpc/routers/

Inngest Functions

  • Serverless event-driven workflows
  • Handle background jobs for code execution
  • Defined in src/inngest/functions.ts

Custom Hooks

  • use-current-themes: Theme management
  • use-mobile: Mobile detection
  • use-scroll: Scroll position tracking

UI Component Library

  • Accordion, Alert Dialog, Avatar, Badge
  • Button, Card, Carousel, Checkbox
  • Command, Dialog, Drawer, Dropdown Menu
  • File Explorer, Form, Input, Label
  • Pagination, Popover, Progress, Radio Group
  • Select, Sidebar, Skeleton, Slider
  • Table, Tabs, Toggle, Tooltip
  • And many more...

πŸ” Authentication & Authorization

  • Clerk Integration: Secure user authentication and session management
  • User Context: Access authenticated user information throughout the app
  • Protected Routes: API routes and pages can verify user authentication

πŸ’Ύ Database Management

Migrations

# Create a new migration after schema changes
npx prisma migrate dev --name <migration_name>

# Reset the database (development only)
npx prisma migrate reset

# Check migration status
npx prisma migrate status

Prisma Studio

View and edit database records in a visual interface:

npx prisma studio

🎨 Theming

The application supports light and dark themes using next-themes:

  • Theme preference is persisted in localStorage
  • CSS variables for consistent styling
  • Component-level theme awareness

πŸ“Š Monitoring & Usage Tracking

  • Usage Model: Track feature usage with points-based system
  • Rate Limiting: Prevent abuse with flexible rate limiting
  • Expiration: Support time-based usage limits

πŸ”„ API Integration

tRPC Client Setup

import { trpc } from '@/trpc/client'

// Use queries
const { data } = trpc.router.query.useQuery()

// Use mutations
const mutation = trpc.router.mutation.useMutation()

πŸš€ Deployment

The project is optimized for deployment on:

  • Vercel (recommended for Next.js)
  • Other Node.js hosting platforms
  • Containerized deployments (Docker support available)

Pre-deployment Checklist

  • Environment variables configured
  • Database migrations applied
  • Clerk and E2B credentials set up
  • Inngest webhook configured
  • Build passes without errors

πŸ› Troubleshooting

Database Connection Issues

  • Verify DATABASE_URL is correct
  • Ensure PostgreSQL service is running
  • Check network connectivity

Authentication Issues

  • Verify Clerk keys are correctly set
  • Check CORS configuration
  • Review Clerk dashboard for errors

Code Execution Issues

  • Verify E2B API key is valid
  • Check sandbox template configuration
  • Monitor Inngest jobs for failures

πŸ“š Additional Resources

πŸ“ License

This project is proprietary. All rights reserved.

🀝 Contributing

Contributions are welcome! Please follow the established code style and submit pull requests for review.


DEMO

See demo preview below Vibe Demo


Feel free to reach out for any questions or support regarding the Vibe platform!

About

An AI-powered code generation and project management platform built with Next.js, Prisma, and Inngest.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages