A real-time chatbot application using Claude AI, built with Node.js, Express, React, and Socket.io.
- Real-time streaming responses from Claude AI
- WebSocket-based communication for instant messaging
- Session management for conversation history
- Markdown support with syntax highlighting
- Dark mode support
- Responsive design with Tailwind CSS
- Node.js 18+ installed
- Anthropic API key
cd backend
npm installCreate a .env file in the backend directory:
ANTHROPIC_API_KEY=your_actual_api_key_here
PORT=3001
CLIENT_URL=http://localhost:5173
cd frontend
npm installcd backend
npm run devThe backend will run on http://localhost:3001
In a new terminal:
cd frontend
npm run devThe frontend will run on http://localhost:5173
POST /api/chat/sessions- Create a new chat sessionGET /api/chat/sessions/:id/messages- Get messages for a sessionPOST /api/chat/sessions/:id/messages- Send a message (non-streaming)DELETE /api/chat/sessions/:id/messages- Clear session messagesGET /health- Health check endpoint
join-session- Join a chat session roomsend-message- Send a message with streaming responsestream-chunk- Receive streaming text chunksmessage-complete- Receive complete message after streaming
- Node.js + TypeScript
- Express.js
- Socket.io
- Anthropic Claude SDK
- React + TypeScript
- Vite
- Tailwind CSS
- Socket.io Client
- React Markdown
chatbot/
├── backend/
│ ├── src/
│ │ ├── routes/ # API routes
│ │ ├── services/ # Business logic
│ │ ├── types/ # TypeScript types
│ │ └── index.ts # Server entry point
│ └── package.json
└── frontend/
├── src/
│ ├── components/ # React components
│ ├── services/ # API and Socket services
│ ├── types/ # TypeScript types
│ └── App.tsx # Main app component
└── package.json
MIT