A full-stack multi-user AI chat application that allows users to interact with multiple AI models (OpenAI, Anthropic, Google Gemini) through a unified interface. Built with React, Node.js/Express, PostgreSQL, and Docker.
- Multi-AI Model Support: Chat with GPT-3.5, GPT-4, Claude 3, Claude 3.5, Gemini Pro, and more
- User Authentication: JWT-based authentication with admin and user roles
- Chat Management: Create, manage, and delete chat conversations
- File Upload: Upload and share images and documents in chats
- Real-time Chat Interface: Modern, responsive chat UI
- Admin Panel: Admins can create new users
- Docker Support: Complete containerized setup
- API Key Management: Secure environment-based API key configuration
ai-chat-proxy/
โโโ backend/ # Node.js/Express API
โ โโโ src/
โ โ โโโ controllers/ # Request handlers
โ โ โโโ models/ # Database models (Sequelize)
โ โ โโโ routes/ # API routes
โ โ โโโ middleware/ # Auth, upload, etc.
โ โ โโโ services/ # AI service integrations
โ โ โโโ config/ # Database configuration
โ โโโ uploads/ # File storage
โโโ frontend/ # React/Vite application
โ โโโ src/
โ โ โโโ components/ # React components
โ โ โโโ pages/ # Page components
โ โ โโโ services/ # API client
โ โ โโโ context/ # React context
โโโ docker-compose.yml # Container orchestration
- Docker and Docker Compose
- Node.js 18+ (for local development)
- PostgreSQL (if running locally)
git clone <repository-url>
cd ai-chat-proxy
cp .env.example .envEdit .env file with your settings:
# Database Configuration
DATABASE_URL=postgresql://postgres:postgres123@localhost:5432/chatproxy
# JWT Configuration
JWT_SECRET=your-super-secret-jwt-key-change-this-in-production
JWT_REFRESH_SECRET=your-super-secret-refresh-key-change-this-in-production
# Admin User (for seeding)
ADMIN_EMAIL=admin@chatproxy.com
ADMIN_PASSWORD=admin123
# AI API Keys (Add your own API keys)
OPENAI_API_KEY=your-openai-api-key-here
ANTHROPIC_API_KEY=your-anthropic-api-key-here
GOOGLE_GEMINI_API_KEY=your-google-gemini-api-key-here
# Server Configuration
PORT=8000
FRONTEND_URL=http://localhost:3000# Build and start all services
docker-compose up --build
# Or run in background
docker-compose up -d --build# Seed the database with admin user
docker-compose exec backend npm run seed- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- Health Check: http://localhost:8000/api/health
Default Admin Login:
- Email:
admin@chatproxy.com - Password:
admin123
cd backend
npm install
npm run devcd frontend
npm install
npm run dev# Install PostgreSQL and create database
createdb chatproxy
# Run migrations and seed
cd backend
npm run seed# Login
POST /api/auth/login
{
"email": "user@example.com",
"password": "password"
}
# Get Profile
GET /api/auth/profile
Authorization: Bearer <token>
# Create User (Admin only)
POST /api/auth/users
Authorization: Bearer <admin-token>
{
"email": "newuser@example.com",
"password": "password"
}# Get all chats
GET /api/chats
Authorization: Bearer <token>
# Create new chat
POST /api/chats
Authorization: Bearer <token>
{
"model_used": "gpt-4",
"title": "My Chat"
}
# Get specific chat
GET /api/chats/:chatId
Authorization: Bearer <token>
# Delete chat
DELETE /api/chats/:chatId
Authorization: Bearer <token># Get available models
GET /api/ai/models
Authorization: Bearer <token>
# Send message to AI
POST /api/ai/chat
Authorization: Bearer <token>
{
"chatId": "uuid",
"message": "Hello AI!",
"model": "gpt-4"
}# Upload file
POST /api/files/upload
Authorization: Bearer <token>
Content-Type: multipart/form-data
[file data]
# Get user files
GET /api/files
Authorization: Bearer <token>
# Delete file
DELETE /api/files/:fileId
Authorization: Bearer <token>- GPT-3.5 Turbo
- GPT-4
- GPT-4o
- Claude 3 Haiku
- Claude 3 Sonnet
- Claude 3 Opus
- Claude 3.5 Sonnet
- Gemini Pro
- Gemini Pro Vision
- JWT-based authentication with refresh tokens
- Password hashing with bcrypt
- Role-based access control (Admin/User)
- File upload validation and size limits
- Rate limiting for API endpoints
- CORS configuration
- Input validation and sanitization
id (UUID, Primary Key)
email (String, Unique)
password (String, Hashed)
role (Enum: admin/user)
created_at, updated_atid (UUID, Primary Key)
user_id (UUID, Foreign Key)
model_used (String)
title (String)
created_at, updated_atid (UUID, Primary Key)
chat_id (UUID, Foreign Key)
role (Enum: user/assistant)
content (Text)
file_url (String, Nullable)
created_at, updated_atid (UUID, Primary Key)
filename (String)
original_name (String)
file_path (String)
file_size (Integer)
mime_type (String)
user_id (UUID, Foreign Key)
created_at, updated_atThe application uses Docker Compose with three services:
- postgres: PostgreSQL database
- backend: Node.js API server
- frontend: React development server
For production, modify docker-compose.yml:
# Use production builds
frontend:
build:
context: ./frontend
dockerfile: Dockerfile.prod
command: ["npm", "run", "build"]
# Add nginx for serving static files
nginx:
image: nginx:alpine
ports:
- "80:80"
volumes:
- ./nginx.conf:/etc/nginx/nginx.conf| Variable | Description | Default |
|---|---|---|
DATABASE_URL |
PostgreSQL connection string | Required |
JWT_SECRET |
JWT signing secret | Required |
JWT_REFRESH_SECRET |
Refresh token secret | Required |
ADMIN_EMAIL |
Default admin email | admin@chatproxy.com |
ADMIN_PASSWORD |
Default admin password | admin123 |
OPENAI_API_KEY |
OpenAI API key | Optional |
ANTHROPIC_API_KEY |
Anthropic API key | Optional |
GOOGLE_GEMINI_API_KEY |
Google Gemini API key | Optional |
PORT |
Backend server port | 8000 |
FRONTEND_URL |
Frontend URL for CORS | http://localhost:3000 |
- Maximum file size: 10MB
- Supported formats: Images (JPEG, PNG, GIF), Documents (PDF, DOC, DOCX, TXT, MD)
- Files are stored locally in the
uploads/directory
# Production deployment
docker-compose -f docker-compose.prod.yml up -d- Set up PostgreSQL database
- Configure environment variables
- Build and deploy backend
- Build and deploy frontend
- Set up reverse proxy (nginx)
# Backend tests
cd backend
npm test
# Frontend tests
cd frontend
npm test
# Integration tests
npm run test:integration- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License. See the LICENSE file for details.
Database Connection Issues:
# Check PostgreSQL is running
docker-compose ps
# View logs
docker-compose logs postgresAPI Key Issues:
- Ensure API keys are properly set in
.env - Check API key validity and permissions
- Verify correct model names in requests
File Upload Issues:
- Check upload directory permissions
- Verify file size limits
- Ensure supported file formats
- Check the Issues section
- Review API documentation
- Check Docker logs:
docker-compose logs [service-name]
- Real-time chat with WebSockets
- Voice message support
- Advanced file processing (OCR, PDF parsing)
- Chat export functionality
- Usage analytics and billing
- Multi-language support
- Mobile app (React Native)
- Plugin system for custom AI models
Built with โค๏ธ using React, Node.js, PostgreSQL, and Docker.