Skip to content

SBrophy-dev/Django_Learning

Repository files navigation

Django Learning Dashboard

An interactive web application that teaches Django through hands-on modules. Explore beginner to advanced topics with live demos, a sandboxed code executor, progress tracking, and a gamified achievement system.

Features

  • Interactive Learning Modules — Beginner, intermediate, and advanced topics with live demos and code examples
  • Sandboxed Code Execution — Run Python code safely in the browser with process isolation, timeouts, and resource limits
  • Progress Tracking — Track module completion, view activity timelines, and monitor your learning journey
  • Achievements & Leaderboard — Earn badges, climb the leaderboard, and stay motivated through gamification
  • REST API — Full API with Swagger and ReDoc documentation powered by Django REST Framework
  • Responsive Dark UI — Tailwind CSS dark theme with Alpine.js interactivity and Highlight.js code highlighting

Tech Stack

Layer Technology
Backend Django 5.0+, Django REST Framework, drf-spectacular
Database PostgreSQL 16
Caching Redis 7
Task Queue Celery
Frontend Tailwind CSS (CDN), Alpine.js, Highlight.js
Production Gunicorn, Nginx, Docker, WhiteNoise

Prerequisites

  • Python 3.12+
  • PostgreSQL 16+ (or use Docker)
  • Redis 7+ (or use Docker)
  • Docker & Docker Compose (for containerized deployment)

Quick Start (Local Development)

  1. Clone the repository

    git clone <repository-url>
    cd django-learning-dashboard
  2. Create a virtual environment

    python -m venv venv
    source venv/bin/activate  # Linux/macOS
    venv\Scripts\activate     # Windows
  3. Install dependencies

    pip install -r requirements.txt
  4. Configure environment variables

    cp .env.example .env

    Edit .env and set your values. For local development with SQLite fallback, the defaults work out of the box. For PostgreSQL, update the DB_* variables.

  5. Run migrations

    python manage.py migrate
  6. Seed learning modules and badges

    python manage.py seed_beginner_modules
    python manage.py seed_intermediate_modules
    python manage.py seed_advanced_modules
    python manage.py seed_badges
    python manage.py recalculate_leaderboard
  7. Create a superuser (optional)

    python manage.py createsuperuser
  8. Start the development server

    python manage.py runserver

    Visit http://localhost:8000 to see the dashboard.

Docker Deployment

  1. Configure environment

    cp .env.example .env
    # Edit .env with production values (SECRET_KEY, DB credentials, etc.)
  2. Build and start all services

    docker-compose up -d --build
  3. Run migrations and seed data

    docker-compose exec web python manage.py migrate
    docker-compose exec web python manage.py seed_beginner_modules
    docker-compose exec web python manage.py seed_intermediate_modules
    docker-compose exec web python manage.py seed_advanced_modules
    docker-compose exec web python manage.py seed_badges
    docker-compose exec web python manage.py recalculate_leaderboard
  4. Create a superuser

    docker-compose exec web python manage.py createsuperuser

The application will be available at http://localhost (port 80 via Nginx).

Docker Services

Service Image Purpose
web Custom (Dockerfile) Django app served by Gunicorn
db postgres:16-alpine PostgreSQL database
redis redis:7-alpine Caching and Celery broker
celery_worker Custom (Dockerfile) Async task processing
nginx nginx:1.25-alpine Reverse proxy and static files

Environment Variables

Variable Description Default
DJANGO_SETTINGS_MODULE Settings module path config.settings.development
SECRET_KEY Django secret key Dev key (change in production)
DEBUG Enable debug mode True
ALLOWED_HOSTS Comma-separated allowed hosts localhost,127.0.0.1
DB_NAME PostgreSQL database name django_dashboard
DB_USER PostgreSQL user postgres
DB_PASSWORD PostgreSQL password postgres
DB_HOST Database host db
DB_PORT Database port 5432
REDIS_URL Redis connection URL redis://redis:6379/1
CELERY_BROKER_URL Celery broker URL redis://redis:6379/0
NGINX_PORT Nginx exposed port 80

Project Structure

├── config/                  # Project configuration
│   ├── settings/
│   │   ├── base.py          # Shared settings
│   │   ├── development.py   # Dev overrides
│   │   └── production.py    # Production settings
│   ├── celery.py            # Celery configuration
│   ├── urls.py              # Root URL routing
│   └── wsgi.py / asgi.py
├── apps/
│   ├── core/                # Dashboard home, Module/Category models
│   ├── modules/             # Learning module views and demos
│   │   └── demos/           # Beginner, intermediate, advanced demos
│   ├── progress/            # Progress tracking and activity logging
│   ├── code_executor/       # Sandboxed Python code execution
│   ├── achievements/        # Badges, leaderboard, gamification
│   └── api/                 # REST API viewsets and serializers
├── templates/               # Global templates and components
├── static/                  # Static assets (CSS, JS, images)
├── docker-compose.yml
├── Dockerfile
├── nginx/                   # Nginx configuration
├── requirements.txt
└── manage.py

Management Commands

# Seed learning modules by difficulty level
python manage.py seed_beginner_modules
python manage.py seed_intermediate_modules
python manage.py seed_advanced_modules

# Seed achievement badges
python manage.py seed_badges

# Recalculate leaderboard rankings
python manage.py recalculate_leaderboard

API Documentation

The REST API is available at /api/v1/ with interactive documentation:

URL Description
/api/docs/ Swagger UI — interactive API explorer
/api/redoc/ ReDoc — clean API reference
/api/schema/ OpenAPI 3.0 schema (JSON)
/api/ Built-in API explorer page

Running Tests

# Run all tests
python manage.py test

# Run tests for a specific app
python manage.py test apps.core
python manage.py test apps.modules
python manage.py test apps.progress
python manage.py test apps.code_executor
python manage.py test apps.achievements
python manage.py test apps.api

# Run with verbosity
python manage.py test -v 2

Contributing

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/your-feature)
  3. Make your changes and add tests
  4. Run the test suite to confirm everything passes
  5. Commit your changes (git commit -m 'Add your feature')
  6. Push to the branch (git push origin feature/your-feature)
  7. Open a Pull Request

License

This project is provided for educational purposes. See LICENSE for details.

About

Interactive web application that teaches Django through hands-on modules *WIP*

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors