Skip to content

Full backend Learning Management System built with Django REST Framework. Features custom user model, JWT authentication, role-based permissions, filtering, search, pagination, and auto-generated API documentation.

Notifications You must be signed in to change notification settings

banumariwan/learning-management-system-backend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ย 

History

3 Commits
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 
ย 

Repository files navigation

Learning Management System (LMS) โ€“ Backend API

A full-featured Django REST Framework backend that implements modern API practices such as a custom user model, JWT authentication, permissions, filtering, search, ordering, pagination, and auto-generated API documentation.

This project was built step-by-step following a complete backend roadmap.


๐Ÿš€ Features

1. Custom User Model (Most Important Part)

The project replaces Djangoโ€™s default user with a CustomUser model that supports:

  • username
  • email
  • password (hashed)
  • age
  • bio
  • role (student/instructor/admin)

๐Ÿ” Secure Password Handling

Passwords are never stored as plain text. A custom serializer handles hashing:

class UserSerializer(serializers.ModelSerializer):
    password = serializers.CharField(write_only=True)

    class Meta:
        model = CustomUser
        fields = ['username', 'email', 'password', 'age', 'bio', 'role']

    def create(self, validated_data):
        password = validated_data.pop('password')
        user = CustomUser(**validated_data)
        user.set_password(password)  # ๐Ÿ”’ important hashing step
        user.save()
        return user

This ensures the userโ€™s password is safely hashed before saving.


๐Ÿ”‘ JWT Authentication (SimpleJWT)

The project uses SimpleJWT for login, token refresh, and secure access.

Endpoints include:

  • /api/auth/register/
  • /api/auth/login/
  • /api/auth/token/refresh/
  • Protected routes requiring Bearer <token>

๐Ÿ‘ฎ Permissions & Access Control

The project uses:

  • IsAuthenticated
  • Role-based access (admin, instructor, student)
  • Object-level permissions (ownership checks)

Examples:

  • Students can only view their own data
  • Instructors can manage their own courses
  • Admins have full access

๐Ÿ”Ž Filtering, Search & Ordering

DjangoFilter + DRF Search + Ordering are applied globally.

Example (User list):

  • Filter by role, age
  • Search by username, email
  • Order by username, email

Query examples:

/api/users/?search=banu
/api/users/?role=student
/api/users/?ordering=email

๐Ÿ“„ Pagination

Custom pagination using DRF PageNumberPagination:

  • Default page size: 10
  • Client can control page size
  • Max page size: 100

Example:

/api/users/?page=2&page_size=5

๐Ÿ“š API Documentation (Swagger / Redoc)

Interactive documentation included using drf-yasg:

  • /swagger/
  • /redoc/

๐Ÿ“˜ Project Structure

lms_api/
โ”‚   manage.py
โ”‚   db.sqlite3
โ”‚
โ”œโ”€โ”€ accounts/
โ”‚   โ”œโ”€โ”€ models.py
โ”‚   โ”œโ”€โ”€ serializers.py
โ”‚   โ”œโ”€โ”€ views.py
โ”‚   โ”œโ”€โ”€ filters.py
โ”‚   โ””โ”€โ”€ urls.py
โ”‚
โ”œโ”€โ”€ courses/
โ”‚   โ”œโ”€โ”€ models.py
โ”‚   โ”œโ”€โ”€ serializers.py
โ”‚   โ””โ”€โ”€ views.py
โ”‚
โ””โ”€โ”€ lms_api/
    โ”œโ”€โ”€ settings.py
    โ”œโ”€โ”€ urls.py
    โ””โ”€โ”€ asgi.py

โš™๏ธ Installation & Setup

  1. Clone the project
git clone https://github.com/<your-username>/learning-management-system-backend.git
cd learning-management-system-backend
  1. Install dependencies
pip install -r requirements.txt
  1. Apply migrations
python manage.py migrate
  1. Start the server
python manage.py runserver

๐Ÿงช Testing

Use:

  • Django admin
  • DRF browsable API
  • Postman
  • Swagger UI

๐ŸŽฏ This project includes:

โœ” Django models โœ” Migrations โœ” Admin customization โœ” DRF API setup โœ” Serializers โœ” ViewSets โœ” Custom user model โœ” JWT authentication โœ” Permissions & Object-level auth โœ” Filtering, Search, Ordering โœ” Pagination โœ” API documentation โœ” Complete full backend project (LMS)


๐Ÿ“ฌ Author

Developed by banumariwan For backend learning, DRF mastery, and real-world API experience.

About

Full backend Learning Management System built with Django REST Framework. Features custom user model, JWT authentication, role-based permissions, filtering, search, pagination, and auto-generated API documentation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages