An intelligent adaptive learning system that personalizes English education through AI-driven quizzes, real-time performance tracking, and interactive teaching. The platform features comprehensive user authentication, adaptive learning algorithms, and an AI Teacher powered by Mistral 7B for conversational learning support.
- π― Project Overview
- β¨ Key Features
- π οΈ Tech Stack
- π Project Structure
- π Installation & Setup
- π» Usage Guide
- π§ͺ Testing & Quality Assurance
- π§ Configuration
- π€ AI Integration
- π Database Schema
- π Security Features
- π Performance Analytics
- π³ Docker Deployment
- π€ Contributing
- π License
The AI-Powered English Learning Platform is a comprehensive educational system that adapts to individual learning patterns and provides personalized English instruction. The platform combines traditional quiz-based learning with cutting-edge AI technology to create an engaging and effective learning experience.
- Adaptive Learning: Content adjusts based on user performance and learning patterns
- AI-Powered Assistance: Mistral 7B integration provides intelligent tutoring and explanations
- Progressive Difficulty: Users advance through beginner, intermediate, and advanced levels
- Comprehensive Tracking: Detailed analytics help both learners and instructors monitor progress
- Quality Assurance: 100% test coverage ensures reliability and robust functionality
- β 100% Test Coverage: All 8 major system components fully tested
- β Comprehensive Test Suite: 40+ individual test scenarios
- β Production Ready: Robust error handling and fallback systems
- β Performance Optimized: Efficient AI quiz generation with smart fallbacks
- β Security Validated: Authentication and authorization thoroughly tested
- Secure Registration/Login: Robust authentication with password hashing and session management
- User Profiles: Comprehensive profile management with progress tracking
- Account Security: Password changes, username updates, and account deletion with verification
- β Fully Tested: 100% authentication test coverage with security validation
- Progressive Quizzes: New users start with static quizzes to establish baseline proficiency
- Adaptive Difficulty: AI-powered quizzes adjust difficulty based on performance history
- Level Progression: Automatic advancement through beginner β intermediate β advanced levels
- Topic-Specific Learning: Focused practice in Grammar, Vocabulary, Reading, and Mixed topics
- Smart Fallbacks: Robust backup quiz system ensures continuous learning experience
- β Thoroughly Tested: Quiz generation, evaluation, and progression logic validated
- Conversational Learning: Chat with Mistral 7B for explanations and practice
- Contextual Responses: AI provides educational feedback tailored to English learning
- Teacher-Style Interactions: Encouraging, patient responses with practical examples
- Question Answering: Get detailed explanations for grammar, vocabulary, and pronunciation
- β AI Functionality Verified: Chat assistant and Q&A systems fully operational
- Real-Time Dashboards: Visual progress tracking with interactive charts
- Detailed Quiz Results: Question-by-question review with explanations
- Topic Performance: Breakdown of strengths and weaknesses by subject area
- Historical Tracking: Timeline of improvement and level progression
- Average Score Calculation: Accurate progress metrics across all quizzes
- Data Consistency: Synchronized metrics across all analytics endpoints
- β Analytics Validated: All performance tracking and metrics thoroughly tested
- Framework: FastAPI (Python) - High-performance async web framework
- Database: MongoDB - Flexible document storage for user data and analytics
- AI Integration: Ollama + Mistral 7B - Local AI model deployment
- Authentication: JWT sessions with secure password hashing
- API Documentation: Auto-generated Swagger UI
- Framework: React 18 with TypeScript - Modern, type-safe UI development
- Styling: TailwindCSS - Utility-first responsive design
- State Management: React Context API - Centralized auth and app state
- Charts: Chart.js - Interactive performance visualizations
- Routing: React Router - Client-side navigation with protected routes
- Language Model: Mistral 7B via Ollama - Efficient local deployment
- Adaptive Algorithms: Custom Python algorithms for difficulty adjustment
- Performance Analysis: Real-time learning pattern recognition
- Containerization: Docker + Docker Compose - Consistent development/production environments
- Code Quality: TypeScript + Python type hints - Enhanced code reliability
- Development: Hot reload for both frontend and backend
- Test Coverage: 100% success rate across 8 comprehensive test suites
- Test Framework: Python pytest with custom test runners and detailed reporting
- Test Categories: Authentication, Quiz Systems, AI Features, Performance Analytics
- Test Features: Automated cleanup, isolated environments, performance monitoring
- Continuous Validation: All critical functionality thoroughly tested and validated
AISE_project/
βββ π README.md # This comprehensive guide
βββ π docker-compose.yml # Production deployment configuration
βββ π docker-compose.dev.yml # Development environment setup
βββ π Dockerfile.ollama # Mistral AI model container
β
βββ ποΈ backend/ # Python FastAPI backend
β βββ π Dockerfile # Backend container configuration
β βββ π requirements.txt # Python dependencies
β βββ ποΈ app/
β βββ π main.py # FastAPI application entry point
β βββ π config.py # Configuration management
β βββ π db.py # MongoDB connection
β βββ ποΈ models/ # Business logic and data models
β β βββ π user_model.py # User authentication and profiles
β β βββ π learning_model.py # Adaptive learning algorithms
β β βββ π question_model.py # Quiz question management
β βββ οΈ routes/ # API endpoints
β βββ π auth.py # Authentication endpoints
β βββ π chat.py # AI Teacher chat integration
β βββ π questions.py # Quiz question management
β βββ π quiz_generator.py # Adaptive quiz generation
β βββ π evaluations.py # Quiz evaluation and scoring
β βββ π performance.py # Analytics and progress tracking
β
βββ ποΈ frontend/ # React TypeScript frontend
β βββ π Dockerfile # Frontend container configuration
β βββ π package.json # Node.js dependencies
β βββ π tailwind.config.js # TailwindCSS configuration
β βββ ποΈ public/ # Static assets
β βββ ποΈ src/
β βββ π App.tsx # Main application component
β βββ π index.tsx # React application entry point
β βββ ποΈ api/ # API client configuration
β β βββ π apiClient.ts # Axios HTTP client
β β βββ π endpoints.ts # API endpoint definitions
β βββ ποΈ contexts/ # React Context providers
β β βββ π AuthContext.tsx # Global authentication state
β βββ ποΈ components/ # React components
β β βββ π SignInPage.tsx # User authentication
β β βββ π SignUpPage.tsx # User registration
β β βββ π Dashboard.tsx # Performance analytics
β β βββ π QuizPage.tsx # Static quiz interface
β β βββ π AdaptiveQuizPage.tsx # AI-generated quizzes
β β βββ π ChatAssistant.tsx # AI Teacher chat interface
β β βββ π AccountPage.tsx # Profile management
β β βββ π ProtectedRoute.tsx # Route access control
β βββ ποΈ styles/ # Styling and themes
β βββ π tailwind.css # Global styles
β
βββ ποΈ mongodb-init/ # Database initialization
β βββ π init-mongo.js # MongoDB setup script
β
βββ ποΈ test/ # Comprehensive test suite for all functionalities
β βββ π README.md # Complete test documentation and usage guide
β βββ π run_all_tests.py # Master test runner with reporting and analysis
β β
β βββ π Authentication Tests # User management and security
β β βββ π test_authentication_system.py # Registration, login, profile, security
β β
β βββ π Quiz System Tests # Quiz generation and evaluation
β β βββ π test_quiz_generation.py # Adaptive/static quiz creation
β β βββ π test_quiz_evaluation.py # Scoring, progression, analytics
β β
β βββ π€ AI Features Tests # Chat and AI functionality
β β βββ π test_chat_assistant.py # AI Teacher chat interactions
β β βββ π test_question_assistant.py # Q&A functionality
β β
β βββ π Analytics Tests # Performance and tracking
β β βββ π test_performance_analytics.py # User metrics and progress
β β
β βββ π§ Core Functionality # Basic system tests
β β βββ π simple_test.py # API connectivity and health
β β βββ π test_first_quiz_flag.py # First quiz completion tracking
β β βββ π test_reading_comprehension.py # Reading quiz functionality
β β
β βββ π οΈ Legacy/Feature Tests # Specific fixes and improvements
β βββ π test_interface_fix.py # Interface improvements
β βββ π test_level_retrocession.py # Level progression logic
β βββ π test_quiz_fix.py # Quiz bug fixes
β βββ π test_static_quiz_removal.py # Static element removal
β
βββ π setup-ollama.sh # Mistral model installation script
- Docker & Docker Compose - For containerized deployment
- Git - For version control
- 4GB+ RAM - For running Mistral 7B model
- Modern Web Browser - Chrome, Firefox, Safari, or Edge
-
Clone the Repository
git clone <repository-url> cd AISE_project
-
Environment Configuration
# Copy environment template cp .env.example .env # Edit configuration (see Configuration section) nano .env
-
Start the Complete Platform
# Start all services (database, AI model, backend, frontend) docker-compose up -d # View logs (optional) docker-compose logs -f
-
Access the Platform
- Frontend: http://localhost:3000
- Backend API: http://localhost:8000
- API Documentation: http://localhost:8000/docs
For active development with hot reload:
# Start development environment
docker-compose -f docker-compose.dev.yml up -d
# The development setup includes:
# - Hot reload for React frontend
# - Auto-restart for FastAPI backend
# - Persistent data volumes
# - Development-optimized loggingClick to expand manual installation steps
cd backend
python3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
# Set environment variables
export MONGO_URI="mongodb://localhost:27017/english_learning"
export OLLAMA_BASE_URL="http://localhost:11434"
export OLLAMA_MODEL="mistral:7b"
# Start the backend
uvicorn app.main:app --host 0.0.0.0 --port 8000 --reloadcd frontend
npm install
npm start # Starts development server on http://localhost:3000# Install Ollama (see https://ollama.ai)
ollama pull mistral:7b
ollama serve-
Create Account
- Visit http://localhost:3000
- Click "Sign Up" and create your account
- Username: 3-20 characters (alphanumeric + underscore)
- Password: 8+ characters with letters and numbers
-
Take Your First Quiz
- New users start with a static assessment quiz
- This establishes your baseline English proficiency
- Results determine your starting level and unlock adaptive features
-
Explore Adaptive Learning
- After completing the first quiz, access advanced features:
- Adaptive Quizzes: AI-generated questions matching your level
- AI Teacher: Chat with Mistral for explanations and practice
- Progress Dashboard: Track your improvement over time
- Note: The static quiz is no longer available once you complete your first quiz to focus on personalized adaptive learning
- Purpose: Establish baseline proficiency and learning patterns
- Format: 4 curated questions covering Grammar and Vocabulary
- Scoring: Detailed feedback with explanations for each answer
- Access: Available to all authenticated users
- Unlocked: After completing the first static quiz
- AI-Generated: Questions created by Mistral based on your performance
- Dynamic Difficulty: Adjusts based on your success rate and learning progress
- Level Management: Automatic progression and retrocession between beginner, intermediate, and advanced levels
- Visual Feedback: Green indicators for level progression, red indicators for level retrocession
- Comprehensive Review: Detailed explanations and performance analysis
- Focused Learning: Static quiz becomes unavailable to encourage adaptive learning progression
- Conversational Learning: Natural language interaction with Mistral 7B
- Educational Focus: Responses tailored for English language learning
- Topics Covered: Grammar rules, vocabulary, pronunciation, and usage examples
- Teaching Style: Patient, encouraging responses with practical examples
- Performance Dashboard: Visual charts showing improvement over time
- Topic Breakdown: Detailed analysis of strengths and weaknesses
- Level Progression: Track advancement through proficiency levels
- Historical Data: Timeline of quiz scores and learning milestones
Create a .env file in the project root:
# MongoDB Configuration
MONGO_URI=mongodb://mongodb:27017/english_learning
MONGO_DB_NAME=english_learning
# Ollama AI Configuration
OLLAMA_BASE_URL=http://ollama:11434
OLLAMA_MODEL=mistral:7b
OLLAMA_TIMEOUT=240
OLLAMA_TEMPERATURE=0.7
OLLAMA_MAX_TOKENS=4000
# Learning System Configuration
LEVEL_UP_THRESHOLD=75
LEVEL_DOWN_THRESHOLD=50
MIN_QUIZZES_FOR_LEVEL_CHANGE=3
# Security Configuration
JWT_SECRET_KEY=your_super_secure_secret_key_here
SESSION_EXPIRE_DAYS=7
# Development Settings (optional)
DEBUG=false
LOG_LEVEL=INFOThe adaptive learning system can be fine-tuned through these parameters:
# In backend/app/config.py
class Config:
# Difficulty Adjustment
LEVEL_UP_THRESHOLD = 75 # Score needed to advance levels
LEVEL_DOWN_THRESHOLD = 50 # Score below which user may regress
MIN_QUIZZES_FOR_LEVEL_CHANGE = 3 # Minimum quizzes before level change
# AI Response Configuration
OLLAMA_TEMPERATURE = 0.7 # Creativity vs consistency (0.1-1.0)
OLLAMA_MAX_TOKENS = 4000 # Maximum response lengthThe platform leverages Mistral 7B, a state-of-the-art language model optimized for instruction following and educational interactions.
- Educational Focus: Excellent at providing clear, structured explanations
- Efficient: Optimized for local deployment with reasonable hardware requirements
- Multilingual: Strong English language capabilities with cultural awareness
- Instruction Following: Responds well to educational prompts and teaching scenarios
# Enhanced teacher prompt configuration
teacher_instructions = """You are a friendly and supportive English teacher.
Your role is to help students learn English effectively.
RESPONSE GUIDELINES:
- Keep paragraphs SHORT (2-3 sentences maximum)
- Use simple, clear language appropriate for English learners
- Be encouraging and patient
- Provide practical examples when explaining concepts
- Break complex topics into digestible pieces- Local Deployment: No external API dependencies
- Optimized Responses: Configured for educational content delivery
- Contextual Awareness: Maintains conversation history for coherent interactions
- Error Handling: Graceful fallbacks for model unavailability
The AI system generates contextually appropriate quiz questions:
# Adaptive quiz generation based on user performance
def generate_adaptive_quiz(user_level, weak_topics, question_count=5):
"""
Generate personalized quiz questions using Mistral
- Adjusts difficulty based on user_level
- Focuses on weak_topics for targeted improvement
- Provides detailed explanations for learning
"""{
_id: ObjectId,
username: String, // Unique username
password: String, // Hashed password with salt
email: String, // User email (optional)
english_level: String, // "beginner", "intermediate", "advanced"
total_quizzes: Number, // Total quizzes completed
average_score: Number, // Overall average score
has_completed_first_quiz: Boolean, // Unlocks adaptive features
created_at: Date,
last_login: Date,
progress: { // Topic-specific progress
Grammar: Number,
Vocabulary: Number,
Pronunciation: Number,
Tenses: Number
}
}{
_id: ObjectId,
user_id: String, // Reference to user
quiz_type: String, // "static" or "adaptive"
score: Number, // Quiz score (0-100)
topic: String, // Primary topic focus
difficulty: String, // Question difficulty level
questions: [ // Detailed question data
{
question: String,
options: [String],
correct_answer: String,
user_answer: String,
is_correct: Boolean,
explanation: String,
topic: String
}
],
topic_performance: { // Performance breakdown
Grammar: { correct: Number, total: Number },
Vocabulary: { correct: Number, total: Number }
},
timestamp: Date,
completion_time: Number // Time taken in seconds
}{
_id: ObjectId,
user_id: String, // Reference to user
token: String, // Session token (hashed)
username: String, // Cached username
created_at: Date,
expires_at: Date, // 7 days from creation
is_active: Boolean
}- Password Hashing: SHA256 with random salt generation
- Session Management: Secure token-based authentication with expiration
- Input Validation: Comprehensive validation for all user inputs
- SQL Injection Prevention: MongoDB's document structure provides natural protection
- Protected Routes: Authentication required for all learning features
- Rate Limiting: (Recommended for production deployment)
- CORS Configuration: Properly configured for frontend-backend communication
- Environment Secrets: Sensitive configuration stored in environment variables
- Password Security: Passwords never stored in plain text
- Session Isolation: User sessions are completely isolated
- Data Validation: All inputs validated before database storage
- Interactive Charts: Visual representation of score improvement over time
- Level Progression: Color-coded difficulty levels (Beginner, Intermediate, Advanced)
- Performance Trends: Identify learning patterns and improvement rates
// Example analytics data structure
{
topic_performance: {
Grammar: { percentage: 85, correct: 17, total: 20 },
Vocabulary: { percentage: 70, correct: 14, total: 20 },
Pronunciation: { percentage: 90, correct: 18, total: 20 },
Tenses: { percentage: 75, correct: 15, total: 20 }
}
}- Strength Identification: Highlight areas of excellence
- Improvement Opportunities: Focus areas needing attention
- Progress Velocity: Rate of improvement over time
- Comparative Analysis: Performance relative to level expectations
# Production deployment with optimized containers
docker-compose up -d
# Scale services as needed
docker-compose up -d --scale backend=2
# Monitor service health
docker-compose ps
docker-compose logs -f [service_name]# Development with hot reload
docker-compose -f docker-compose.dev.yml up -d
# Rebuild after dependency changes
docker-compose -f docker-compose.dev.yml up -d --buildββ nginx (reverse proxy) β port 80/443
ββ frontend (React) ββββββ port 3000
ββ backend (FastAPI) βββββ port 8000
ββ ollama (Mistral AI) βββ port 11434
ββ mongodb (database) ββββ port 27017
We welcome contributions to improve AISE - AI Second-language Educator!
-
Fork the Repository
git fork <repository-url> git clone <your-fork-url>
-
Create Feature Branch
git checkout -b feature/your-feature-name
-
Follow Code Standards
- Backend: Follow PEP 8 Python style guidelines
- Frontend: Use TypeScript and follow React best practices
- Documentation: Update README and inline comments
-
Testing & Quality Assurance
The project includes a comprehensive test suite covering all functionalities with 100% success rate:
# Run complete test suite with detailed reporting python test/run_all_tests.py # Run tests in Docker environment (recommended) docker exec -it english-learning-dev-backend python test/run_all_tests.py # Run specific test categories python test/test_authentication_system.py # User management tests python test/test_quiz_generation.py # Quiz system tests python test/test_quiz_evaluation.py # Quiz scoring & progression python test/test_chat_assistant.py # AI features tests python test/test_performance_analytics.py # Analytics tests python test/test_question_assistant.py # Q&A functionality python test/test_first_quiz_flag.py # Quiz completion tracking python test/test_reading_comprehension.py # Reading quiz functionality
π Complete Test Coverage (100% Success Rate):
- β Authentication System - User management, security, profile operations
- β Quiz Generation - Adaptive AI-powered quiz creation with smart fallbacks
- β Quiz Evaluation - Accurate scoring, average calculation, level progression
- β Performance Analytics - Consistent metrics across all endpoints
- β Chat Assistant - AI Teacher interactions and educational responses
- β Question Assistant - Q&A functionality validated for accuracy
- β First Quiz Flag - User onboarding and progress tracking
- β Reading Comprehension - Passage-based quiz functionality
Advanced Test Features:
- π Comprehensive Reporting: Success rates, performance metrics, failure analysis
- π§Ή Automatic Cleanup: Test data isolation and environment protection
- π‘οΈ Security Testing: Authentication, authorization, and input validation
- β‘ Performance Monitoring: Timing analysis and bottleneck identification
- π§ Smart Diagnostics: Detailed failure analysis with troubleshooting recommendations
- π― Edge Case Coverage: Invalid inputs, network errors, AI service failures
Test Environment Features:
- Isolated Test Users: Prevents interference with production data
- AI Model Validation: Ensures Ollama/Mistral integration is operational
- Database Consistency: Verifies data integrity across all operations
- Error Recovery Testing: Validates fallback systems and error handling
See
test/README.mdfor detailed documentation and usage instructions.
π ALL TESTS PASSING: 100% Success Rate (8/8 Test Suites)
β Authentication System (0.2s)
- User registration with comprehensive validation
- Secure login/logout with session management
- Profile management and security features
- Password changes and account operations
β Quiz Generation (42.9s)
- AI-powered adaptive quiz creation for all topics (Grammar, Vocabulary, Reading, Mixed)
- Smart fallback system ensures continuous quiz availability
- Topic validation and difficulty level management
- Ollama/Mistral AI model integration and health monitoring
- Question uniqueness and variety optimization
β Quiz Evaluation (0.1s)
- Accurate answer validation and scoring calculations
- Fixed: Average score calculation and persistence across sessions
- Level progression tracking (beginner β intermediate β advanced)
- Topic-specific performance analytics and progress tracking
β Chat Assistant (18.1s)
- AI Teacher chat interactions with educational focus
- Mistral 7B integration for conversational learning
- Context-aware responses and learning assistance
- Educational content generation and validation
β Performance Analytics (0.1s)
- Fixed: Data consistency between profile and performance endpoints
- User progress calculations and historical tracking
- Visual analytics data preparation for dashboards
- Cross-endpoint metric synchronization and validation
β Question Assistant (0.0s)
- AI-powered Q&A functionality for learning support
- Educational content generation and validation
- Response validation and answer quality assurance
β First Quiz Flag (5.0s)
- User onboarding completion tracking
- Quiz milestone detection and progress markers
- Database state management for user progression
- Initial assessment and baseline establishment
β Reading Comprehension (11.1s)
- Passage-based quiz generation and validation
- Reading skill assessment across difficulty levels
- Comprehension question variety and quality control
- Text analysis and educational content verification
System Performance Insights:
- Fastest Component: Question Assistant (instant response)
- Most Resource-Intensive: Quiz Generation (42.9s for AI processing)
- Overall Test Duration: 77.5 seconds for complete system validation
- Reliability Score: 100% - All critical functionality operational
Recent Major Fixes & Achievements:
- π§ Fixed Quiz Evaluation: Resolved average score calculation persistence issue
- π§ Fixed Performance Analytics: Achieved data consistency across all endpoints
- π§ Enhanced Quiz Generation: Improved AI validation with robust fallback system
- π§ Optimized Question Assistant: Enhanced Q&A validation and educational content quality
- π Production Ready: All systems validated and operating at optimal performance
Quality Assurance Highlights:
- Zero Critical Bugs: All major functionality thoroughly tested and validated
- Robust Error Handling: Comprehensive fallback systems for AI and network failures
- Data Integrity: Consistent metrics and calculations across all system components
- Security Validated: Authentication, authorization, and input validation confirmed
- Performance Optimized: Efficient resource utilization with smart caching strategies
- Educational Content: Additional quiz questions and learning materials
- AI Improvements: Enhanced prompt engineering for better educational responses
- Analytics: Advanced learning analytics and visualization
- Mobile Support: React Native mobile application
- Internationalization: Support for additional languages
- Accessibility: WCAG compliance improvements
This project is licensed under the MIT License - see the LICENSE file for details.
- Mistral 7B: Apache 2.0 License
- React: MIT License
- FastAPI: MIT License
- MongoDB: Server Side Public License (SSPL)
- Issues: GitHub Issues
- Discussions: GitHub Discussions
- Documentation: This README and inline code documentation
- Developer: [Luib01, KaminariManu]
Ready to start your English learning journey with AI? π
Get started by running docker-compose up -d and visit http://localhost:3000!