Developer Guide
Developer Guide
Section titled “Developer Guide”This comprehensive guide covers everything you need to know to develop, extend, and contribute to VibeCode.
Architecture Overview
Section titled “Architecture Overview”VibeCode is built as a modern, cloud-native application with the following architecture:
Frontend Stack
Section titled “Frontend Stack”- Next.js 15 - React framework with App Router
- React 19 - Modern React with concurrent features
- TypeScript - Full type safety and developer experience
- Tailwind CSS - Utility-first CSS framework
- Shadcn/UI - Beautiful, accessible UI components
Backend Stack
Section titled “Backend Stack”- Next.js API Routes - Serverless API endpoints
- PostgreSQL 16+ - Primary database with pgvector for AI embeddings
- Redis/Valkey - Caching and session storage
- Prisma - Type-safe database ORM
AI Integration
Section titled “AI Integration”- OpenAI - GPT-4, GPT-3.5, and embedding models
- Anthropic Claude - Advanced reasoning and code generation
- Google AI - Gemini models for diverse tasks
- LiteLLM - Unified interface for multiple AI providers
Monitoring & Observability
Section titled “Monitoring & Observability”- OpenTelemetry - Distributed tracing
- Datadog - Metrics, logs, and APM
- Custom metrics - Application-specific monitoring
Deployment
Section titled “Deployment”- Docker - Containerization for all components
- Kubernetes - Orchestration and scaling
- Helm - Package management and deployment
Development Setup
Section titled “Development Setup”Prerequisites
Section titled “Prerequisites”- Node.js ≥18.18.0 (recommend 25.x)
- PostgreSQL 16+ with pgvector
- Redis 6+
- Docker and Docker Compose
- Git
Environment Setup
Section titled “Environment Setup”-
Clone and install
Terminal window git clone https://github.com/ryanmaclean/vibecode-webgui.gitcd vibecode-webguinpm install --legacy-peer-deps -
Environment configuration
Terminal window cp .env.example .env.localConfigure your
.env.local:Terminal window # DatabaseDATABASE_URL="postgresql://vibecode:password@localhost:5432/vibecode_dev"# RedisREDIS_URL="redis://localhost:6379"# AuthenticationNEXTAUTH_SECRET="development-secret-min-32-characters"NEXTAUTH_URL="http://localhost:3000"# AI ProvidersOPENAI_API_KEY="your-openai-key"ANTHROPIC_API_KEY="your-anthropic-key"GOOGLE_AI_API_KEY="your-google-key"# Monitoring (optional for development)DD_API_KEY="your-datadog-key"OTEL_ENABLED="false" -
Database setup
Terminal window # Start PostgreSQL and Redisdocker-compose -f docker-compose.dev.yml up -d postgres redis# Run database migrationsnpm run db:migratenpm run db:generate -
Development server
Terminal window npm run dev
Project Structure
Section titled “Project Structure”vibecode-webgui/├── src/│ ├── app/ # Next.js App Router│ │ ├── api/ # API routes│ │ ├── (dashboard)/ # Dashboard pages│ │ └── globals.css # Global styles│ ├── components/ # React components│ │ ├── ui/ # Base UI components│ │ ├── ai/ # AI-related components│ │ ├── chat/ # Chat interface│ │ └── ... # Feature-specific components│ ├── lib/ # Utility libraries│ │ ├── ai/ # AI service integrations│ │ ├── cache/ # Caching strategies│ │ ├── monitoring/ # Observability│ │ └── utils.ts # Common utilities│ ├── hooks/ # Custom React hooks│ └── types/ # TypeScript definitions├── prisma/ # Database schema and migrations├── docs/ # Documentation (Astro + Starlight)├── k8s/ # Kubernetes manifests├── charts/ # Helm charts├── scripts/ # Build and utility scripts└── tests/ # Test suites ├── unit/ # Unit tests ├── integration/ # Integration tests └── e2e/ # End-to-end testsDevelopment Workflow
Section titled “Development Workflow”1. Creating Features
Section titled “1. Creating Features”When adding new features:
-
Create a feature branch
Terminal window git checkout -b feature/your-feature-name -
Follow the component structure
- Place components in appropriate directories
- Use TypeScript for all new code
- Follow existing naming conventions
-
Add tests
- Unit tests for business logic
- Integration tests for API endpoints
- E2E tests for user workflows
-
Update documentation
- Add JSDoc comments to functions
- Update API documentation if needed
- Add usage examples
2. Code Style and Quality
Section titled “2. Code Style and Quality”We maintain high code quality through:
- ESLint - Code linting and style enforcement
- Prettier - Consistent code formatting
- TypeScript - Type safety and better IDE support
- Husky - Pre-commit hooks for quality gates
# Run lintingnpm run lint
# Fix auto-fixable issuesnpm run lint:fix
# Type checkingnpm run type-check
# Format codenpm run format3. Testing Strategy
Section titled “3. Testing Strategy”Unit Tests
Section titled “Unit Tests”# Run unit testsnpm run test
# Watch modenpm run test:watch
# Coverage reportnpm run test:coverageIntegration Tests
Section titled “Integration Tests”# Run integration testsnpm run test:integration
# With real servicesENABLE_REAL_TESTS=true npm run test:integrationE2E Tests
Section titled “E2E Tests”# Run E2E testsnpm run test:e2e
# In headed mode (with browser UI)npm run test:e2e:headedAPI Development
Section titled “API Development”Creating API Endpoints
Section titled “Creating API Endpoints”API endpoints are created in src/app/api/:
import { NextRequest, NextResponse } from 'next/server';import { z } from 'zod';
const requestSchema = z.object({ name: z.string().min(1), email: z.string().email(),});
export async function POST(request: NextRequest) { try { const body = await request.json(); const { name, email } = requestSchema.parse(body);
// Your business logic here const result = await createUser({ name, email });
return NextResponse.json({ success: true, data: result }); } catch (error) { return NextResponse.json({ success: false, error: error.message }, { status: 400 }); }}API Documentation
Section titled “API Documentation”API documentation is automatically generated from your code. Use JSDoc comments:
/** * Creates a new user account * @param request - HTTP request with user data * @returns User creation response */export async function POST(request: NextRequest) { // Implementation}AI Integration
Section titled “AI Integration”Adding New AI Providers
Section titled “Adding New AI Providers”-
Create provider client
src/lib/ai/providers/your-provider.ts export class YourProviderClient {async generateText(prompt: string): Promise<string> {// Implementation}} -
Register in AI orchestrator
src/lib/ai/orchestrator.ts import { YourProviderClient } from './providers/your-provider';// Add to provider registry -
Add configuration
Terminal window YOUR_PROVIDER_API_KEY="your-key-here"
AI Prompt Engineering
Section titled “AI Prompt Engineering”Store prompts in src/lib/ai/prompts/:
export const PROJECT_GENERATION_PROMPT = `You are an expert software architect. Generate a project structure based on:
Requirements: {requirements}Technology Stack: {stack}Complexity Level: {complexity}
Provide a complete file structure with:1. Core application files2. Configuration files3. Documentation4. Tests`;Database Development
Section titled “Database Development”Schema Changes
Section titled “Schema Changes”-
Update Prisma schema
prisma/schema.prisma model User {id String @id @default(cuid())email String @uniquename String?createdAt DateTime @default(now())} -
Generate migration
Terminal window npx prisma migrate dev --name add-user-table -
Update TypeScript types
Terminal window npx prisma generate
Vector Database Operations
Section titled “Vector Database Operations”For AI embeddings and semantic search:
import { vectorDatabase } from '@/lib/vector-database';
// Store embeddingsawait vectorDatabase.store({ id: 'doc-1', content: 'Document content', embedding: embeddings, metadata: { type: 'documentation' }});
// Search similar contentconst results = await vectorDatabase.search(queryEmbedding, { limit: 5, threshold: 0.8});Monitoring and Observability
Section titled “Monitoring and Observability”Adding Metrics
Section titled “Adding Metrics”import { metrics } from '@/lib/monitoring';
// Countermetrics.increment('api.requests', 1, { endpoint: '/api/example', method: 'POST'});
// Gaugemetrics.gauge('active.connections', connectionCount);
// Histogrammetrics.histogram('request.duration', duration, { endpoint: '/api/example'});Adding Traces
Section titled “Adding Traces”import { trace } from '@opentelemetry/api';
const tracer = trace.getTracer('vibecode-api');
export async function processRequest() { return tracer.startActiveSpan('process-request', async (span) => { try { // Your code here span.setStatus({ code: SpanStatusCode.OK }); return result; } catch (error) { span.recordException(error); span.setStatus({ code: SpanStatusCode.ERROR }); throw error; } finally { span.end(); } });}Deployment
Section titled “Deployment”Local Development Deployment
Section titled “Local Development Deployment”# Full stack with Dockerdocker-compose -f docker-compose.dev.yml up
# Production-like environmentdocker-compose -f docker-compose.prod.yml upKubernetes Deployment
Section titled “Kubernetes Deployment”# Apply manifestskubectl apply -f k8s/
# Using Helmhelm install vibecode ./charts/vibecode-platformEnvironment-Specific Configuration
Section titled “Environment-Specific Configuration”- Development:
docker-compose.dev.yml - Staging:
k8s/staging/ - Production:
k8s/production/
Contributing
Section titled “Contributing”Pull Request Process
Section titled “Pull Request Process”- Fork the repository
- Create a feature branch
- Make your changes
- Add tests
- Update documentation
- Submit pull request
Code Review Guidelines
Section titled “Code Review Guidelines”- Functionality: Does the code work as intended?
- Tests: Are there adequate tests?
- Performance: Any performance implications?
- Security: Are there security considerations?
- Documentation: Is documentation updated?
Commit Message Format
Section titled “Commit Message Format”type(scope): description
feat(api): add user authentication endpointfix(ui): resolve button styling issuedocs(readme): update installation instructionstest(auth): add unit tests for login flowPerformance Optimization
Section titled “Performance Optimization”Frontend Performance
Section titled “Frontend Performance”- Code Splitting: Use dynamic imports
- Image Optimization: Next.js Image component
- Bundle Analysis:
npm run build:analyze
Backend Performance
Section titled “Backend Performance”- Database Queries: Use Prisma query optimization
- Caching: Implement Redis caching
- Connection Pooling: Configure connection limits
AI Performance
Section titled “AI Performance”- Model Selection: Choose appropriate models
- Prompt Optimization: Minimize token usage
- Response Caching: Cache common responses
Troubleshooting
Section titled “Troubleshooting”Common Development Issues
Section titled “Common Development Issues”TypeScript errors
- Run
npm run type-checkto see all errors - Ensure all dependencies are properly typed
- Check tsconfig.json configuration
Database connection issues
- Verify DATABASE_URL is correct
- Ensure PostgreSQL is running
- Check database permissions
AI integration problems
- Verify API keys are valid
- Check rate limits and quotas
- Review error logs for specific issues
Debug Mode
Section titled “Debug Mode”Enable debug logging:
DEBUG=vibecode:*LOG_LEVEL=debugResources
Section titled “Resources”This guide covers the essentials of VibeCode development. For specific questions, check the codebase or create an issue on GitHub.