A Next.js chat application that can generate charts and UI components using both traditional API calls and AgentKit multi-agent architecture.
- Dual Architecture Support: Toggle between traditional Anthropic API calls and AgentKit multi-agent network
- Chart Generation: Create various chart types (bar, line, pie, area, radar) with real data
- UI Component Generation: Generate functional shadcn/ui components and layouts
- Real-time Switching: Switch between architectures without restarting the app
- Direct API calls to Anthropic Claude
- Single agent handles all tasks
- Simpler but less specialized
- Multi-agent network with specialized agents:
- Chart Generator Agent: Specialized in data visualization
- UI Generator Agent: Expert in shadcn/ui component creation
- Routing Agent: Intelligent routing between specialized agents
- Better task specialization and routing
- More scalable and maintainable
- Node.js 18+
- npm or pnpm
- Anthropic API key
- Install dependencies:
npm install- Set up environment variables:
# Create .env.local file
ANTHROPIC_API_KEY=your_anthropic_api_key_herenpm run devThen toggle off "AgentKit Network" in the UI.
npm run dev:agentkitThis runs both the Next.js dev server and the AgentKit server concurrently.
npm run agentkit- Open http://localhost:3000 in your browser
- Use the toggle in the header to switch between:
- Traditional API: Direct Anthropic API calls
- AgentKit Network: Multi-agent specialized routing
- Try different prompts:
- Charts: "Create a bar chart showing sales data"
- UI: "Create a contact form with validation"
- Complex: "Build a dashboard with charts and user profile cards"
-
Chart Generator Agent (
lib/agents/chart-agent.ts)- Specialized in data visualization
- Supports 15+ chart types
- Handles data formatting and configuration
-
UI Generator Agent (
lib/agents/ui-agent.ts)- Expert in shadcn/ui components
- Supports 11+ UI types (forms, cards, dashboards, etc.)
- Validates component structure
-
Routing Agent (
lib/agents/routing-agent.ts)- Analyzes user requests
- Routes to appropriate specialist agent
- Handles task completion
The assistantNetwork (lib/agents/network.ts) orchestrates all agents with:
- Shared state management
- Intelligent routing logic
- Result aggregation
/api/chat- Traditional Anthropic API/api/agentkit-chat- AgentKit multi-agent network
npm run dev- Start Next.js development servernpm run agentkit- Start AgentKit server onlynpm run dev:agentkit- Start both servers concurrentlynpm run build- Build for productionnpm run start- Start production server
ANTHROPIC_API_KEY=your_anthropic_api_key_here
AGENTKIT_PORT=3010 # Optional: AgentKit server port- Frontend: Next.js 13, React, Tailwind CSS
- UI Components: shadcn/ui, Radix UI
- Charts: Recharts
- AI: Anthropic Claude, AgentKit by Inngest
- Architecture: Multi-agent network with routing
lib/
├── agents/
│ ├── chart-agent.ts # Chart generation specialist
│ ├── ui-agent.ts # UI component specialist
│ ├── routing-agent.ts # Request routing logic
│ └── network.ts # Agent network orchestration
├── agentkit-server.ts # AgentKit HTTP server
└── inngest.ts # Inngest client configuration
app/api/
├── chat/route.ts # Traditional API endpoint
└── agentkit-chat/route.ts # AgentKit network endpoint
components/
├── Chat.tsx # Main chat interface with toggle
├── ChatContainer.tsx # Message display
├── ChatInput.tsx # Input handling
└── charts/ # Chart rendering components
scripts/
└── start-agentkit.ts # AgentKit server startup
- Fork the repository
- Create a feature branch
- Make your changes
- Test both traditional and AgentKit modes
- Submit a pull request
MIT License - see LICENSE file for details.