Skip to content

ablfaxl/lms_api

Repository files navigation

LMS App Server

Django DRF Python PostgreSQL License OpenAPI GitHub Repo GitHub Repo

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.


🧱 Tech Stack

  • 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)

🚀 Quick Start

1. Clone & environment

python -m venv .venv
source .venv/bin/activate      # or .venv\Scripts\activate on Windows
pip install -r requirements.txt
  1. Start services with Docker
docker compose up -d
  1. Run migrations
python manage.py migrate
  1. Run the server
python manage.py runserver

Server 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_lms

Reset and re‑seed:

python manage.py seed_lms --clear

All 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_diagram

This command writes the diagram to:

  • docs/images/db_schema.png

Then the README can show it directly:

Database schema diagram

The diagram is generated directly from Django model metadata and saved as a PNG image.


⚠️ Important notes

· 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

About

An LMS for product training (e.g., training on how to use a SaaS, or internal company training)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages