Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Wanna Fit - Advanced Fitness Tracking Platform

A comprehensive, production-ready fitness tracking application built with Django, featuring ML-powered recommendations, real-time data processing, and microservices architecture.

πŸš€ Key Features

Core Functionality

  • 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

Advanced Features

  • πŸ€– 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

πŸ—οΈ Architecture

Technology Stack

  • 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

System Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   Django Web    β”‚    β”‚   Go Service    β”‚    β”‚   ML Engine     β”‚
β”‚   Application   │◄──►│  Data Processor │◄──►│  Recommendationsβ”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
         β”‚                       β”‚                       β”‚
         β–Ό                       β–Ό                       β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”    β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚   PostgreSQL    β”‚    β”‚   Apache Kafka  β”‚    β”‚     Redis       β”‚
β”‚    Database     β”‚    β”‚  Message Queue  β”‚    β”‚     Cache       β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜    β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ› οΈ Installation & Setup

Prerequisites

  • Python 3.11+
  • Go 1.21+
  • Docker & Docker Compose
  • Kubernetes cluster (for production)

Quick Start with Docker

# 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

Development Setup

# 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

Kubernetes Deployment

# 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-fit

πŸ€– Machine Learning Features

Recommendation Engine

The ML-powered recommendation system uses multiple approaches:

  1. Collaborative Filtering: Matrix factorization to find similar users
  2. Content-Based Filtering: Feature similarity matching
  3. Hybrid Approach: Combines both methods for optimal results

Training the Models

# 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

API Endpoints

# 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/

πŸ“Š Advanced Analytics

Real-time Data Processing

  • 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

Performance Monitoring

  • Prometheus: Metrics collection and alerting
  • Grafana: Visualization dashboards
  • Health Checks: Automated service monitoring
  • Auto-scaling: Kubernetes HPA based on metrics

πŸ”§ API Documentation

REST API Endpoints

User Management

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 profile

Nutrition Tracking

GET    /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 meal

Workout Tracking

GET    /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 log

ML Recommendations

GET  /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

πŸ§ͺ Testing

Running Tests

# 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

Load Testing

# Install locust
pip install locust

# Run load tests
locust -f tests/load_test.py --host=http://localhost:8000

πŸ“ˆ Performance Optimization

Database Optimization

  • Query Optimization: Complex queries with proper joins
  • Indexing: Strategic database indexes for performance
  • Connection Pooling: Efficient database connections
  • Caching: Redis for frequently accessed data

Frontend Optimization

  • AJAX: Asynchronous data loading
  • Pagination: Efficient data pagination
  • Lazy Loading: On-demand content loading
  • CDN: Static file delivery optimization

πŸ”’ Security Features

  • 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

πŸ“± Mobile Responsiveness

  • Bootstrap 5: Responsive design framework
  • Mobile-First: Optimized for mobile devices
  • Touch-Friendly: Mobile-optimized interactions
  • Progressive Web App: PWA capabilities

πŸš€ Deployment

Production Deployment

# 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

Environment Variables

# 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

πŸ“Š Monitoring & Logging

Metrics Collection

  • Application Metrics: Request rates, response times
  • Business Metrics: User engagement, recommendation accuracy
  • Infrastructure Metrics: CPU, memory, disk usage
  • Custom Metrics: ML model performance

Logging

  • Structured Logging: JSON-formatted logs
  • Log Levels: DEBUG, INFO, WARNING, ERROR
  • Log Aggregation: Centralized log collection
  • Alerting: Automated error notifications

🀝 Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

πŸ“„ License

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

πŸ™ Acknowledgments

  • Django community for the excellent framework
  • Scikit-learn team for ML capabilities
  • Docker and Kubernetes communities
  • All contributors and testers

πŸ“ž Support

For support, email support@wannafit.com or join our Slack channel.


Built with ❀️ for fitness enthusiasts worldwide

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages