Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

13 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

MultiGenQA - Enterprise Multi-AI Chat Platform

A comprehensive, production-ready web platform that enables secure conversations with multiple AI models including OpenAI GPT-4o, Google Gemini 2.5 Flash, and Claude 3.5 Sonnet. Built with enterprise-grade authentication, monitoring, and deployment capabilities.

✨ Features

πŸ€– Multi-AI Integration

  • OpenAI GPT-4o: Latest and most capable OpenAI model
  • Google Gemini 2.5 Flash: Google's fastest multimodal AI
  • Claude 3.5 Sonnet: Anthropic's most intelligent model
  • Seamless Model Switching: Change AI models mid-conversation
  • Conversation Persistence: Full chat history with database storage

πŸ” Enterprise Authentication

  • JWT Token-Based Authentication: Industry-standard security
  • User Registration & Login: Complete account management
  • Password Strength Validation: Real-time password requirements
  • Email Verification: Account verification system
  • Session Management: Automatic token refresh and logout
  • Rate Limiting: Protection against abuse and attacks

🎨 Modern User Experience

  • Responsive Design: Works perfectly on desktop, tablet, and mobile
  • Real-time Chat Interface: Instant message delivery
  • Loading States: Clear feedback during AI processing
  • Error Handling: Graceful error messages and recovery
  • Accessibility: Screen reader compatible and keyboard navigation

πŸš€ Production Ready

  • Docker Containerization: Easy deployment anywhere
  • Database Integration: PostgreSQL with SQLAlchemy ORM
  • Caching Layer: Redis for improved performance
  • Monitoring: Prometheus metrics and Grafana dashboards
  • Security Headers: CORS, CSP, and security best practices
  • SSL/TLS Support: HTTPS encryption ready

πŸ—οΈ Architecture

Frontend (React/TypeScript)

  • React 18 with TypeScript for type-safe development
  • Context API for state management
  • Axios for HTTP client with interceptors
  • Lucide React for consistent iconography
  • Custom CSS with responsive design

Backend (Python Flask)

  • Flask with production WSGI server (Gunicorn)
  • SQLAlchemy ORM with PostgreSQL
  • JWT Authentication with secure password hashing
  • Flask-Limiter for rate limiting
  • Flask-Caching with Redis
  • Prometheus metrics collection

Infrastructure

  • Docker Compose for orchestration
  • PostgreSQL for data persistence
  • Redis for caching and sessions
  • nginx as reverse proxy
  • Prometheus + Grafana for monitoring

🚦 Quick Start

Option 1: Docker (Recommended)

# Clone the repository
git clone https://github.com/your-username/MultiGenQA.git
cd MultiGenQA

# Setup environment variables
cp backend/env.example backend/.env
# Edit backend/.env with your API keys

# Start with Docker
./docker-run.sh

Access your app:

Option 2: Manual Setup

# Backend setup
cd backend
pip install -r requirements.txt
cp env.example .env
# Edit .env with your API keys
python app.py

# Frontend setup (new terminal)
npm install
npm start

πŸ”‘ API Keys Setup

You'll need API keys from these services:

  1. OpenAI β†’ https://platform.openai.com/api-keys
  2. Google AI β†’ https://makersuite.google.com/app/apikey
  3. Anthropic β†’ https://console.anthropic.com/

Add them to backend/.env:

OPENAI_API_KEY=sk-your-openai-key
GOOGLE_API_KEY=your-google-key
ANTHROPIC_API_KEY=your-anthropic-key

πŸ“± How to Use

  1. Create Account: Register with email and secure password
  2. Login: Access your personalized chat interface
  3. Select AI Model: Choose from OpenAI, Gemini, or Claude
  4. Start Chatting: Type messages and get AI responses
  5. Switch Models: Change AI models anytime during conversation
  6. View History: Access all your previous conversations

πŸ“ Project Structure

MultiGenQA/
β”œβ”€β”€ πŸ“ backend/                    # Python Flask API
β”‚   β”œβ”€β”€ app.py                     # Main Flask application
β”‚   β”œβ”€β”€ models.py                  # Database models (User, Conversation, Message)
β”‚   β”œβ”€β”€ requirements.txt           # Python dependencies
β”‚   └── tests/                     # Backend test suite
β”œβ”€β”€ πŸ“ src/                        # React/TypeScript frontend
β”‚   β”œβ”€β”€ πŸ“ components/             # React components
β”‚   β”‚   β”œβ”€β”€ AuthProvider.tsx       # Authentication context
β”‚   β”‚   β”œβ”€β”€ Login.tsx             # Login component
β”‚   β”‚   β”œβ”€β”€ Register.tsx          # Registration component
β”‚   β”‚   β”œβ”€β”€ ChatMessage.tsx       # Message display
β”‚   β”‚   └── ModelSelector.tsx     # AI model selector
β”‚   β”œβ”€β”€ πŸ“ services/              # API services
β”‚   β”‚   └── api.ts                # HTTP client with auth
β”‚   β”œβ”€β”€ πŸ“ types/                 # TypeScript definitions
β”‚   β”‚   └── index.ts              # Type interfaces
β”‚   └── App.tsx                   # Main application
β”œβ”€β”€ πŸ“ docker/                    # Docker configuration
β”‚   β”œβ”€β”€ docker-compose.yml        # Development setup
β”‚   β”œβ”€β”€ docker-compose.prod.yml   # Production setup
β”‚   β”œβ”€β”€ Dockerfile.backend        # Backend container
β”‚   └── Dockerfile.frontend       # Frontend container
β”œβ”€β”€ πŸ“ monitoring/                # Monitoring setup
β”‚   └── prometheus.yml            # Metrics configuration
β”œβ”€β”€ πŸ“ docs/                      # Documentation
β”‚   β”œβ”€β”€ AUTHENTICATION.md         # Auth system guide
β”‚   β”œβ”€β”€ ARCHITECTURE.md           # System architecture
β”‚   β”œβ”€β”€ DOCKER.md                 # Docker guide
β”‚   └── PRODUCTION-DEPLOYMENT.md  # Production deployment
└── README.md                     # This file

πŸ”Œ API Endpoints

Authentication

  • POST /api/auth/register - User registration
  • POST /api/auth/login - User login
  • POST /api/auth/logout - User logout
  • GET /api/auth/me - Get current user
  • POST /api/auth/verify-email - Email verification

Chat & AI

  • GET /api/models - Available AI models
  • POST /api/chat - Send message to AI
  • GET /api/conversations - User's conversations
  • GET /api/conversations/:id - Specific conversation

System

  • GET /api/health - Health check
  • GET /api/metrics - Prometheus metrics
  • GET /api/usage - User's API usage stats

πŸ’» TypeScript Learning Guide

This project demonstrates key TypeScript concepts:

Interfaces & Types

// Define the shape of data
interface User {
  id: string;
  email: string;
  first_name: string;
  last_name: string;
}

// Union types for specific values
type MessageRole = 'user' | 'assistant';

Generic Types

// Type-safe state management
const [user, setUser] = useState<User | null>(null);
const [messages, setMessages] = useState<Message[]>([]);

Function Types

// Define function signatures
interface AuthContextType {
  login: (user: User, token: string) => void;
  logout: () => Promise<void>;
}

Event Handlers

// Properly typed event handlers
const handleSubmit = (e: React.FormEvent<HTMLFormElement>) => {
  e.preventDefault();
  // TypeScript knows the exact event type
};

🐳 Docker Deployment

Development

docker-compose up --build

Production

docker-compose -f docker-compose.prod.yml up -d

With Monitoring

docker-compose -f docker-compose.prod.yml --profile monitoring up -d

πŸ“Š Monitoring & Observability

  • Prometheus Metrics: API performance, error rates, response times
  • Grafana Dashboards: Visual monitoring and alerting
  • Structured Logging: JSON logs for easy parsing
  • Health Checks: Automated service health monitoring

πŸ”’ Security Features

  • JWT Authentication: Secure token-based auth
  • Password Hashing: bcrypt with salt
  • Rate Limiting: API abuse protection
  • CORS Protection: Secure cross-origin requests
  • Security Headers: XSS, CSRF, clickjacking protection
  • Input Validation: Comprehensive data validation
  • SQL Injection Prevention: Parameterized queries

πŸ§ͺ Testing

Backend Tests

cd backend
python test_backend.py

Frontend Tests

npm test

Full Test Suite

npm run test:all

πŸš€ Production Deployment

For production deployment, see our comprehensive guides:

πŸ› οΈ Development

Prerequisites

  • Node.js 18+
  • Python 3.11+
  • Docker (optional but recommended)
  • Git

Development Workflow

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Run tests
  5. Submit a pull request

Code Style

  • TypeScript: Strict mode enabled
  • Python: PEP 8 compliance
  • ESLint: Configured for React/TypeScript
  • Prettier: Code formatting

πŸ“ˆ Performance

  • Response Times: < 2s average for AI responses
  • Concurrent Users: Supports 100+ simultaneous users
  • Database: Optimized queries with proper indexing
  • Caching: Redis caching for frequently accessed data
  • CDN Ready: Static assets optimized for CDN delivery

πŸ”§ Troubleshooting

Common Issues

Authentication not working?

  • Check if JWT secret is set in environment
  • Verify API keys are correctly configured
  • Check browser console for errors

Docker containers not starting?

  • Ensure Docker Desktop is running
  • Check if ports 3000/5001 are available
  • Verify .env file has real API keys

AI responses failing?

  • Verify API keys are valid and have credits
  • Check rate limits on AI service accounts
  • Review backend logs for specific errors

Getting Help

  1. Check the troubleshooting guides
  2. Review GitHub Issues
  3. Join our community discussions

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

πŸ™ Acknowledgments

  • OpenAI for GPT-4o API
  • Google for Gemini API
  • Anthropic for Claude API
  • React and TypeScript communities
  • Flask and Python ecosystems

πŸ“ž Support


Built with ❀️ using React, TypeScript, Python, and Docker

About

MultiGenQA is a modular framework for building question-answering (QA)

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages