A comprehensive AI-powered Multiple Choice Question (MCQ) platform built with FastAPI, featuring intelligent question generation with multi-language support (Hindi/English), subject-specific expertise (Mathematics, Physics, Chemistry), user management, subscription handling, and advanced document processing capabilities.
- Overview
- 🆕 New Features
- Features
- Tech Stack
- Project Structure
- Installation & Setup
- Configuration
- Usage
- Language Support
- API Documentation
- Workflow Diagram
- File & Folder Details
- Contributing
- License
Smart MCQ Platform is an enterprise-grade examination system that leverages artificial intelligence to automatically generate high-quality multiple-choice questions from uploaded documents. The platform now features advanced multi-language support, subject-specific AI models, and intelligent content processing for both Hindi and English educational content.
- 🌐 Multi-Language AI: Automatic language detection and native question generation in Hindi/English
- 🧮 Subject-Specific Expertise: Specialized AI models for Mathematics, Physics, Chemistry with accurate calculations
- 🤖 Advanced AI Integration: Google Gemini AI and LangChain for intelligent MCQ creation
- 📄 Smart Document Processing: PDF, DOCX, images with OCR capabilities and page-specific filtering
- 🔍 Vector Search: ChromaDB integration with CLIP embeddings for semantic similarity matching
- 👥 User Management: Role-based access control with JWT authentication
- 💳 Subscription System: Flexible subscription plans with payment integration
- 💬 Real-time Chat: AI-powered multilingual chatbot for instant assistance
- 📊 Comprehensive Analytics: Performance tracking and detailed reporting
- 🇮🇳 Hindi Language: Native Hindi question generation with proper Devanagari script support
- 🇬🇧 English Language: Enhanced English question generation with improved accuracy
- 🔄 Automatic Detection: Smart language detection based on document content
- 📚 Bilingual Keywords: Subject-specific keyword matching in both languages
- 🔢 Mathematical Accuracy: Specialized prompts ensuring correct calculations and formulas
- 📐 Clean Notation: Standard ASCII mathematical notation (x^2, a/b, [[matrix]])
- 🧠 Expert AI: Mathematics-specific system prompts for enhanced accuracy
- 🚫 No Admin Questions: Filters out exam instructions, focuses only on mathematical concepts
- ❓ What Questions: "What is...", "What happens when...", "What are the characteristics..."
- 🔧 How Questions: "How does...work?", "How is...calculated?", "How can...be determined?"
- 📍 Where Questions: "Where is...found?", "Where does...occur?", "Where is...applied?"
- 🤔 Why Questions: "Why does...happen?", "Why is...important?", "Why is...used?"
- ⏰ When Questions: "When does...occur?", "When is...applied?", "When should...be used?"
- Direct Questions: Standalone factual questions
- Context-Based Questions: Include relevant text excerpts with proper attribution
- Condition-Based Questions: Scenario-based problem-solving questions
- 🧠 Advanced Gemini AI Integration with subject-specific expertise for natural language processing
- 🖼️ CLIP Model for image and text embeddings with enhanced multilingual support
- 🗄️ Vector Database with ChromaDB for semantic search and content retrieval
- 🎯 Intelligent Question Generation with difficulty levels, topic scope, and language awareness
- 📱 OCR Support with Tesseract for image-based documents and scanned content
- 🔍 Smart Content Filtering with chapter-specific keyword matching
- 📄 Multi-format Support: PDF, DOCX, images with intelligent content extraction
- 🧠 Language-Aware Processing: Automatic detection and processing of Hindi/English content
- 📖 Page-specific Processing for targeted question generation with chapter filtering
- ⚡ Fast Processing Pipeline using CLIP + ChromaDB + Gemini for 3-5x speed improvement
- 🔧 Subject Detection: Mathematics, Physics, Chemistry content identification
- 📊 Batch Processing capabilities for multiple documents with progress tracking
- 🔐 Role-based Access Control (Admin, Teacher, Student) with granular permissions
- 🎫 JWT Authentication with secure token management and refresh tokens
- 👤 Comprehensive User Profiles with detailed analytics and learning progress
- 📈 Activity Tracking and performance monitoring with visual dashboards
- 🔒 Security Features with input validation and SQL injection prevention
- 💰 Stripe Integration for international payments with webhook support
- 🇮🇳 Razorpay Support for Indian market with UPI and wallet support
- 📋 Flexible Subscription Plans with feature limitations and usage tracking
- 📧 Automated Billing and invoice generation with email notifications
- 💎 Freemium Model with free and premium content differentiation
- 💬 Multilingual Real-time Chat with AI-powered responses in Hindi/English
- 📝 Advanced Test Management with comprehensive settings and scheduling
- 📈 Performance Analytics with detailed reporting and progress tracking
- 📧 Smart Notifications via email with customizable templates
- 📱 SMS Integration via Twilio for important alerts and notifications
- FastAPI (0.117.1) - Modern Python web framework
- SQLAlchemy (2.0.43) - ORM for database operations
- Alembic (1.17.0) - Database migrations
- PostgreSQL/SQLite - Database systems
- Redis - Caching and session management
- LangChain (0.3.27) - LLM orchestration framework
- Google Generative AI (0.8.5) - Gemini AI integration
- Transformers (4.55.4) - Hugging Face transformers
- PyTorch (2.8.0) - Deep learning framework
- ChromaDB (1.0.20) - Vector database
- Sentence Transformers (5.1.1) - Text embeddings
- PyPDF2 (3.0.1) - PDF processing
- PyMuPDF (1.26.5) - Advanced PDF operations
- Pytesseract (0.3.13) - OCR capabilities
- python-docx (1.2.0) - Word document processing
- Pillow (11.3.0) - Image processing
- Stripe (13.0.1) - Payment processing
- Razorpay (2.0.0) - Indian payment gateway
- Twilio (9.8.3) - SMS services
- FastAPI-Mail (1.5.2) - Email services
Fastapi-mcq-platform/
├── 📁 app/ # Main application package
│ ├── 📁 api/ # API layer
│ │ └── 📁 v1/ # API version 1
│ │ ├── admin.py # Admin management endpoints
│ │ ├── auth.py # Authentication endpoints
│ │ ├── categories.py # Category management
│ │ ├── chatbot.py # Chatbot API endpoints
│ │ ├── subscriptions.py # Subscription management
│ │ ├── tests.py # Test management endpoints
│ │ └── users.py # User management endpoints
│ ├── 📁 core/ # Core application logic
│ │ ├── config.py # Application configuration
│ │ ├── database.py # Database connection & setup
│ │ ├── exceptions.py # Custom exception classes
│ │ └── security.py # Security utilities
│ ├── 📁 models/ # Database models
│ │ ├── attempt.py # Test attempt models
│ │ ├── category.py # Category models
│ │ ├── chat.py # Chat models
│ │ ├── chatbot.py # Chatbot models
│ │ ├── gamification.py # Gamification models
│ │ ├── subscription.py # Subscription models
│ │ ├── test.py # Test models
│ │ └── user.py # User models
│ └── 📁 services/ # Business logic layer
│ ├── document_processor.py # Document processing service
│ ├── fast_mcq_generator.py # Fast MCQ generation
│ ├── mcq_generator.py # Main MCQ generation
│ ├── rag_chatbot.py # RAG-based chatbot
│ └── vector_service.py # Vector database operations
├── 📁 models/ # Pre-trained models
│ └── 📁 clip-vit-base-patch32/ # CLIP model files
├── 📁 myenv/ # Virtual environment
├── 📁 monitoring/ # Monitoring configurations
├── 📁 uploads/ # File upload directory
├── main.py # Application entry point
├── requirements.txt # Python dependencies
├── .env # Environment variables
├── .env.example # Environment template
├── Procfile # Heroku deployment config
└── README.md # Project documentation
The easiest way to get started is using the pre-built Docker image from Docker Hub:
# Pull the latest image from Docker Hub
docker pull prabhat9801/fastapi_mcq_platform
# Run the container
docker run -p 8000:8000 prabhat9801/fastapi_mcq_platform
# Access the application
# API Documentation: http://localhost:8000/api/docs
# Health Check: http://localhost:8000/healthTo customize the Docker deployment, you can pass environment variables:
docker run -p 8000:8000 \
-e GOOGLE_API_KEY="your-google-api-key" \
-e DATABASE_URL="sqlite:///./mcq_platform.db" \
-e SECRET_KEY="your-secret-key" \
prabhat9801/fastapi_mcq_platform- Docker Hub: prabhat9801/fastapi_mcq_platform
- GitHub Repository: Prabhat9801/Fastapi-mcq-platform
- Python 3.8 or higher
- PostgreSQL (optional, SQLite works for development)
- Redis (optional, for caching)
- Git
git clone https://github.com/Prabhat9801/Fastapi-mcq-platform.git
cd Fastapi-mcq-platform# Windows
python -m venv myenv
myenv\Scripts\activate
# Linux/Mac
python -m venv myenv
source myenv/bin/activatepip install --upgrade pip
pip install -r requirements.txt# Copy environment template
cp .env.example .env
# Edit .env file with your configurations
# Key settings to configure:
# - GOOGLE_API_KEY: Your Google Gemini API key
# - DATABASE_URL: Your database connection string
# - SECRET_KEY: Generate a strong secret key
# - Payment gateway credentials (Stripe, Razorpay)# For SQLite (default development setup)
# Database will be created automatically
# For PostgreSQL
# 1. Create database: mcq_platform
# 2. Update DATABASE_URL in .env
# 3. Run migrations
alembic upgrade head# Create models directory
mkdir models
cd models
# Clone CLIP model from Hugging Face
git clone https://huggingface.co/openai/clip-vit-base-patch32
# Go back to project root
cd ..Alternative Model Download Methods:
Option A: Using Hugging Face Hub (Recommended)
# Install huggingface_hub if not already installed
pip install huggingface_hub
# Download model using Python
python -c "
from huggingface_hub import snapshot_download
snapshot_download(
repo_id='openai/clip-vit-base-patch32',
local_dir='./models/clip-vit-base-patch32',
local_dir_use_symlinks=False
)
"Option B: Automatic Download (First Run)
# The model will be downloaded automatically on first use
# Check app/services/vector_service.py for auto-download logic- Model: OpenAI CLIP ViT-B/32
- Repository: https://huggingface.co/openai/clip-vit-base-patch32
- Size: ~600MB
- Purpose: Text and image embeddings for vector search
# Model Configuration
CLIP_MODEL_PATH=./models/clip-vit-base-patch32
HUGGINGFACEHUB_API_TOKEN=your-huggingface-token # Optional for private models
MODEL_CACHE_DIR=./modelsIf model download fails:
# Method 1: Direct download using wget/curl
wget -r --no-parent https://huggingface.co/openai/clip-vit-base-patch32/resolve/main/
# Method 2: Manual download
# Visit: https://huggingface.co/openai/clip-vit-base-patch32
# Download required files to ./models/clip-vit-base-patch32/Required model files:
config.jsonpytorch_model.binormodel.safetensorstokenizer.jsontokenizer_config.jsonvocab.jsonmerges.txt
# Development mode
python main.py
# Or using uvicorn directly
uvicorn main:app --reload --host 127.0.0.1 --port 8000- API Documentation: http://localhost:8000/api/docs
- ReDoc Documentation: http://localhost:8000/api/redoc
- Health Check: http://localhost:8000/health
APP_NAME="Smart MCQ Platform"
DEBUG=True
HOST=0.0.0.0
PORT=8000# PostgreSQL (Production)
DATABASE_URL=postgresql://user:password@localhost:5432/mcq_platform
# SQLite (Development)
DATABASE_URL=sqlite:///./mcq_platform.dbSECRET_KEY=your-secret-key-here-generate-a-strong-one
ALGORITHM=HS256
ACCESS_TOKEN_EXPIRE_MINUTES=10080GOOGLE_API_KEY="your-google-gemini-api-key"
HUGGINGFACEHUB_API_TOKEN="your-huggingface-token"
CLIP_MODEL_PATH=./models/clip-vit-base-patch32UPLOAD_DIR=./uploads
MAX_UPLOAD_SIZE=52428800 # 50MB
TESSERACT_CMD=C:/Program Files/Tesseract-OCR/tesseract.exe # Windowspython create_admin.py# Using the API
POST /api/v1/admin/tests/generate-fast
# Form data:
{
"file": "document.pdf",
"test_series_id": 1,
"test_name": "Chapter 1 Test",
"num_questions": 10,
"difficulty_level": "medium",
"topic_scope": "comprehensive",
"duration_minutes": 60,
"specific_pages": "1-10" # Optional
}# Create user
POST /api/v1/users/register
# Get user details
GET /api/v1/users/{user_id}
# Update user role
PUT /api/v1/admin/users/{user_id}/role# Register
POST /api/v1/auth/register
# Login
POST /api/v1/auth/login
# Response includes JWT token for subsequent requests# Get available tests
GET /api/v1/tests/
# Start test attempt
POST /api/v1/tests/{test_id}/start
# Submit answers
POST /api/v1/tests/{test_id}/submit# Send message to chatbot
POST /api/v1/chat/message
{
"message": "Explain photosynthesis",
"context": "biology"
}POST /api/v1/auth/register- User registrationPOST /api/v1/auth/login- User loginPOST /api/v1/auth/refresh- Refresh JWT tokenPOST /api/v1/auth/logout- User logout
POST /api/v1/admin/tests/generate- Generate MCQs (slow, thorough)POST /api/v1/admin/tests/generate-fast- Generate MCQs (fast)GET /api/v1/admin/users- List all usersPUT /api/v1/admin/users/{user_id}/role- Update user roleDELETE /api/v1/admin/tests/{test_id}- Delete test
GET /api/v1/tests/- List available testsGET /api/v1/tests/{test_id}- Get test detailsPOST /api/v1/tests/{test_id}/start- Start test attemptPOST /api/v1/tests/{test_id}/submit- Submit test answersGET /api/v1/tests/{test_id}/results- Get test results
POST /api/v1/chat/message- Send message to AI chatbotGET /api/v1/chat/history- Get chat historyDELETE /api/v1/chat/history- Clear chat history
GET /api/v1/subscriptions/plans- List subscription plansPOST /api/v1/subscriptions/subscribe- Subscribe to planGET /api/v1/subscriptions/status- Check subscription status
graph TB
subgraph "Document Processing"
A[📄 User Uploads Document] --> B[🔧 Document Processor]
B --> C{📋 Document Type?}
C -->|PDF| D[📖 PyPDF2/PyMuPDF<br/>Extraction]
C -->|DOCX| E[📝 python-docx<br/>Extraction]
C -->|Image| F[👁️ Tesseract OCR<br/>Processing]
end
subgraph "AI Processing Pipeline"
D --> G[🧹 Text Preprocessing]
E --> G
F --> G
G --> H[🎯 CLIP Embeddings<br/>Generation]
H --> I[💾 ChromaDB<br/>Vector Storage]
I --> J[🔗 LangChain<br/>Processing]
J --> K[🤖 Google Gemini AI<br/>Analysis]
K --> L[❓ MCQ Generation<br/>& Formatting]
end
subgraph "Quality & Storage"
L --> M[✅ Question Validation<br/>& Quality Check]
M --> N[🗄️ Database Storage<br/>SQLite/PostgreSQL]
N --> O[📡 API Response<br/>to Client]
end
subgraph "Test Taking Flow"
P[👤 User Takes Test] --> Q[📝 Answer Submission]
Q --> R[🎯 Automatic Scoring<br/>& Evaluation]
R --> S[📊 Results & Analytics<br/>Dashboard]
end
subgraph "AI Chat System"
T[💬 User Chat Query] --> U[🧠 RAG System<br/>Processing]
U --> I
U --> V[🔍 Context Retrieval<br/>from Vectors]
V --> W[🤖 AI Response<br/>Generation]
W --> X[💬 Chat Response<br/>to User]
end
style A fill:#e1f5fe
style O fill:#c8e6c9
style S fill:#fff3e0
style X fill:#f3e5f5
For environments where Mermaid diagrams don't render, here's the workflow in text format:
1. Document Upload → 2. Format Detection → 3. Content Extraction
↓ ↓ ↓
[PDF/DOCX/Image] → [Type Analysis] → [Text/OCR Processing]
4. Text Preprocessing → 5. CLIP Embeddings → 6. Vector Storage
↓ ↓ ↓
[Clean & Format] → [Generate Vectors] → [ChromaDB Store]
7. LangChain Process → 8. Gemini AI → 9. MCQ Generation
↓ ↓ ↓
[Context Setup] → [AI Analysis] → [Question Creation]
10. Quality Check → 11. Database Store → 12. API Response
↓ ↓ ↓
[Validate] → [SQLite/PostgreSQL] → [JSON Response]
User Login → Select Test → Answer Questions → Submit → Auto-Score → Results
↓ ↓ ↓ ↓ ↓ ↓
[Auth] → [Test Selection] → [UI Interface] → [DB] → [Algorithm] → [Dashboard]
User Query → RAG Processing → Vector Search → Context Retrieval → AI Response
↓ ↓ ↓ ↓ ↓
[Input] → [Question Analysis] → [ChromaDB] → [Relevant Docs] → [Gemini AI]
| Component | Technology | Purpose |
|---|---|---|
| Document Parser | PyPDF2, PyMuPDF, python-docx | Extract text from various formats |
| OCR Engine | Tesseract | Process image-based documents |
| Embeddings | CLIP ViT-B/32 | Generate semantic vectors |
| Vector DB | ChromaDB | Store and search document embeddings |
| AI Engine | Google Gemini | Generate intelligent MCQs |
| Framework | LangChain | Orchestrate AI workflows |
| Database | SQLAlchemy + PostgreSQL/SQLite | Persistent data storage |
| API | FastAPI | RESTful web service interface |
- Purpose: Application entry point and FastAPI app configuration
- Key Features:
- CORS middleware setup
- Database initialization
- Vector database setup
- Global exception handling
- Health check endpoints
- Lifespan management
- Purpose: Centralized configuration management
- Features:
- Environment variable loading
- Validation of configuration parameters
- Default value management
- Type safety with Pydantic
- Purpose: Database connection and session management
- Components:
- SQLAlchemy engine configuration
- Database session factory
- Connection pool management
- Database URL handling
- Purpose: Authentication and security utilities
- Functions:
- JWT token creation and validation
- Password hashing and verification
- Security dependencies for routes
- Role-based access control
- Purpose: Custom exception classes
- Exception Types:
AppException: Base application exceptionAuthException: Authentication errorsValidationException: Data validation errorsDatabaseException: Database operation errors
- Purpose: Administrative endpoints
- Key Endpoints:
- MCQ generation from documents
- User management (role updates, account management)
- Test management (create, update, delete)
- System statistics and analytics
- Security: Admin role required for all endpoints
- Purpose: Authentication and authorization
- Endpoints:
- User registration with email verification
- Login with JWT token generation
- Token refresh mechanism
- Password reset functionality
- Logout and token invalidation
- Purpose: Test and examination management
- Features:
- Test creation and configuration
- Test attempt management
- Real-time test taking
- Answer submission and validation
- Results calculation and analytics
- Test history and performance tracking
- Purpose: User profile and account management
- Functions:
- Profile viewing and updating
- Account settings management
- Activity history
- Performance analytics
- Subscription status
- Purpose: AI-powered chat functionality
- Capabilities:
- Natural language query processing
- Context-aware responses
- Chat history management
- Multi-turn conversations
- Subject-specific assistance
- Purpose: Subscription and payment management
- Features:
- Subscription plan management
- Payment processing (Stripe, Razorpay)
- Billing history
- Feature access control
- Subscription analytics
- Purpose: Subject and category management
- Functions:
- Subject categorization
- Topic organization
- Category-based filtering
- Hierarchical category structure
- Models: User, UserRole, UserStatus
- Features:
- User authentication data
- Role-based permissions
- Profile information
- Activity tracking
- Relationship definitions
- Models: Test, Question, Choice, TestSeries
- Components:
- Test configuration
- Question bank management
- Multiple choice options
- Test series organization
- Difficulty levels and topics
- Models: TestAttempt, UserAnswer, TestResult
- Tracking:
- Test attempt sessions
- Individual answer recording
- Time tracking
- Score calculation
- Performance metrics
- Models: SubscriptionPlan, UserSubscription, Payment
- Management:
- Subscription tier definitions
- User subscription status
- Payment transaction records
- Feature access control
- Models: ChatSession, ChatMessage
- Features:
- Chat session management
- Message history
- Context preservation
- User interaction tracking
- Purpose: Main MCQ generation service
- Capabilities:
- Integration with Google Gemini AI
- Question quality validation
- Difficulty level assignment
- Topic categorization
- Batch question generation
- Purpose: Optimized MCQ generation
- Features:
- Faster processing using CLIP embeddings
- ChromaDB integration
- Streamlined question creation
- Reduced API calls
- Improved performance metrics
- Purpose: Multi-format document processing
- Supported Formats:
- PDF processing (PyPDF2, PyMuPDF)
- Word document handling (python-docx)
- Image OCR (Tesseract)
- Text extraction and cleaning
- Metadata extraction
- Purpose: Vector database operations
- Functions:
- ChromaDB management
- Document embedding storage
- Similarity search
- Vector indexing
- Retrieval operations
- Purpose: Retrieval-Augmented Generation chatbot
- Features:
- Context-aware responses
- Document-based knowledge retrieval
- Multi-turn conversation support
- Subject-specific assistance
- Response quality optimization
- Purpose: Environment configuration
- Categories:
- Server settings (host, port, debug mode)
- Database configuration
- API keys and secrets
- Third-party service credentials
- File upload settings
- Purpose: Python package dependencies
- Categories:
- Core FastAPI framework
- Database and ORM packages
- AI and ML libraries
- Document processing tools
- Payment and communication services
- Purpose: Heroku deployment configuration
- Content: Web process definition for production deployment
- Purpose: Pre-trained model storage
- Contents:
- CLIP model files
- Model configurations
- Tokenizer files
- Model metadata
- Purpose: Temporary file storage
- Usage:
- Document upload handling
- File processing workspace
- Temporary storage during processing
- Purpose: Python virtual environment
- Contents:
- Isolated Python installation
- Project-specific packages
- Environment-specific configurations
- JWT Token-based Authentication
- Role-based Access Control (Admin, Teacher, Student)
- Password Hashing with bcrypt
- Token Expiration and refresh mechanisms
- Secure Session Management
- Input Validation with Pydantic models
- SQL Injection Prevention via SQLAlchemy ORM
- XSS Protection through proper data sanitization
- CORS Configuration for cross-origin requests
- File Upload Validation and size limits
- Rate Limiting for API endpoints
- Request Size Limits to prevent DoS attacks
- Secure Headers implementation
- Environment Variable Protection
- Error Handling without information disclosure
- Connection Pooling for efficient database access
- Query Optimization with proper indexing
- Lazy Loading for related data
- Database Migration Management with Alembic
- Redis Integration for session and data caching
- Vector Caching for frequently accessed embeddings
- API Response Caching for static data
- Model Caching to reduce loading times
- Model Caching to avoid repeated downloads
- Batch Processing for multiple documents
- Async Processing for long-running tasks
- Efficient Embedding Storage with ChromaDB
# Pull and run the latest image
docker pull prabhat9801/fastapi_mcq_platform
docker run -d -p 8000:8000 \
--name mcq-platform \
-e GOOGLE_API_KEY="your-api-key" \
-e SECRET_KEY="your-secret-key" \
prabhat9801/fastapi_mcq_platform# Clone the repository
git clone https://github.com/Prabhat9801/Fastapi-mcq-platform.git
cd Fastapi-mcq-platform
# Build the Docker image
docker build -t fastapi-mcq-platform .
# Run the container
docker run -d -p 8000:8000 \
--name mcq-platform \
-e GOOGLE_API_KEY="your-api-key" \
-e SECRET_KEY="your-secret-key" \
fastapi-mcq-platform# docker-compose.yml
version: '3.8'
services:
mcq-platform:
image: prabhat9801/fastapi_mcq_platform
ports:
- "8000:8000"
environment:
- GOOGLE_API_KEY=your-google-api-key
- DATABASE_URL=postgresql://user:password@db:5432/mcq_platform
- SECRET_KEY=your-secret-key
- REDIS_URL=redis://redis:6379
depends_on:
- db
- redis
volumes:
- ./uploads:/app/uploads
- ./models:/app/models
db:
image: postgres:15
environment:
- POSTGRES_DB=mcq_platform
- POSTGRES_USER=user
- POSTGRES_PASSWORD=password
volumes:
- postgres_data:/var/lib/postgresql/data
redis:
image: redis:7-alpine
volumes:
postgres_data:# Run with Docker Compose
docker-compose up -dAWS ECS/EKS:
# Use the Docker image: prabhat9801/fastapi_mcq_platformGoogle Cloud Run:
gcloud run deploy mcq-platform \
--image=prabhat9801/fastapi_mcq_platform \
--platform=managed \
--region=us-central1 \
--allow-unauthenticatedAzure Container Instances:
az container create \
--resource-group myResourceGroup \
--name mcq-platform \
--image prabhat9801/fastapi_mcq_platform \
--ports 8000DigitalOcean App Platform:
- Use Docker Hub image:
prabhat9801/fastapi_mcq_platform - Set environment variables in the dashboard
# Clone and setup
git clone <repository-url>
cd Fastapi-mcq-platform
python -m venv myenv
myenv\Scripts\activate # Windows
pip install -r requirements.txt
# Configure environment
cp .env.example .env
# Edit .env with your settings
# Run application
python main.pyIf you want to build your own Docker image with modifications:
# Clone the repository
git clone https://github.com/Prabhat9801/Fastapi-mcq-platform.git
cd Fastapi-mcq-platform
# Build the image
docker build -t your-username/fastapi-mcq-platform .
# Run the container
docker run -p 8000:8000 your-username/fastapi-mcq-platform
# Push to your Docker Hub (optional)
docker tag your-username/fastapi-mcq-platform your-username/fastapi-mcq-platform:latest
docker push your-username/fastapi-mcq-platform:latest- Base Image:
python:3.10-slim - Exposed Port:
8000 - Working Directory:
/app - Pre-installed: All dependencies from
requirements.txt - Auto-runs: Admin user creation on startup
- Prepare Procfile (already included)
- Set Environment Variables in Heroku dashboard
- Deploy:
heroku create your-app-name
git push heroku mainNote: For easier deployment, consider using the Docker image:
# Deploy using Docker on Heroku
heroku container:push web --app your-app-name
heroku container:release web --app your-app-name- Database: Use PostgreSQL instead of SQLite
- Redis: Set up Redis for caching
- Environment Variables: Secure API keys and secrets
- Monitoring: Implement logging and error tracking
- Load Balancing: Use nginx or similar for high traffic
- SSL/TLS: Enable HTTPS for production
# Run all tests
pytest
# Run with coverage
pytest --cov=app
# Run specific test file
pytest tests/test_mcq_generator.py- Unit Tests: Individual function testing
- Integration Tests: API endpoint testing
- Database Tests: Model and query testing
- Authentication Tests: Security feature testing
- Fork the repository
- Clone your fork
- Create a feature branch
- Make your changes
- Add tests for new features
- Run the test suite
- Submit a pull request
- Follow PEP 8 guidelines
- Use type hints where applicable
- Document functions and classes
- Write meaningful commit messages
- Use GitHub Issues for bug reports
- Provide detailed reproduction steps
- Include environment information
- Add relevant logs and error messages
This project is licensed under the MIT License. See the LICENSE file for details.
- GitHub Repository: https://github.com/Prabhat9801/Fastapi-mcq-platform
- Docker Hub: https://hub.docker.com/r/prabhat9801/fastapi_mcq_platform
- Documentation: Check this README and API docs at
http://localhost:8000/api/docs - Issues: Report bugs via GitHub Issues
- Discussions: Use GitHub Discussions for questions
- Docker Hub: Check Docker Hub repository for image updates
- Star ⭐ the repository if you find it useful
- Fork and contribute to the project
- Share feedback and suggestions
- Help others in discussions
Made with ❤️ by the Smart MCQ Platform Team
Last Updated: October 2024