A comprehensive, production-ready fitness tracking application built with Django, featuring ML-powered recommendations, real-time data processing, and microservices architecture.
- User Management: Registration, authentication, and comprehensive profiles
- Nutrition Tracking: Meal logging with detailed nutritional information
- Workout Tracking: Exercise logging with calorie burn calculations
- Goal Setting: Personalized fitness goals and progress tracking
- Dashboard: Real-time analytics and progress visualization
- π€ ML-Powered Recommendations: AI-driven meal and workout suggestions
- π Real-time Analytics: Live data processing with Apache Kafka
- β‘ High Performance: Redis caching and optimized database queries
- π³ Containerized: Full Docker and Kubernetes deployment
- π§ Microservices: Go-based data processing service
- π Monitoring: Prometheus and Grafana integration
- Backend: Django 5.2.5 with Django REST Framework
- Database: PostgreSQL with advanced query optimization
- Cache: Redis for session management and performance
- Message Queue: Apache Kafka for real-time data streaming
- ML Engine: Scikit-learn with collaborative filtering
- Microservices: Go for data processing
- Containerization: Docker with multi-stage builds
- Orchestration: Kubernetes with auto-scaling
- Monitoring: Prometheus + Grafana
- Frontend: Bootstrap 5 with AJAX and real-time updates
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β Django Web β β Go Service β β ML Engine β
β Application βββββΊβ Data Processor βββββΊβ Recommendationsβ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β β β
βΌ βΌ βΌ
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
β PostgreSQL β β Apache Kafka β β Redis β
β Database β β Message Queue β β Cache β
βββββββββββββββββββ βββββββββββββββββββ βββββββββββββββββββ
- Python 3.11+
- Go 1.21+
- Docker & Docker Compose
- Kubernetes cluster (for production)
# Clone the repository
git clone https://github.com/yourusername/wanna-fit.git
cd wanna-fit
# Start all services
docker-compose up -d
# Run migrations and train ML models
docker-compose exec web python manage.py migrate
docker-compose exec web python manage.py train_ml_model
# Access the application
open http://localhost:8000# Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate
# Install dependencies
pip install -r requirements.txt
# Setup environment variables
cp .env.example .env
# Edit .env with your database credentials
# Run migrations
python manage.py migrate
# Create superuser
python manage.py createsuperuser
# Train ML models
python manage.py train_ml_model
# Start development server
python manage.py runserver# Apply Kubernetes configurations
kubectl apply -f k8s/namespace.yaml
kubectl apply -f k8s/configmap.yaml
kubectl apply -f k8s/secret.yaml
kubectl apply -f k8s/postgres.yaml
kubectl apply -f k8s/redis.yaml
kubectl apply -f k8s/django-app.yaml
# Check deployment status
kubectl get pods -n wanna-fitThe ML-powered recommendation system uses multiple approaches:
- Collaborative Filtering: Matrix factorization to find similar users
- Content-Based Filtering: Feature similarity matching
- Hybrid Approach: Combines both methods for optimal results
# Train all ML models
python manage.py train_ml_model --model-type all --verbose
# Generate recommendations for all users
python manage.py generate_recommendations --recommendation-type all
# Retrain models with new data
python manage.py train_ml_model --force-retrain# Get personalized food recommendations
GET /api/recommendations/food_recommendations/
# Get personalized workout recommendations
GET /api/recommendations/workout_recommendations/
# Generate intelligent meal plan
GET /api/recommendations/meal_plan/
# Provide feedback on recommendations
POST /api/recommendations/{id}/provide_feedback/- Apache Kafka: Streams user interactions in real-time
- Go Microservice: Processes events and generates analytics
- Redis Caching: Stores frequently accessed data
- Database Optimization: Complex queries with proper indexing
- Prometheus: Metrics collection and alerting
- Grafana: Visualization dashboards
- Health Checks: Automated service monitoring
- Auto-scaling: Kubernetes HPA based on metrics
POST /api/accounts/register/ # User registration
POST /api/accounts/login/ # User login
GET /api/accounts/profile/ # Get user profile
PUT /api/accounts/profile/ # Update user profileGET /api/nutrition/meals/ # List meals
POST /api/nutrition/meals/ # Create meal
GET /api/nutrition/meals/{id}/ # Get meal details
PUT /api/nutrition/meals/{id}/ # Update meal
DELETE /api/nutrition/meals/{id}/ # Delete mealGET /api/workouts/logs/ # List workout logs
POST /api/workouts/logs/ # Create workout log
GET /api/workouts/logs/{id}/ # Get workout details
PUT /api/workouts/logs/{id}/ # Update workout log
DELETE /api/workouts/logs/{id}/ # Delete workout logGET /api/recommendations/food_recommendations/ # Food recommendations
GET /api/recommendations/workout_recommendations/ # Workout recommendations
GET /api/recommendations/meal_plan/ # Intelligent meal plan
POST /api/recommendations/{id}/provide_feedback/ # Recommendation feedback# Run all tests
python manage.py test
# Run specific app tests
python manage.py test recommendations
# Run with coverage
coverage run --source='.' manage.py test
coverage report
coverage html# Install locust
pip install locust
# Run load tests
locust -f tests/load_test.py --host=http://localhost:8000- Query Optimization: Complex queries with proper joins
- Indexing: Strategic database indexes for performance
- Connection Pooling: Efficient database connections
- Caching: Redis for frequently accessed data
- AJAX: Asynchronous data loading
- Pagination: Efficient data pagination
- Lazy Loading: On-demand content loading
- CDN: Static file delivery optimization
- Authentication: Django's built-in auth system
- CSRF Protection: Cross-site request forgery protection
- SQL Injection Prevention: ORM-based queries
- XSS Protection: Template auto-escaping
- Rate Limiting: API rate limiting
- HTTPS: SSL/TLS encryption
- Bootstrap 5: Responsive design framework
- Mobile-First: Optimized for mobile devices
- Touch-Friendly: Mobile-optimized interactions
- Progressive Web App: PWA capabilities
# Build production image
docker build -t wanna-fit:latest .
# Deploy to Kubernetes
kubectl apply -f k8s/
# Monitor deployment
kubectl get pods -n wanna-fit
kubectl logs -f deployment/wanna-fit-web -n wanna-fit# Database
DB_HOST=localhost
DB_NAME=wanna_fit
DB_USER=postgres
DB_PASSWORD=your_password
# Redis
REDIS_URL=redis://localhost:6379/0
# Kafka
KAFKA_BOOTSTRAP_SERVERS=localhost:9092
# Django
SECRET_KEY=your_secret_key
DEBUG=False
ALLOWED_HOSTS=your_domain.com- Application Metrics: Request rates, response times
- Business Metrics: User engagement, recommendation accuracy
- Infrastructure Metrics: CPU, memory, disk usage
- Custom Metrics: ML model performance
- Structured Logging: JSON-formatted logs
- Log Levels: DEBUG, INFO, WARNING, ERROR
- Log Aggregation: Centralized log collection
- Alerting: Automated error notifications
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Django community for the excellent framework
- Scikit-learn team for ML capabilities
- Docker and Kubernetes communities
- All contributors and testers
For support, email support@wannafit.com or join our Slack channel.
Built with β€οΈ for fitness enthusiasts worldwide