Production Ready: AI-powered React component builder using Anthropic Claude Sonnet 4 in a hierarchical multi-agent system
Build production-ready React components using AI-powered agents with Claude Sonnet 4
Features · Deploy Your Own · Setup · Getting Started · Architecture
Deploy your own instance of AINative Component Builder to any hosting platform that supports Next.js applications.
- Hierarchical Multi-Agent Architecture: 4-tier agent system (Orchestrator + 3 specialized subagents)
- Design Subagent: Analyzes requirements and creates design specifications
- Code Subagent: Generates React components from design specs
- Validation Subagent: Tests and validates generated code
- Anthropic Claude Sonnet 4: Primary model (claude-sonnet-4-20250514) with extended thinking
- Extended Thinking: 2000-token thinking budget for improved quality and reasoning
- Template System: 35 predefined templates with semantic matching
- Custom Prompt Support: Full support for custom component generation from natural language
- Memory System: Anthropic Memory API for cross-conversation context persistence
- Real-time Preview: Split-screen interface with chat and live preview panels
- Streaming Support: Real-time AI response streaming with visual feedback
- Image Integration: Unsplash API integration for component imagery
- Conversation History: Maintains chat history throughout the session
- Suggestion System: Helpful prompts to guide users
- Anonymous Access: Create chats without registration (with rate limits)
- Guest Access: Temporary accounts for persistent sessions
- User Registration/Login: Email/password authentication with secure password hashing
- Session Management: Secure session handling with NextAuth.js
- Multi-Tenant Architecture: Multiple users with isolated data
- Ownership Mapping: Users only see their own chats and projects
- Rate Limiting: Different limits for anonymous, guest, and registered users
- Node.js 18+ and pnpm
- PostgreSQL database
- Anthropic API key (Get one here)
Create a .env file with all required variables:
# Auth Secret - Generate a random string for production
# Generate with: openssl rand -base64 32
AUTH_SECRET=your-auth-secret-here
# Database URL - PostgreSQL connection string
DATABASE_URL=postgresql://user:password@localhost:5432/ainative_db
POSTGRES_URL=postgresql://user:password@localhost:5432/ainative_db
# Anthropic API Key - Get from https://console.anthropic.com/
ANTHROPIC_API_KEY=your-anthropic-api-key-here
# Anthropic Model Configuration
ANTHROPIC_MODEL=claude-sonnet-4-20250514
# OpenAI API Key (for embeddings and utilities only)
OPENAI_API_KEY=your-openai-api-key-here
# Unsplash API Key (for image integration)
UNSPLASH_ACCESS_KEY=your-unsplash-access-key
# Subagents Configuration
USE_SUBAGENTS=true # Enable hierarchical multi-agent systemThis project uses PostgreSQL with Drizzle ORM. Set up your database:
-
Generate Database Schema:
pnpm db:generate
-
Run Database Migrations:
pnpm db:migrate
-
Optional - Open Database Studio:
pnpm db:studio
-
Install Dependencies:
pnpm install
-
Set Up Environment:
- Copy
.env.exampleto.env - Add your Anthropic API key
- Configure database connection
- Copy
-
Run Database Migrations:
pnpm db:migrate
-
Start Development Server:
pnpm dev
-
Open Application: Open http://localhost:3000 to start building components
┌─────────────────────────────────────┐
│ Orchestrator Agent (Cody) │
│ - Team leader │
│ - Coordinates workflow │
│ - 30 years of experience │
└────────────┬────────────────────────┘
│
┌───────┴────────┬──────────────┐
│ │ │
┌────▼────┐ ┌────▼─────┐ ┌───▼──────┐
│ Design │ │ Code │ │Validation│
│Subagent │────▶│ Subagent │───▶│ Subagent │
└─────────┘ └──────────┘ └──────────┘
Workflow:
- User enters prompt → Orchestrator analyzes request
- Design Subagent creates component specification
- Code Subagent generates React component code
- Validation Subagent tests and validates output
- Result streamed back to user in real-time
Frontend:
- Next.js 15 with App Router
- React 19
- Tailwind CSS
- Shadcn/ui Components
- Monaco Editor for code display
- Real-time preview rendering
Backend:
- Next.js API Routes
- Anthropic Claude Sonnet 4 API
- OpenAI API (embeddings only)
- WebSocket for real-time streaming
- Drizzle ORM + PostgreSQL
- NextAuth.js for authentication
AI Integration:
- Anthropic SDK for Claude integration
- Tool Use API for structured output
- Anthropic Memory API for context
- Extended thinking for quality
- Prompt caching (90% cost reduction)
- Users: User accounts with authentication
- ProjectOwnership: Maps projects to users
- ChatOwnership: Maps chats to users
- AnonymousChatLog: Rate limiting for anonymous users
app/page.tsx- Main UI with chat and previewapp/api/chat-ws/route.ts- WebSocket endpoint for streaminglib/agent/subagents.ts- Multi-agent orchestrationlib/agent/orchestrator.ts- Main orchestrator logiccomponents/ai-elements/- AI UI componentscomponents/shared/- Shared UI components
pnpm db:generate- Generate migration files from schema changespnpm db:migrate- Apply pending migrationspnpm db:studio- Open Drizzle Studio for database inspectionpnpm db:push- Push schema changes directly (development only)
# Run all tests
pnpm test
# Run tests in watch mode
pnpm test:watch
# Run tests with coverage
pnpm test:coverage
# Run specific test suites
pnpm test:unit
pnpm test:integration- Password hashing with bcrypt-ts
- Secure session cookies with NextAuth.js
- CSRF protection
- SQL injection protection via Drizzle ORM
- User data isolation through ownership mapping
- Rate limiting for anonymous access
- Anonymous Users: No account, 3 chats/day, no persistence
- Guest Users: Auto-created accounts, 5 chats/day, session persistence
- Registered Users: Permanent accounts, 50 chats/day, full features
Rate limits reset every 24 hours.
- claude-sonnet-4-20250514: Used for all component generation
- Extended thinking enabled (2000 tokens)
- Prompt caching for cost optimization
- OpenAI text-embedding-ada-002: Template similarity matching
- OpenAI GPT-4: Translation and utility functions (if configured)
The system uses agent profiles from ~/.claude/agents/:
cody-team-leader.md- Orchestrator configurationai-product-architect.md- Design subagentfrontend-ui-builder.md- Code subagentqa-bug-hunter.md- Validation subagent
Contributions are welcome! Please see the issues in the repository for tasks that need work.
MIT License - see LICENSE file for details
Built with AI by AINative Studio
Powered by Anthropic Claude Sonnet 4 and Next.js
