A comprehensive REST API for an online learning platform built with Django REST Framework. Features include course management, student enrollments, quizzes, progress tracking, and course ratings.
- π Authentication: JWT-based authentication with role-based access (Students & Instructors)
- π Course Management: Create, update, and manage courses with categories and levels
- π Lessons: Organize course content with ordered lessons supporting video and text content
- π Quizzes: Interactive quizzes with multiple choice and true/false questions
- π― Enrollments: Student enrollment system with progress tracking
- β Ratings: Course rating and review system with average rating calculation
- π Throttling: Rate limiting to prevent API abuse
- π API Documentation: Interactive Swagger/OpenAPI documentation
- Backend: Django 5.2.8 + Django REST Framework 3.16.1
- Database: PostgreSQL 15
- Authentication: JWT (djangorestframework-simplejwt)
- API Documentation: drf-spectacular (Swagger/OpenAPI)
- Web Server: Nginx (reverse proxy)
- Containerization: Docker & Docker Compose
- Testing: pytest + pytest-django
- Code Quality: Black, Flake8
- Docker & Docker Compose
- Git
git clone https://github.com/snushev/learning-platform.git
cd learning-platformcp .env.example .envEdit .env and set your environment variables.
docker-compose up --builddocker-compose exec web python manage.py createsuperuser- API Root: http://localhost/api/
- Admin Panel: http://localhost/admin/
- API Documentation: http://localhost/api/docs/
POST /api/users/register/- Register new userPOST /api/users/login/- Login and get JWT tokensPOST /api/token/- Get JWT tokenPOST /api/token/refresh/- Refresh JWT token
GET /api/users/profile/- Get current user profilePUT /api/users/profile/update/- Update user profile
GET /api/courses/- List all courses (with filtering & search)POST /api/courses/- Create course (instructors only)GET /api/courses/{id}/- Get course detailsPUT /api/courses/{id}/- Update course (owner only)DELETE /api/courses/{id}/- Delete course (owner only)
GET /api/categories/- List all categoriesPOST /api/categories/- Create category (admin only)
GET /api/lessons/- List lessonsGET /api/lessons/?course={id}- Filter lessons by coursePOST /api/lessons/- Create lesson (instructor only)GET /api/lessons/{id}/- Get lesson detailsPUT /api/lessons/{id}/- Update lessonDELETE /api/lessons/{id}/- Delete lesson
GET /api/enrollments/- List my enrollmentsPOST /api/enrollments/- Enroll in a courseGET /api/enrollments/{id}/- Get enrollment details with progressDELETE /api/enrollments/{id}/- Unenroll from coursePOST /api/enrollments/{id}/mark-lesson-viewed/- Mark lesson as viewed
GET /api/quizzes/- List quizzesGET /api/quizzes/?course={id}- Filter quizzes by coursePOST /api/quizzes/- Create quiz (instructor only)GET /api/quizzes/{id}/- Get quiz details with questions
GET /api/quiz-attempts/- List my attemptsPOST /api/quiz-attempts/- Start quiz attemptGET /api/quiz-attempts/{id}/- Get attempt detailsPOST /api/quiz-attempts/{id}/submit/- Submit quiz answers
GET /api/ratings/- List all ratingsGET /api/ratings/?course={id}- Filter ratings by coursePOST /api/ratings/- Rate a course (enrolled students only)PUT /api/ratings/{id}/- Update rating (owner only)DELETE /api/ratings/{id}/- Delete rating (owner only)
# Run all tests
docker-compose exec web pytest
# Run with verbose output
docker-compose exec web pytest -v
# Run specific test file
docker-compose exec web pytest users/tests.py
# Run with coverage
docker-compose exec web pytest --cov=. --cov-report=html- Create virtual environment
python -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activate- Install dependencies
pip install -r requirements.txt- Set up database
# Start only PostgreSQL container
docker-compose up db
# Run migrations
python manage.py migrate- Run development server
python manage.py runserver# Format code with Black
black .
# Lint with Flake8
flake8 .- JWT token authentication
- Role-based access control (Students & Instructors)
- Rate limiting (100 requests/day for anonymous, 1000/day for authenticated)
- Permission checks on all endpoints
- Unique constraints to prevent duplicate enrollments/ratings
learning-platform/
βββ config/ # Project settings
βββ users/ # User authentication & profiles
βββ courses/ # Course management
βββ lessons/ # Lesson content
βββ enrollments/ # Student enrollments & progress
βββ quizzes/ # Quiz system
βββ ratings/ # Course ratings & reviews
βββ nginx/ # Nginx configuration
βββ .github/workflows/ # CI/CD pipelines
βββ docker-compose.yml # Docker services
βββ Dockerfile # Django container
βββ requirements.txt # Python dependencies
βββ README.md
- 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.
Simeon Nushev
- GitHub: @snushev
- Built with Django REST Framework
- API documentation powered by drf-spectacular
- Containerized with Docker
Made with β€οΈ by Simeon Nushev