Open-source conversation management platform with advanced branching capabilities and multi-provider AI integration.
ChatRoutes lets you manage AI conversations with features like conversation branching (explore multiple discussion paths from any message), parallel responses (compare answers from different AI models side-by-side), and a full REST API for building custom integrations.
- Conversation Branching - Fork conversations at any message to explore alternative paths
- Parallel Responses - Get responses from multiple AI models simultaneously
- Multi-Provider AI - OpenAI (GPT-4o, GPT-5), Anthropic (Claude), Google (Gemini), DeepSeek
- REST API - Complete API for programmatic access
- Guest Mode - Try without creating an account
- JWT + API Key Auth - Flexible authentication options
- OAuth - GitHub and Google sign-in
- Usage Tracking - Monitor API usage per user
- Streaming - Real-time streaming responses via SSE
- Runtime: Node.js + TypeScript
- Framework: Express.js
- Database: PostgreSQL + Prisma ORM
- Cache: Redis (optional)
- Auth: JWT + bcrypt
- AI: OpenAI SDK, Anthropic SDK
- Deployment: Docker, Docker Compose
git clone https://github.com/chatroutes/chatroutes-backend.git
cd chatroutes-backend
# Set up environment
cp .env.example .env
# Edit .env with your API keys (OpenAI, Anthropic, etc.)
# Start everything
docker-compose up --buildThe API will be available at http://localhost:3000.
# Prerequisites: Node.js 18+, PostgreSQL 15+
# Install dependencies
npm run setup
# Set up environment
cp .env.example .env
# Edit .env with your database URL and API keys
# Run database migrations
cd services/api-gateway
npx prisma migrate dev
npx prisma generate
cd ../..
# Start development server
npm run devBase URL: http://localhost:3000/api/v1
# Register
curl -X POST http://localhost:3000/api/v1/auth/register \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com", "password": "yourpassword", "name": "Your Name"}'
# Login
curl -X POST http://localhost:3000/api/v1/auth/login \
-H "Content-Type: application/json" \
-d '{"email": "user@example.com", "password": "yourpassword"}'# Create a conversation
curl -X POST http://localhost:3000/api/v1/conversations \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"title": "My Conversation", "model": "gpt-4o"}'
# Send a message
curl -X POST http://localhost:3000/api/v1/conversations/:id/messages \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"content": "Hello!", "role": "user"}'# Create a branch from any message
curl -X POST http://localhost:3000/api/v1/conversations/:id/branches \
-H "Authorization: Bearer YOUR_JWT_TOKEN" \
-H "Content-Type: application/json" \
-d '{"forkPointMessageId": "MESSAGE_ID", "name": "Alternative approach"}'See documentation/api/ for the complete API reference.
Key variables (see .env.example for the full list):
| Variable | Description | Required |
|---|---|---|
DATABASE_URL |
PostgreSQL connection string | Yes |
JWT_SECRET |
Secret for JWT token signing | Yes |
OPENAI_API_KEY |
OpenAI API key | For OpenAI models |
ANTHROPIC_API_KEY |
Anthropic API key | For Claude models |
REDIS_URL |
Redis connection URL | No (optional cache) |
PORT |
Server port (default: 3000) | No |
chatroutes-backend/
├── services/
│ └── api-gateway/ # Main application
│ └── src/
│ ├── routes/ # API endpoints
│ ├── services/ # Business logic
│ ├── middleware/ # Auth, rate limiting
│ ├── config/ # Configuration
│ └── prisma/ # Database schema
├── tests/ # Test suite
├── documentation/ # API docs, architecture
├── deployment/ # Docker, infrastructure
├── docker-compose.yml # Local development stack
└── .env.example # Environment template
npm run dev # Start dev server
npm run build # Build TypeScript
npm test # Run tests
npm run lint # Lint codeSee CONTRIBUTING.md for guidelines.