Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vibe-deterministic

Code generation system with pattern learning and vector search for React components and FastAPI endpoints.

Core Features

  • DSPt (DSPy for TypeScript): Component generation with compile-time design system enforcement
  • DSPy (Design System for Python): Backend API generation with validation
  • Pattern Learning: RAG-based system using successful examples
  • Vector Search: LanceDB for semantic similarity
  • Type-Safe Design Tokens: Prevents raw Tailwind usage at compile-time
  • Hot Reloading: Frontend and backend with auto-refresh

Quick Start

Prerequisites

  • Bun >= 1.0.0
  • Python 3.12
  • Node.js >= 18 (for some tooling)

Installation

# Clone the repository
git clone <repository-url>
cd vibe-deterministic

# Install all dependencies (including workspaces)
bun install

# Install backend Python dependencies (if using virtual env)
cd packages/backend && pip install -r requirements.txt && cd ../..

Development

# Start everything with hot reload (recommended)
bun run dev              # Start all services with concurrently

# Individual services
bun run dev:frontend     # Just the Next.js frontend
bun run dev:backend      # Just the FastAPI backend  
bun run dev:ladle        # Just the component development

# Testing the learning systems
bun run test:dspt        # Test frontend vector search
bun run test:dspy        # Interactive backend generation

This will start:

DSPt: Frontend Component Generation

Generate React components that follow your design system:

// The system enforces:
// ✅ No raw Tailwind classes
// ✅ Design token usage only
// ✅ TypeScript types required
// ✅ Proper data-testid attributes

import { ComponentGenerator } from '@/lib/dspt/component-generator';

const generator = new ComponentGenerator();
const component = await generator.generateComponent({
  type: 'form',
  description: 'Multi-step wizard with validation',
  requirements: ['progress indicator', 'field validation'],
  features: ['stateful', 'accessible']
});

DSPy: Backend API Generation

Generate FastAPI endpoints with validation:

# Interactive generation
python -m app.dspy interactive

# Generate from prompt
python -m app.dspy generate "Create user registration endpoint with email verification"

The system validates:

  • ✅ Async/await patterns
  • ✅ Proper error handling
  • ✅ Pydantic models
  • ✅ Repository pattern
  • ✅ JWT authentication

Learning System

Both DSPt and DSPy use pattern learning with vector search:

  1. Few-Shot Learning: Retrieves similar successful examples
  2. Pattern Recognition: Identifies and applies common patterns
  3. Vector Similarity: LanceDB finds semantically similar code
  4. Continuous Improvement: Learns from each generation

See LEARNING_EVOLUTION.md for examples of the system improving through iterations.

Inspect Learning Data

# View frontend learning database
bun run inspect:frontend-db

# View backend learning database
bun run inspect:backend-db

Project Structure

vibe-deterministic/
├── packages/
│   ├── frontend/
│   │   ├── lib/
│   │   │   ├── design-system/     # Type-safe design tokens
│   │   │   └── dspt/              # Component generation system
│   │   ├── components/            # Generated components
│   │   └── .dspt/                # Learning database + vectors
│   ├── backend/
│   │   ├── app/
│   │   │   └── dspy/             # API generation system
│   │   └── .dspy/                # Learning database + vectors
│   ├── types/                    # Shared TypeScript types
│   └── utils/                    # Shared utilities
└── LEARNING_EVOLUTION.md         # Examples of system improvement

Available Commands

Development

  • bun run dev - Start all services with hot reload (uses concurrently)
  • bun run dev:frontend - Start just the frontend
  • bun run dev:backend - Start just the backend

Testing

  • bun run test:dspt - Test frontend vector search
  • bun run test:dspy - Interactive backend generation
  • bun run test - Run all tests

Database Inspection

  • bun run inspect:frontend-db - View frontend examples
  • bun run inspect:backend-db - View backend examples

Code Quality

  • bun run lint - Lint all code
  • bun run typecheck - Type check TypeScript

How It Works

Pattern Learning (RAG)

The system uses Retrieval-Augmented Generation:

  1. Store successful generations with ratings
  2. Extract patterns from high-rated examples
  3. Use vector similarity to find relevant context
  4. Include best examples in generation prompts

Vector Search

LanceDB provides semantic search capabilities:

  • 384-dimensional embeddings (mock implementation)
  • Similarity search for requests, components, patterns
  • Metadata filtering for success/rating criteria

Design System Enforcement

Compile-time prevention of design violations:

  • No raw className="bg-blue-500"
  • Must use DS.backgroundColor('primary', '500')
  • All tokens from centralized definition

🚀 Deployment

The system is designed for flexible deployment:

Development (Recommended)

bun run dev  # Everything runs locally with hot reload using concurrently

Production Options

  • Frontend: Vercel, Netlify, Cloudflare Pages
  • Backend: Railway, Fly.io, any Python host
  • Databases: SQLite (included) or PostgreSQL

Nix (Optional)

nix develop  # Reproducible dev environment

🎯 Philosophy

"Vibe Deterministic" means:

  • Deterministic Output: Same inputs → similar high-quality outputs
  • Vibe Preservation: Maintains your design language and coding style
  • Learning System: Gets better with use
  • Developer Experience: Hot reload everything, simple commands

📝 License

MIT License - Use freely in your projects!

About

DSPy & DSPt together. Full stack DSP!

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages