A modern, full-featured AI chat application powered by Google Gemini, Groq, Cerebras, and SambaNova. This application provides a unified interface to interact with cutting-edge models like Gemini 2.0 Flash, Llama 3.1, and Gemma 2, complete with user management, conversation history, and an admin dashboard.
- Multi-Model Support: Seamlessly switch between:
- Google: Gemini 2.0 Flash, Gemini 1.5 Flash
- Groq: Llama 3.1 8B (Instant), Gemma 2 9B
- Cerebras: Llama 3.1 8B (Super Fast)
- SambaNova: Llama 3.1 8B (Balanced)
- Efficient Tier Selection: Optimized model selection for speed and reliability.
- Contextual Memory: Persistent conversation history stored in PostgreSQL.
- Interactive Gallery: Feature showcase with a built-in Lightbox Image Viewer.
- Modern UI: Cyberpunk/Glassmorphism inspired design with dark/light theme support.
- Responsive Design: Fully optimized for Desktop and Mobile devices (including sidebar navigation).
- Customization: Adjustable font sizes, temperature controls, and theme settings.
- Rich Text: Markdown support for code blocks, tables, and lists in chat responses.
- Admin Dashboard: Comprehensive panel to manage users and view system stats.
- User Management: Role-based access control (Admin/User).
- Message Limits: Configurable daily message quotas per user to manage API costs.
- Analytics: Monitor chat volume and user activity.
- Node.js 18 or higher
- PostgreSQL database (Local or Cloud like Neon/Supabase)
- API Keys for the providers you wish to use (Google, Groq, etc.)
-
Clone the repository
git clone https://github.com/MIbnEKhalid/ChatAPI.git cd ChatAPI -
Install dependencies
npm install
-
Set up environment variables Create a
.envfile in the root directory:cp .env.template .env
See the Environment Variables section below.
-
Set up the database Run the SQL script to create the necessary tables:
psql -U your_username -d your_database -f model/db.sql
-
Start the application
npm start
-
Access the application
- Main Application:
http://localhost:3030 - Admin Dashboard:
http://localhost:3030/admin
- Main Application:
Configure the following in your example.env.template file:
.env.template.
The application uses PostgreSQL with the following main tables:
ai_history_chatapi: Stores conversation threads, messages, and timestamps.user_message_logs_chatapi: Tracks daily message usage for rate limiting.users(or equivalent): User credentials and role management.
- Backend: Node.js, Express.js
- Database: PostgreSQL
- Frontend: Handlebars (HBS), Vanilla CSS/JS
- Authentication: Session-based (Custom/Passport)
- AI Integration: Official SDKs and REST APIs
GET /chatbot- Render the chat interface.POST /api/chat- Process user message and return AI response.GET /api/history- Fetch conversation history.DELETE /api/chat/:id- Delete a specific conversation.
GET /admin/dashboard- View system statistics.GET /admin/users- Manage registered users.
Contributions are welcome! Please feel free to submit a Pull Request.
- Fork the project
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
| Name | Role | Links |
|---|---|---|
| Muhammad Bin Khalid | Lead Developer | |
| Maaz Waheed | Developer |
This project is licensed under the MIT License - see the LICENSE file for details.
For questions or contributions, please contact Muhammad Bin Khalid at mbktech.org/Support, support@mbktech.org , chmuhammadbinkhalid28.com and wwork4287@gmail.com.