Backend for the LMS platform built with Django 5.2 + Django REST Framework + JWT + WebSockets (Django Channels).
Handles user management, course enrolment, messaging, notifications, and live chat.
- Django 5.2 & Django REST Framework
- JWT (
djangorestframework-simplejwt) - Django Channels (WebSocket chat + notifications)
- PostgreSQL (primary database)
- S3‑compatible storage (
django-storages+boto3) - Docker Compose (for local Postgres + RustFS)
python -m venv .venv
source .venv/bin/activate # or .venv\Scripts\activate on Windows
pip install -r requirements.txt- Start services with Docker
docker compose up -d- Run migrations
python manage.py migrate- Run the server
python manage.py runserverServer will be available at http://127.0.0.1:8000
🧪 Seed demo data
Populate the database with rich demo users, courses, messages, grades, and newsletter entries:
python manage.py seed_lmsReset and re‑seed:
python manage.py seed_lms --clearAll seeded users have the password: seedpass123
📚 API Documentation
The full REST API is described in openapi.yaml (OpenAPI 3.0). All routes are prefixed with /api/v1/.
🔓 Public endpoints
· GET /courses/ – list courses · GET /courses/{id}/ – course outline (anonymous access) · GET /stats/ – platform statistics · POST /newsletter/ – subscribe to newsletter · POST /login/ – obtain JWT pair · POST /register/ – new user registration · POST /auth/register/ (alias) · POST /refresh-token/ – refresh access token
🔐 Authenticated endpoints
· GET /me/ – current user profile + role flags · GET /admin/overview/ – platform admin overview · GET /enrollments/ – my enrolled courses · POST /courses/{id}/enroll/ – enrol into a course · GET /messages/conversations/ – list my conversations · GET /notifications/ – unread notifications
💬 WebSocket chat
Endpoint: ws://127.0.0.1:8000/ws/chat/?token=<your_jwt_access_token>
Supports:
· sending / receiving messages · typing indicators · read receipts · real‑time notification pushes
👥 Roles
· student – can browse courses, enrol, participate in chat · instructor – can manage their courses (admin UI / future endpoints) · admin – full platform oversight (e.g. /admin/overview/)
Check GET /api/v1/me/ for frontend feature gating.
🗺️ Database Schema Diagram
Generate an ER diagram image automatically from Django models:
python manage.py generate_schema_diagramThis command writes the diagram to:
docs/images/db_schema.png
Then the README can show it directly:
The diagram is generated directly from Django model metadata and saved as a PNG image.
· Environment is loaded from .env (see .env.sample), including DB settings.
· Channel layer is in‑memory. Use Redis for production.
· Browsable API is enabled only when DEBUG=True.
📁 Documentation
Detailed contracts and checklists are in the docs/ folder:
· backend-api-contract-fa.md · lms-api-contract.md · frontend-websocket-chat-fa.md · server-api-checklist.md
