How aestheticsuraj234/vibecode-playground works
Project Type and Purpose
• This is a full-stack, AI-powered web IDE built with Next.js (App Router), running entirely in the browser.
• Purpose: Provide an in-browser code editor (Monaco), interactive terminal (xterm.js + WebContainers), AI chat/code suggestions (Ollama LLM), project templates, OAuth-backed authentication, and persistent state via MongoDB.
File Structure
• Top-level “app/” directory: Next.js App Router pages & API routes.
• app/layout.tsx, app/globals.css: global UI layout and styling.
• app/api/auth, chat, code-suggestion, template: backend API endpoints.
• app/(auth), app/(root), app/dashboard, app/playground: dynamic page segments and layouts.
• “components/” and “features/”: reusable UI building blocks (ShadCN UI + Tailwind) and feature-scoped modules (auth, ai-chat, dashboard, playground, webcontainers).
• “lib/” and “hooks/”: shared utilities (DB access via Prisma, syntax highlighting, template logic) and React hooks.
• “prisma/schema.prisma”: data model (MongoDB).
• Config files: next.config.ts, auth.config.ts, middleware.ts, vercel.json.
• External integrations: WebContainers service (in-browser Node.js), Ollama LLM (Docker), NextAuth (OAuth), MongoDB.
README for Additional Insights
• Tech stack: Next.js 15 App Router, TypeScript, TailwindCSS, ShadCN UI, NextAuth (Google/GitHub), Monaco Editor, Ollama, WebContainers, xterm.js, MongoDB.
• Features: OAuth login, project templates, custom file explorer, AI suggestions, embedded terminal, AI chat assistant.
Main Components
a. Frontend (Browser)
• Next.js React UI: pages, layouts, feature components.
• Monaco Editor component.
• Custom File Explorer UI.
• Terminal UI (xterm.js + WebContainers).
• AI Chat panel.
b. Backend (Next.js Server / Edge)
• API Routes: /api/auth (NextAuth), /api/chat, /api/code-suggestion, /api/template.
• Data layer: Prisma client → MongoDB.
c. In-Browser Runtime
• WebContainers service: spawns Node.js containers for live code execution.
d. External Services
• OAuth Providers (Google, GitHub).
• Ollama LLM (running locally via Docker).
• MongoDB Atlas (or self-hosted).
e. Infrastructure / Deployment
• Vercel (or custom hosting), environment variables, build pipeline.
Relationships and Interactions
• User in Browser → Next.js React UI → API Routes for data, authentication, AI suggestions.
• Next.js API → Prisma → MongoDB.
• Next.js API → Ollama LLM service for code suggestions & AI chat.
• Browser UI ↔ WebContainers: live code execution and embedded terminal I/O.
• OAuth “Sign in” flow: Browser → NextAuth API → OAuth Provider → NextAuth callback → session cookie.
• Template retrieval: Browser → /api/template → file templates served.
Architectural Patterns and Design Principles
• Layered architecture: UI layer, application/API layer, data layer.
• Feature-based module organization (under “features/”).
• Next.js App Router for co-located pages, layouts, API.
• Component reusability: ShadCN UI primitives + custom feature components.
• In-browser microservice (WebContainers) for sandboxed execution.
Final Checklist
• All main components present.
• Authentication flow to OAuth providers.
• In-browser runtime highlighted as distinct microservice.
• Technology labels (Next.js, TypeScript, Prisma, MongoDB, Ollama, WebContainers, xterm.js).
• Logical grouping of feature modules under broader services.