Code generation system with pattern learning and vector search for React components and FastAPI endpoints.
- 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
- Bun >= 1.0.0
- Python 3.12
- Node.js >= 18 (for some tooling)
# 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 ../..# 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 generationThis will start:
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000/docs
- Ladle (Component Dev): http://localhost:61000
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']
});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
Both DSPt and DSPy use pattern learning with vector search:
- Few-Shot Learning: Retrieves similar successful examples
- Pattern Recognition: Identifies and applies common patterns
- Vector Similarity: LanceDB finds semantically similar code
- Continuous Improvement: Learns from each generation
See LEARNING_EVOLUTION.md for examples of the system improving through iterations.
# View frontend learning database
bun run inspect:frontend-db
# View backend learning database
bun run inspect:backend-dbvibe-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
bun run dev- Start all services with hot reload (uses concurrently)bun run dev:frontend- Start just the frontendbun run dev:backend- Start just the backend
bun run test:dspt- Test frontend vector searchbun run test:dspy- Interactive backend generationbun run test- Run all tests
bun run inspect:frontend-db- View frontend examplesbun run inspect:backend-db- View backend examples
bun run lint- Lint all codebun run typecheck- Type check TypeScript
The system uses Retrieval-Augmented Generation:
- Store successful generations with ratings
- Extract patterns from high-rated examples
- Use vector similarity to find relevant context
- Include best examples in generation prompts
LanceDB provides semantic search capabilities:
- 384-dimensional embeddings (mock implementation)
- Similarity search for requests, components, patterns
- Metadata filtering for success/rating criteria
Compile-time prevention of design violations:
- No raw
className="bg-blue-500" - Must use
DS.backgroundColor('primary', '500') - All tokens from centralized definition
The system is designed for flexible deployment:
bun run dev # Everything runs locally with hot reload using concurrently- Frontend: Vercel, Netlify, Cloudflare Pages
- Backend: Railway, Fly.io, any Python host
- Databases: SQLite (included) or PostgreSQL
nix develop # Reproducible dev environment"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
MIT License - Use freely in your projects!