A Next.js application featuring three specialized AI agents powered by GPT-4o that collaborate to build complete software features through intelligent communication.
- π¨ UI/UX Designer Agent: Analyzes requirements and creates comprehensive design proposals with user experience patterns, wireframes, and visual specifications
- βοΈ Frontend Developer Agent: Implements production-ready React/Next.js 16 components with TypeScript, state management, and responsive styling
- π§ Backend Developer Agent: Builds secure API endpoints, database schemas, and server-side logic
- π¨ Message Bus: Pub/sub communication system enabling seamless agent-to-agent collaboration
- π¬ Interactive Chat Interface: Beautiful chatbot UI with expandable code sections and full agent output display
- π Multiple Workflow Modes: Sequential (coordinated) or parallel (fast) execution
- Node.js 18 or higher
- npm or yarn package manager
- OpenAI API key (Get one here)
-
Clone the repository:
git clone https://github.com/jaggernaut007/js-coding-agent.git cd epiminds -
Install dependencies:
npm install
-
Configure environment variables:
Create a
.env.localfile in the root directory:OPENAI_API_KEY=sk-your-actual-openai-api-key-here
Important: Never commit your API key to version control. The
.env.localfile is already in.gitignore. -
Run the development server:
npm run dev
-
Open your browser:
Navigate to http://localhost:3000
-
Start building:
Type a feature request like "Create a user authentication system" and watch the agents collaborate!
The system uses three specialized AI agents, each powered by GPT-4o:
-
π¨ UI/UX Designer Agent (
UIUXDesignerAgent.ts)- Analyzes user requirements and personas
- Creates comprehensive design proposals with wireframes
- Defines visual design specifications (colors, typography, spacing)
- Ensures WCAG accessibility compliance
- Considers responsive design for all screen sizes
- Provides detailed component specifications
-
βοΈ Frontend Developer Agent (
FrontendDeveloperAgent.ts)- Receives design proposals from UI/UX Designer
- Implements production-ready React/Next.js 16 components
- Ensures full TypeScript type safety
- Handles state management and client-side logic
- Implements responsive layouts and styling
- Requests backend APIs when needed
- Optimizes for performance and accessibility
-
π§ Backend Developer Agent (
BackendDeveloperAgent.ts)- Designs RESTful API endpoints and data models
- Implements Next.js 16 API routes with proper validation
- Creates database schemas (when needed)
- Handles authentication and authorization
- Implements security best practices (OWASP)
- Provides API documentation and integration specs
- Optimizes database queries and performance
The MessageBus class enables sophisticated pub/sub communication:
- Subscription Model: Agents subscribe to receive messages
- Direct & Broadcast: Messages can target specific agents or broadcast to all
- Message History: Full communication log for debugging and tracking
- Type-Safe Messages: Strongly typed message structure with TypeScript
- Message Types:
task_started- Initiates workflowdesign_proposal- Design sent to frontendfrontend_implementation- Code sent to backendbackend_implementation- API specs sharedquestion/answer- Inter-agent queriesprogress_update- Status notificationserror- Error handling
Sequential Mode (default - recommended):
- π¨ UI/UX Designer analyzes requirements and creates design
- βοΈ Frontend Developer receives design and implements components
- π§ Backend Developer (if needed) creates APIs based on frontend needs
- Agents collaborate through questions and feedback
Parallel Mode (experimental):
- All three agents work simultaneously on the same request
- Faster execution but less coordination
- Best for independent, non-overlapping tasks
Health check endpoint for monitoring
GET /api/health
Response:
{
"status": "ok",
"timestamp": "2025-12-03T12:34:56.789Z",
"uptime": 123.45,
"environment": "development"
}Main endpoint for agent interaction
POST /api/agents/chat
Request:
{
"message": "Build a user profile page with avatar upload",
"mode": "sequential" // or "parallel"
}Response:
{
"success": true,
"data": {
"design": "Full UI/UX design proposal...",
"frontend": "Complete React component code...",
"backend": "API routes and database schema...",
"messages": [
{
"from": "UIUXDesigner",
"to": "FrontendDeveloper",
"type": "design_proposal",
"timestamp": "2025-12-03T12:34:56.789Z"
}
]
}
}GET /api/agents/chat
Returns current status of all agents
Response:
{
"status": "ok",
"agents": {
"initialized": true,
"agents": {
"uiux": { "name": "UIUXDesigner", "role": "UI/UX Designer" },
"frontend": { "name": "FrontendDeveloper", "role": "Frontend Developer" },
"backend": { "name": "BackendDeveloper", "role": "Backend Developer" }
}
}
}epiminds/
βββ app/
β βββ api/
β β βββ agents/
β β β βββ chat/
β β β βββ route.ts # Main agent API endpoint
β β βββ health/
β β βββ route.ts # Health check endpoint
β βββ components/
β β βββ ChatBot.tsx # Interactive chat interface with expandable outputs
β βββ layout.tsx # Root layout with metadata
β βββ page.tsx # Home page
β βββ globals.css # Global styles and animations
βββ lib/
β βββ agents/
β βββ Agent.ts # Base agent class with LLM integration
β βββ MessageBus.ts # Pub/sub communication system
β βββ UIUXDesignerAgent.ts # UI/UX Designer implementation
β βββ FrontendDeveloperAgent.ts # Frontend Developer implementation
β βββ BackendDeveloperAgent.ts # Backend Developer implementation
β βββ AgentOrchestrator.ts # Coordinates agent workflows
βββ .env.local # Environment variables (not in git)
βββ .gitignore # Git ignore rules
βββ package.json # Dependencies and scripts
βββ tsconfig.json # TypeScript configuration
βββ next.config.js # Next.js configuration
βββ README.md # This file
Input:
Create a todo list with add, delete, and mark complete features
Output:
- π¨ Design: Component layout, color scheme, interaction patterns
- βοΈ Frontend: Complete React component with state management
- π§ Backend: API endpoints for CRUD operations
Input:
Build a user authentication system with email/password login
Output:
- π¨ Design: Login/signup forms, error states, responsive design
- βοΈ Frontend: Form validation, authentication flow, protected routes
- π§ Backend: JWT authentication, password hashing, session management
Input:
Create an admin dashboard with user statistics and charts
Output:
- π¨ Design: Dashboard layout, chart specifications, data visualization
- βοΈ Frontend: Chart components, data fetching, responsive grid
- π§ Backend: Analytics API, data aggregation, database queries
The chatbot UI provides:
- Expandable Sections: Click βΆ to expand each agent's output
- Code Display: Syntax-highlighted code blocks with dark theme
- Full Output: No truncation - see complete designs and code
- Message History: Track agent-to-agent communication
- Scrollable Content: Long outputs are scrollable within sections
npm run dev # Start development server (hot reload enabled)
npm run build # Build for production
npm run start # Start production server
npm run lint # Run ESLint for code quality- π₯ Hot Reload: Changes reflected immediately without restart
- π TypeScript: Full type safety across the entire codebase
- β ESLint: Automated code quality and style checks
- π Message History: All agent communications logged in browser console
- π Error Handling: Comprehensive error messages and recovery
- β‘ Fast Refresh: React Fast Refresh for instant UI updates
- Framework: Next.js 16 with App Router
- Language: TypeScript 5.3+
- AI/LLM: OpenAI GPT-4o via Vercel AI SDK
- Styling: CSS-in-JS with inline styles
- Architecture: Agent-based with message bus pattern
Problem: API key is missing or incorrect
Solutions:
- Ensure
.env.localfile exists in the project root - Verify
OPENAI_API_KEY=sk-...is correctly set - Restart the development server after adding the key
- Check that the key starts with
sk-and is valid on OpenAI platform
Problem: Agents exceed 15-second timeout
Solutions:
- Check your OpenAI API rate limits and usage quota
- Simplify your request to reduce processing time
- Adjust timeout in
AgentOrchestrator.ts(line ~120):await this.waitForCompletion(30000) // Increase to 30 seconds
- Try parallel mode for faster (but less coordinated) execution
Problem: TypeScript or build errors
Solutions:
- Run
npm installto ensure all packages are installed - Delete
.nextfolder and rebuild:rm -rf .next && npm run dev - Check
tsconfig.jsonis properly configured - Verify Node.js version is 18 or higher:
node --version
Problem: Messages sent but no response
Solutions:
- Check browser console for JavaScript errors
- Verify OpenAI API key is valid and has credits
- Check network tab in DevTools for failed API requests
- Restart the development server
Problem: Missing dependencies
Solutions:
- Delete
node_modulesand reinstall:rm -rf node_modules && npm install - Clear npm cache:
npm cache clean --force - Check
package.jsonfor correct dependency versions
Each agent is:
- Autonomous: Makes independent decisions based on its expertise
- Collaborative: Communicates with other agents via message bus
- Stateful: Maintains conversation history and scratchpad data
- Type-Safe: Fully typed with TypeScript interfaces
The pub/sub architecture enables:
- Decoupling: Agents don't directly depend on each other
- Scalability: Easy to add new agents to the system
- Traceability: Full message history for debugging
- Flexibility: Direct messages or broadcasts
- β Separation of concerns (each agent has clear responsibilities)
- β Clean architecture with distinct layers
- β Type safety throughout the codebase
- β Error handling and recovery mechanisms
- β Extensible design for future enhancements
- β Comprehensive system prompts for agent behavior
Potential improvements and features:
- Streaming Responses: Real-time streaming of agent outputs
- Agent Memory: Persistent storage for learned patterns
- Code Execution: Run generated code in sandboxed environment
- File Generation: Automatically create files from agent outputs
- Multi-Model Support: Allow different LLMs per agent
- Agent Feedback Loop: Agents review and improve each other's work
- Custom Agents: User-defined specialized agents
- Project Templates: Pre-built templates for common use cases
- Version Control: Track iterations and changes
- Collaborative Editing: Real-time multi-user collaboration
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Shreyas Jagannath
- GitHub: @jaggernaut007
- Repository: js-coding-agent
- Next.js - The React framework
- Vercel AI SDK - AI/LLM integration
- OpenAI - GPT-4o language model
- TypeScript - Type safety
Built with β€οΈ using Next.js and GPT-4o