Skip to content

jaggernaut007/js-coding-agent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

2 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Epiminds - AI Agent Development System

A Next.js application featuring three specialized AI agents powered by GPT-4o that collaborate to build complete software features through intelligent communication.

✨ Features

  • 🎨 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

πŸ“‹ Prerequisites

  • Node.js 18 or higher
  • npm or yarn package manager
  • OpenAI API key (Get one here)

πŸš€ Getting Started

  1. Clone the repository:

    git clone https://github.com/jaggernaut007/js-coding-agent.git
    cd epiminds
  2. Install dependencies:

    npm install
  3. Configure environment variables:

    Create a .env.local file 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.local file is already in .gitignore.

  4. Run the development server:

    npm run dev
  5. Open your browser:

    Navigate to http://localhost:3000

  6. Start building:

    Type a feature request like "Create a user authentication system" and watch the agents collaborate!

πŸ—οΈ How It Works

Agent Architecture

The system uses three specialized AI agents, each powered by GPT-4o:

  1. 🎨 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
  2. βš›οΈ 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
  3. πŸ”§ 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

πŸ“¨ Message Bus Communication

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 workflow
    • design_proposal - Design sent to frontend
    • frontend_implementation - Code sent to backend
    • backend_implementation - API specs shared
    • question / answer - Inter-agent queries
    • progress_update - Status notifications
    • error - Error handling

πŸ”„ Workflow Modes

Sequential Mode (default - recommended):

  1. 🎨 UI/UX Designer analyzes requirements and creates design
  2. βš›οΈ Frontend Developer receives design and implements components
  3. πŸ”§ Backend Developer (if needed) creates APIs based on frontend needs
  4. 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

πŸ“‘ API Endpoints

/api/health

Health check endpoint for monitoring

GET /api/health

Response:

{
  "status": "ok",
  "timestamp": "2025-12-03T12:34:56.789Z",
  "uptime": 123.45,
  "environment": "development"
}

/api/agents/chat

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" }
    }
  }
}

πŸ“ Project Structure

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

πŸ’‘ Usage Examples

Example 1: Build a Todo List

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

Example 2: User Authentication

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

Example 3: Dashboard with Analytics

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

Chat Interface Features

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

πŸ› οΈ Development

Available Scripts

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

Development Features

  • πŸ”₯ 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

Key Technologies

  • 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

πŸ› Troubleshooting

"OpenAI API key not configured"

Problem: API key is missing or incorrect

Solutions:

  • Ensure .env.local file 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

Agents taking too long / Timeout errors

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

Type errors or compilation issues

Problem: TypeScript or build errors

Solutions:

  • Run npm install to ensure all packages are installed
  • Delete .next folder and rebuild: rm -rf .next && npm run dev
  • Check tsconfig.json is properly configured
  • Verify Node.js version is 18 or higher: node --version

Chat interface not responding

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

"Cannot find module" errors

Problem: Missing dependencies

Solutions:

  • Delete node_modules and reinstall: rm -rf node_modules && npm install
  • Clear npm cache: npm cache clean --force
  • Check package.json for correct dependency versions

πŸ—οΈ Architecture Highlights

Agent System Design

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

Message Bus Pattern

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

Best Practices Implemented

  • βœ… 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

πŸš€ Future Enhancements

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

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ‘¨β€πŸ’» Author

Shreyas Jagannath

πŸ™ Acknowledgments


Built with ❀️ using Next.js and GPT-4o

About

Agent to code features requests

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages