Enterprise-grade Python learning platform showcasing production-ready development practices, comprehensive testing strategies, and modern cloud-native deployment.
Python Mastery Hub is an interactive learning platform that demonstrates advanced software engineering practices while delivering a comprehensive Python education experience. Built with scalable microservices architecture, security-first design principles, and professional CI/CD pipelines.
- Features
- Architecture
- Quick Start
- Learning Modules
- Technology Stack
- Development
- Deployment
- Security
- Performance
- Monitoring
- API Documentation
- Contributing
- License
- 9 Structured Learning Modules: From Python basics to advanced web development and data science
- Interactive Code Execution: Safe, sandboxed environment with real-time feedback
- Multi-Interface Access: Rich CLI, responsive web application, and comprehensive REST API
- Progress Analytics: Detailed tracking with achievements, streaks, and personalized recommendations
- AI-Powered Code Review: Intelligent feedback on code submissions with improvement suggestions
- Adaptive Learning Paths: Personalized curriculum based on skill level and learning objectives
- Microservices Design: Scalable FastAPI backend with async/await patterns
- Cloud-Native Deployment: Kubernetes-ready with Terraform infrastructure automation
- Comprehensive Security: Multi-layer scanning, RBAC, and secure code execution environments
- Observability Stack: Prometheus metrics, Grafana dashboards, and ELK logging
- High Availability: Redis clustering, database replication, and auto-scaling capabilities
- 95%+ Test Coverage: Unit, integration, E2E, and performance testing
- Automated Quality Gates: Pre-commit hooks, security scanning, and dependency auditing
- Documentation-First: Auto-generated API docs, interactive notebooks, and comprehensive guides
- Container-First Development: Docker development environment with hot reloading
graph TB
subgraph "Client Layer"
CLI[Rich CLI Interface]
WEB[React Web App]
API_CLIENT[API Clients]
end
subgraph "Load Balancing"
LB[Nginx Load Balancer]
end
subgraph "Application Layer"
FASTAPI[FastAPI Application]
AUTH[Authentication Service]
EXECUTOR[Code Execution Engine]
PROGRESS[Progress Service]
end
subgraph "Message Queue"
CELERY[Celery Workers]
REDIS_MQ[Redis Message Broker]
end
subgraph "Data Layer"
POSTGRES[(PostgreSQL)]
REDIS[(Redis Cache)]
S3[(AWS S3 Storage)]
end
subgraph "Monitoring"
PROMETHEUS[Prometheus]
GRAFANA[Grafana]
ELK[ELK Stack]
end
CLI --> LB
WEB --> LB
API_CLIENT --> LB
LB --> FASTAPI
FASTAPI --> AUTH
FASTAPI --> EXECUTOR
FASTAPI --> PROGRESS
FASTAPI --> CELERY
CELERY --> REDIS_MQ
FASTAPI --> POSTGRES
FASTAPI --> REDIS
FASTAPI --> S3
FASTAPI --> PROMETHEUS
PROMETHEUS --> GRAFANA
FASTAPI --> ELK
- Modular Architecture: Each learning module is independently deployable
- Exercise Framework: Automated testing and validation system
- Progress Tracking: Real-time analytics with streak tracking
- Content Management: Version-controlled curriculum with A/B testing support
- FastAPI Backend: High-performance async API with OpenAPI 3.0 specification
- WebSocket Integration: Real-time code execution and collaborative features
- Security Middleware: Rate limiting, CORS handling, and request validation
- Responsive Frontend: Mobile-first design with accessibility compliance
- Rich Terminal Experience: Syntax highlighting and interactive prompts
- Offline Capabilities: Full functionality without internet connectivity
- Cross-Platform Support: Windows, macOS, and Linux compatibility
- Plugin Architecture: Extensible command system
- Python 3.11 or higher
- Poetry (recommended for dependency management)
- Docker (optional, for containerized development)
- Node.js 18+ (for frontend development)
# Clone the repository
git clone https://github.com/SatvikPraveen/Python-Mastery-Hub.git
cd Python-Mastery-Hub
# Install dependencies
poetry install --with dev
# Setup pre-commit hooks
poetry run pre-commit install
# Start the development environment
make dev
# Access the application
# CLI: poetry run python-mastery-hub
# Web: http://localhost:8000
# API Docs: http://localhost:8000/docs
# Clone and start with Docker Compose
git clone https://github.com/SatvikPraveen/Python-Mastery-Hub.git
cd Python-Mastery-Hub
# Start full development stack
docker-compose up -d
# Access services:
# Web App: http://localhost:8000
# API: http://localhost:8000/api
# Grafana: http://localhost:3000 (admin/admin)
# Prometheus: http://localhost:9090
# Install from PyPI (when published)
pip install python-mastery-hub
# Launch CLI
python-mastery-hub --help
# Start web server
pmh-web --host 0.0.0.0 --port 8000
# Run health checks
curl http://localhost:8000/health
# Test CLI functionality
poetry run python-mastery-hub list
# Run example exercise
poetry run python-mastery-hub practice basics --exercise variables
Each module follows a pedagogically-sound structure designed for progressive skill building:
- Conceptual Introduction: Core theory with practical context
- Interactive Demonstrations: Live code examples with explanations
- Guided Exercises: Step-by-step challenges with hints
- Independent Practice: Complex problems requiring synthesis
- Real-world Applications: Industry-relevant project scenarios
Module | Level | Duration | Exercises | Key Topics |
---|---|---|---|---|
Python Basics | Beginner | 8-10 hours | 15 | Variables, data types, control flow, functions, error handling |
Object-Oriented Programming | Intermediate | 12-15 hours | 12 | Classes, inheritance, polymorphism, design patterns, SOLID principles |
Advanced Python | Advanced | 15-20 hours | 10 | Decorators, generators, context managers, metaclasses, descriptors |
Data Structures | Intermediate | 10-12 hours | 14 | Built-in collections, custom implementations, complexity analysis |
Algorithms | Advanced | 20-25 hours | 16 | Sorting, searching, dynamic programming, graph algorithms |
Async Programming | Advanced | 15-18 hours | 11 | asyncio, concurrency patterns, threading, multiprocessing |
Web Development | Intermediate | 18-22 hours | 13 | FastAPI, REST APIs, WebSockets, database integration, authentication |
Data Science | Intermediate | 20-25 hours | 18 | NumPy, Pandas, Matplotlib, scikit-learn, statistical analysis |
Testing & Quality | Intermediate | 12-15 hours | 15 | pytest, mocking, TDD, property-based testing, CI/CD integration |
- Adaptive Difficulty: Exercises adjust based on performance
- Code Review Integration: AI-powered feedback with improvement suggestions
- Peer Learning: Community features for code sharing and discussion
- Certification Tracking: Progress verification and skill validation
Category | Technologies |
---|---|
Core Framework | FastAPI, Uvicorn, Gunicorn |
Database | PostgreSQL 15+, SQLAlchemy 2.0, Alembic |
Caching & Queue | Redis 7+, Celery, aioredis |
Authentication | JWT, OAuth 2.0, passlib, python-jose |
API Documentation | OpenAPI 3.0, Swagger UI, ReDoc |
Category | Technologies |
---|---|
Dependency Management | Poetry, pip-tools |
Code Quality | Black, isort, flake8, mypy, pylint |
Testing | pytest, pytest-asyncio, factory-boy, faker |
Security Scanning | Bandit, Safety, Semgrep, CodeQL |
Pre-commit Hooks | pre-commit, various quality tools |
Category | Technologies |
---|---|
Web Frontend | HTML5, CSS3, Modern JavaScript |
CLI Interface | Typer, Rich, Click |
Templates | Jinja2 with responsive design |
Code Editor | CodeMirror integration |
Category | Technologies |
---|---|
Scientific Computing | NumPy, SciPy, scikit-learn |
Data Manipulation | Pandas, Polars (planned) |
Visualization | Matplotlib, Seaborn, Plotly |
Jupyter Integration | JupyterLab, notebook widgets |
Category | Technologies |
---|---|
Containerization | Docker, Docker Compose |
Orchestration | Kubernetes, Helm |
Infrastructure as Code | Terraform, Ansible |
CI/CD | GitHub Actions, automated testing |
Monitoring | Prometheus, Grafana, ELK Stack |
Cloud Platforms | AWS, GCP support planned |
# Complete development setup
make setup-dev
# Or step by step:
poetry install --with dev
poetry run pre-commit install
cp .env.example .env
make migrate-db
make seed-data
# Code quality checks
make lint # Run all linters
make format # Auto-format code
make type-check # Type checking with mypy
make security-scan # Security vulnerability scanning
# Testing
make test # Full test suite
make test-unit # Unit tests only
make test-integration # Integration tests
make test-e2e # End-to-end tests
make test-performance # Performance benchmarks
make coverage # Generate coverage report
# Development servers
make dev # Start development stack
make dev-web # Web server only
make dev-cli # CLI development mode
make docs-serve # Documentation server
- Unit Tests: 90%+ coverage requirement
- Integration Tests: API endpoint and service testing
- End-to-End Tests: Complete user journey validation
- Performance Tests: Load testing and benchmarking
- Property-Based Testing: Hypothesis for edge case discovery
- Formatting: Black with 88-character line length
- Import Organization: isort with black-compatible settings
- Type Annotations: Comprehensive typing with mypy strict mode
- Documentation: Docstrings for all public APIs using Google style
- Naming Conventions: PEP 8 compliance with descriptive names
- Repository Pattern: Data access abstraction
- Service Layer: Business logic encapsulation
- Factory Pattern: Object creation management
- Observer Pattern: Event-driven components
- Strategy Pattern: Algorithm selection (learning paths)
- Async/Await: Non-blocking I/O throughout
- Connection Pooling: Database and Redis connections
- Caching Strategy: Multi-layer caching (Redis, application, CDN)
- Lazy Loading: On-demand module and resource loading
- Database Optimization: Query optimization and indexing strategy
# Deploy to Kubernetes cluster
kubectl apply -f deployment/kubernetes/namespace.yaml
kubectl apply -f deployment/kubernetes/configmap.yaml
kubectl apply -f deployment/kubernetes/deployment.yaml
kubectl apply -f deployment/kubernetes/service.yaml
kubectl apply -f deployment/kubernetes/ingress.yaml
# Verify deployment
kubectl get pods -n python-mastery-hub
kubectl logs -f deployment/python-mastery-hub-web -n python-mastery-hub
# Initialize Terraform
cd deployment/terraform
terraform init
# Plan infrastructure
terraform plan -var-file="production.tfvars"
# Deploy infrastructure
terraform apply -var-file="production.tfvars"
# Get outputs
terraform output app_url
# Production deployment with Docker Compose
docker-compose -f docker-compose.yml -f docker-compose.prod.yml up -d
# Scale services
docker-compose up --scale web=3 --scale worker=2 --scale db-replica=2
# Monitor services
docker-compose logs -f web
# Application Configuration
ENVIRONMENT=production
SECRET_KEY=your-256-bit-secret-key
DEBUG=false
LOG_LEVEL=INFO
# Database Configuration
DATABASE_URL=postgresql://user:password@host:5432/python_mastery_hub
DATABASE_POOL_SIZE=20
DATABASE_MAX_OVERFLOW=10
# Redis Configuration
REDIS_URL=redis://host:6379/0
REDIS_CLUSTER_NODES=host1:6379,host2:6379,host3:6379
# Security Configuration
JWT_SECRET_KEY=your-jwt-secret
JWT_ALGORITHM=HS256
JWT_ACCESS_TOKEN_EXPIRE_MINUTES=30
JWT_REFRESH_TOKEN_EXPIRE_DAYS=30
# External Services
SENTRY_DSN=https://your-sentry-dsn
AWS_ACCESS_KEY_ID=your-access-key
AWS_SECRET_ACCESS_KEY=your-secret-key
AWS_S3_BUCKET=your-bucket-name
# Monitoring
PROMETHEUS_ENABLED=true
GRAFANA_ADMIN_PASSWORD=secure-password
# Performance
UVICORN_WORKERS=4
CELERY_WORKERS=8
REDIS_MAX_CONNECTIONS=100
# Features
ENABLE_RATE_LIMITING=true
ENABLE_CORS=true
ENABLE_WEBSOCKETS=true
-
Network Security
- TLS 1.3 encryption for all traffic
- CORS policy enforcement
- Rate limiting and DDoS protection
- IP whitelisting for admin functions
-
Application Security
- Input validation and sanitization
- SQL injection prevention with parameterized queries
- XSS protection with content security policy
- CSRF token validation
-
Authentication & Authorization
- JWT-based authentication with refresh tokens
- Role-based access control (RBAC)
- Multi-factor authentication support
- Session management with secure cookies
-
Code Execution Security
- Sandboxed execution environment with Docker
- Resource limits (CPU, memory, time)
- Filesystem isolation
- Network access restrictions
# Run comprehensive security tests
make security-test
# Individual security scans
poetry run bandit -r src/ # Code security analysis
poetry run safety check # Dependency vulnerabilities
poetry run semgrep --config=auto src/ # Static analysis
docker run --rm -v "$PWD":/app returntocorp/semgrep
# Container security scanning
docker run --rm -v /var/run/docker.sock:/var/run/docker.sock \
-v $PWD:/app aquasec/trivy image python-mastery-hub:latest
# Infrastructure security
checkov -f deployment/terraform/
- GDPR Compliance: Data anonymization and right-to-deletion
- SOC 2 Type II: Audit logging and access controls
- OWASP Guidelines: Top 10 vulnerability prevention
- Container Security: CIS benchmark compliance
Metric | Target | Achieved |
---|---|---|
API Response Time (95th percentile) | <200ms | 150ms |
Database Query Time (average) | <50ms | 35ms |
Code Execution Time (simple) | <2s | 1.2s |
Memory Usage (baseline) | <512MB | 380MB |
Concurrent Users | 1000+ | 1500+ |
Startup Time | <30s | 22s |
- Connection Pooling: SQLAlchemy with asyncpg
- Query Optimization: Selective loading and joins
- Indexing Strategy: Covering indexes for common queries
- Read Replicas: Separate read/write database instances
- Application Layer: In-memory caching with TTL
- Database Layer: Redis for session and query caching
- CDN Layer: CloudFront for static assets
- Browser Caching: Optimized cache headers
- Non-blocking I/O: FastAPI with async/await
- Concurrent Request Handling: 1000+ concurrent connections
- Resource Efficiency: Lower memory footprint per request
- Scalability: Horizontal scaling capabilities
# Run performance test suite
make performance-test
# Load testing with Locust
poetry run locust -f tests/performance/locustfile.py \
--host http://localhost:8000 \
--users 100 \
--spawn-rate 10 \
--run-time 5m
# Database performance testing
poetry run python tests/performance/db_benchmarks.py
# Memory profiling
poetry run python -m memory_profiler scripts/profile_memory.py
graph TB
subgraph "Application Metrics"
APP[FastAPI App]
PROM_CLIENT[Prometheus Client]
end
subgraph "Infrastructure Metrics"
NODE_EXPORTER[Node Exporter]
POSTGRES_EXPORTER[Postgres Exporter]
REDIS_EXPORTER[Redis Exporter]
end
subgraph "Logging Pipeline"
FILEBEAT[Filebeat]
LOGSTASH[Logstash]
ELASTICSEARCH[Elasticsearch]
end
subgraph "Monitoring Backend"
PROMETHEUS[Prometheus]
GRAFANA[Grafana]
ALERTMANAGER[Alertmanager]
end
APP --> PROM_CLIENT
PROM_CLIENT --> PROMETHEUS
NODE_EXPORTER --> PROMETHEUS
POSTGRES_EXPORTER --> PROMETHEUS
REDIS_EXPORTER --> PROMETHEUS
APP --> FILEBEAT
FILEBEAT --> LOGSTASH
LOGSTASH --> ELASTICSEARCH
PROMETHEUS --> GRAFANA
PROMETHEUS --> ALERTMANAGER
ELASTICSEARCH --> GRAFANA
- Request Metrics: Latency, throughput, error rates
- Business Metrics: User registrations, exercise completions, learning progress
- Code Execution: Success rates, execution times, resource usage
- Authentication: Login attempts, token refresh rates, security events
- System Resources: CPU, memory, disk usage, network I/O
- Database Performance: Connection pool usage, query performance, replication lag
- Cache Performance: Hit ratios, memory usage, eviction rates
- Container Metrics: Resource utilization, restart counts, health checks
# Example alert rules (monitoring/prometheus/rules/application.yml)
groups:
- name: application
rules:
- alert: HighErrorRate
expr: rate(http_requests_total{status=~"5.."}[5m]) > 0.1
for: 2m
labels:
severity: critical
annotations:
summary: High error rate detected
- alert: DatabaseConnectionPool
expr: sqlalchemy_pool_checked_out / sqlalchemy_pool_size > 0.8
for: 5m
labels:
severity: warning
annotations:
summary: Database connection pool utilization high
# Basic health check
curl http://localhost:8000/health
# Response: {"status": "healthy", "timestamp": "2025-01-01T12:00:00Z"}
# Detailed health check
curl http://localhost:8000/health/detailed
# Response: {
# "status": "healthy",
# "checks": {
# "database": "healthy",
# "redis": "healthy",
# "celery": "healthy"
# },
# "version": "1.0.0",
# "uptime": 3600
# }
# Component-specific checks
curl http://localhost:8000/health/database
curl http://localhost:8000/health/redis
curl http://localhost:8000/health/celery
The API follows OpenAPI 3.0 specification with comprehensive documentation:
- Interactive Documentation: http://localhost:8000/docs (Swagger UI)
- Alternative Documentation: http://localhost:8000/redoc (ReDoc)
- OpenAPI Schema: http://localhost:8000/openapi.json
POST /api/auth/register # User registration
POST /api/auth/login # User login
POST /api/auth/refresh # Token refresh
POST /api/auth/logout # User logout
GET /api/auth/profile # User profile
PUT /api/auth/profile # Update profile
GET /api/modules # List all modules
GET /api/modules/{module} # Get module details
GET /api/modules/{module}/topics/{topic} # Get topic content
POST /api/modules/{module}/exercises/{exercise}/submit # Submit solution
GET /api/learning-path # Get personalized learning path
POST /api/execute # Execute code safely
GET /api/execute/{execution_id} # Get execution result
POST /api/validate # Validate code syntax
GET /api/progress # User progress overview
GET /api/progress/{module} # Module-specific progress
POST /api/progress/achievement # Record achievement
GET /api/leaderboard # Global leaderboard
import httpx
from typing import Dict, Any
class PythonMasteryClient:
def __init__(self, base_url: str, token: str = None):
self.base_url = base_url
self.headers = {"Authorization": f"Bearer {token}"} if token else {}
async def get_modules(self) -> Dict[str, Any]:
async with httpx.AsyncClient() as client:
response = await client.get(
f"{self.base_url}/api/modules",
headers=self.headers
)
return response.json()
async def execute_code(self, code: str) -> Dict[str, Any]:
async with httpx.AsyncClient() as client:
response = await client.post(
f"{self.base_url}/api/execute",
json={"code": code},
headers=self.headers
)
return response.json()
# Usage example
client = PythonMasteryClient("http://localhost:8000", token="your-jwt-token")
modules = await client.get_modules()
result = await client.execute_code("print('Hello, World!')")
# Get all modules
curl -X GET "http://localhost:8000/api/modules" \
-H "Authorization: Bearer YOUR_TOKEN"
# Execute code
curl -X POST "http://localhost:8000/api/execute" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{"code": "print(\"Hello, World!\")", "timeout": 5}'
# Submit exercise solution
curl -X POST "http://localhost:8000/api/modules/basics/exercises/variables/submit" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_TOKEN" \
-d '{"code": "name = \"Python\"\nprint(f\"Hello, {name}!\")"}'
We welcome contributions from the community! Please read our CONTRIBUTING.md for detailed guidelines.
- Fork the repository on GitHub
- Clone your fork locally
- Create a feature branch from
main
- Make your changes with comprehensive tests
- Run quality checks (
make check-all
) - Submit a pull request with detailed description
# Setup development environment
git clone https://github.com/SatvikPraveen/Python-Mastery-Hub.git
cd Python-Mastery-Hub
make setup-dev
# Create feature branch
git checkout -b feature/your-feature-name
# Make changes and test
make test
make lint
make security-scan
# Commit with conventional commit format
git commit -m "feat: add new learning module for machine learning"
# Push and create PR
git push origin feature/your-feature-name
- Automated Checks: All PRs run through CI/CD pipeline
- Security Review: Automated security scanning on all changes
- Performance Review: Performance impact assessment for significant changes
- Documentation: All public APIs must be documented
- Testing: New features require comprehensive test coverage
- Bug Fixes: Issue resolution and stability improvements
- New Features: Learning modules, exercises, and platform capabilities
- Documentation: Improvements to guides, API docs, and examples
- Performance: Optimization and scalability improvements
- Security: Security enhancements and vulnerability fixes
- Infrastructure: DevOps and deployment improvements
- GitHub Discussions: Ask questions and share ideas
- Issues: Report bugs and request features
- Discord: Join our developer community
Focus: Core platform functionality and production readiness
- Enhanced Web Interface: Improved mobile responsiveness and accessibility
- Code Collaboration: Pair programming and code sharing features
- Advanced Analytics: Detailed learning analytics and insights
- Plugin System: Extensible architecture for custom modules
- Machine Learning Integration: AI-powered personalized learning paths
- Video Content: Interactive video tutorials and explanations
- Social Learning: Community features and peer learning
- API Expansion: GraphQL API and advanced filtering
- Instructor Dashboard: Content creation and management tools
- Certification System: Skill verification and digital badges
- Enterprise Features: SSO, team management, and reporting
- Mobile Applications: Native iOS and Android apps
- Multi-language Support: Expand beyond Python to other languages
- VR/AR Integration: Immersive learning experiences
- AI Teaching Assistant: Intelligent tutoring and support
- Global Marketplace: Community-contributed content ecosystem
This project is licensed under the MIT License - see the LICENSE file for details.
The MIT License was chosen to encourage:
- Open Source Contribution: Maximum compatibility with other projects
- Commercial Use: Freedom for commercial applications and modifications
- Educational Use: Unrestricted use in educational institutions
- Community Growth: Encouraging forks, modifications, and contributions
This project builds upon the excellent work of the Python community:
- FastAPI: For the high-performance web framework
- SQLAlchemy: For the powerful ORM and database toolkit
- Redis: For efficient caching and message queuing
- PostgreSQL: For reliable and scalable data storage
- Docker: For containerization and deployment consistency
- Kubernetes: For container orchestration and scaling
- Python Software Foundation: For advancing Python education
- Real Python: For excellent Python learning resources
- Python.org Tutorial: For foundational learning structure
- Django Girls: For inclusive programming education approaches
Special thanks to all contributors who have helped build and improve this platform. See CONTRIBUTORS.md for the complete list.
- Documentation: Comprehensive guides at docs.python-mastery-hub.dev
- GitHub Issues: Technical issues and bug reports
- GitHub Discussions: Questions and community support
- Discord Community: Real-time chat and support
For enterprise deployments, training, and custom development:
- Email: [email protected]
- Consulting: Available for implementation and customization
- Training: Corporate Python training programs
Do not create public GitHub issues for security vulnerabilities.
Built with ❤️ for the Python community by developers who believe in the power of quality education and open source collaboration.