A modern chat application powered by OpenRouter API that supports multiple AI models. Built with Next.js 15, React 19, TypeScript and Tailwind CSS. This application allows users to chat with different AI models, upload images, and manage conversation history.
This project is a feature-rich chat application that leverages the OpenRouter API to provide access to multiple AI models. It's designed with a focus on user experience, performance, and modern web development practices.
- OpenRouter API integration
- Dynamic model list fetching
- Model switching functionality
- Model-specific feature support (image upload, etc.)
- Real-time messaging
- Streaming responses
- Message history management
- Base64 image encoding
- File size control (5MB limit)
- Model-specific image support validation
- Local storage-based data persistence
- Conversation history list
- Chat deletion functionality
- Active conversation tracking
- Auto title generation
- Error Boundary: Catches component lifecycle errors
- Global Error Handler: Catches JavaScript and Promise errors
- Error Logging: Sends errors to logging service
- Notification Messages: User-friendly notifications
- Responsive design
- Modern look with Tailwind CSS
- Hover effects
- Loading states
- Notification messages
- Single command deployment with Docker Compose
- Development and production environments
- Next.js 15 - React framework
- React 19 - UI library
- TypeScript - Type safety
- Tailwind CSS - Styling
- Zustand - State management
- React Query - Data fetching
- React Toastify - Notifications
- Next.js API Routes - Backend API
- OpenRouter API - AI model access
- Zod - Input validation
- Docker - Containerization
- Docker Compose - Multi-container orchestration
src/
βββ app/
β βββ api/ # API endpoints
β β βββ chat/ # Chat API
β β βββ errors/ # Error logging API
β β βββ title/ # Title generation API
β βββ components/ # React components
β β βββ ChatInput.tsx # Message input component
β β βββ ChatHistory.tsx # Chat history
β β βββ MessageHistory.tsx # Message display
β β βββ Notification.tsx # Notification messages
β β βββ ErrorBoundary.tsx # Error boundary
β βββ hooks/ # Custom hooks
β β βββ useMessage.ts # Message handling
β β βββ useErrorLogger.ts # Error logging
β β βββ useGlobalErrorHandler.ts # Global error handling
β βββ providers/ # Context providers
β β βββ providers.tsx # Main providers
β βββ layout.tsx # Root layout
βββ lib/
β βββ validations.ts # Zod schemas
βββ stores/
βββ ConversationStore.ts # Conversation state
βββ ModelStore.ts # Model state
- Node.js 20+
- Docker and Docker Compose
- OpenRouter API key
- Clone the repository
git clone https://github.com/M3R1ttt/OpenRouter-Chat-App.git
cd OpenRouter-Chat-App- Create environment file
cp .env.example .env.local-
Configure OpenRouter API
- Go to OpenRouter Dashboard
- Navigate to API Keys section
- Click Create new key or use existing key
- Copy your API key
-
Add your API key
# Add your API key, other options are optional
OPENROUTER_API_KEY=your_api_key_here- Run with Docker
docker compose up -d- Access the application
- Main application: http://localhost:3000
npm install
npm run devnpm run build
npm startnpm run lintI chose Zustand because:
- Simple and lightweight
- Excellent TypeScript support
- Minimal boilerplate
- Less complex than Redux
I selected Tailwind CSS because:
- Utility-first approach
- Easy responsive design
- No custom CSS needed
- Modern and fast
I implemented comprehensive error handling because:
- Production error handling is critical
- Important for user experience
- Makes debugging easier
- Essential for monitoring
- Next.js 15 - Fast compilation with Turbopack
- React 19 - New features and optimizations
- Tailwind CSS - Utility-first, minimal CSS
- Zustand - Lightweight state management
- Docker - Containerized deployment
- NextAuth.js integration
- JWT token management
- User profiles
- PostgreSQL/MongoDB integration
- Prisma ORM
- Cloud storage
- Socket.io integration
- Real-time messaging
- Dark mode
- Animations
- Drag and drop
- Keyboard shortcuts
- Custom model fine-tuning
- Prompt templates
- Response quality scoring
- Cloud storage (AWS S3, Cloudinary)
- File compression
- Multiple file uploads
- File preview
- Rate limiting
- Input sanitization
- CORS configuration
- Security headers