A production-ready real-time messaging and calling backend inspired by WhatsApp.
A scalable backend built with Django, Django REST Framework, Django Channels, Redis, WebSockets, and WebRTC Signaling.
Designed using clean architecture principles to provide secure authentication, real-time messaging, media sharing, voice/video call signaling, and status updates.
Modern messaging applications require much more than simple CRUD APIs. This project demonstrates how to build a scalable backend capable of handling:
- π¬ Real-Time Messaging
- π Audio & Video Call Signaling
- πΈ WhatsApp-style Status Updates
- π₯ Group Conversations
- π Media Sharing
- π Secure JWT Authentication
- β‘ WebSocket Communication
- π Fully Documented REST APIs (Swagger/OpenAPI)
Whether you're learning Django Channels, building a messaging platform, or exploring WebRTC signaling, this project provides a solid foundation.
- π Overview
- π Project Highlights
- β¨ Features
- π Technology Stack
- π System Architecture
- π Project Structure
- β Installation
- π³ Docker Setup
- π Environment Variables
- π Database Migration
- π Running the Project
- π API Documentation
- πΈ Swagger Preview
- π Authentication
- π‘ WebSocket Endpoints
- π API Examples
- π¬ Chat Flow
- π Call Flow
- π API Modules
- π§ͺ Testing
- β CI/CD
- π£ Roadmap
- π€ Contributing
- π License
- π¨βπ» Author
WhatsUp Backend is a production-ready backend application inspired by the architecture of modern messaging platforms such as WhatsApp.
It combines REST APIs with WebSocket communication to deliver secure, scalable, and real-time messaging experiences.
The backend supports:
- π Secure JWT Authentication
- π¬ One-to-One Messaging
- π₯ Group Messaging
- π Media Sharing
- πΈ Status Updates
- π Audio & Video Call Signaling
- β‘ Real-Time Notifications
- π Interactive Swagger Documentation
The project is designed using Django best practices, making it suitable for both learning purposes and real-world applications.
| Feature | Status |
|---|---|
| π JWT Authentication | β |
| π¬ Private Chat | β |
| π₯ Group Chat | β |
| π Media Upload | β |
| π€ Voice Notes | β |
| πΈ Status Sharing | β |
| π Audio Calling | β |
| π₯ Video Calling | β |
| β‘ WebSocket Communication | β |
| π Swagger Documentation | β |
| π³ Docker Support | β |
| π Redis Channel Layer | β |
| π‘ WebRTC Signaling | β |
| π OpenAPI Schema | β |
| π Clean Architecture | β |
- β User Registration
- β Login & Logout
- β JWT Authentication
- β User Profile
- β Profile Update
- β Private Conversations
- β Group Conversations
- β Reply Messages
- β Forward Messages
- β Search Messages
- β Message Reactions
- β Pin Messages
- β Star Messages
- β Archive Chats
- β Mute Chats
- β Delete for Me
- β Delete for Everyone
- β Create Group
- β Add Participants
- β Remove Participants
- β Leave Group
- β Admin Management
- β Images
- β Videos
- β Documents
- β Audio Files
- β Voice Notes
- β Multiple Attachments
- β Upload Status
- β Image Status
- β Video Status
- β Status Privacy
- β Status Viewers
- β Delete Status
- β Audio Calls
- β Video Calls
- β Busy Detection
- β Hold Call
- β Resume Call
- β Call History
- β Missed Calls
- β Screen Sharing Signaling
- β Camera Toggle Events
- β WebRTC Signaling
- β Django Channels
- β Redis Channel Layer
- β WebSocket Messaging
- β Live Typing Indicators
- β Read Receipts
- β Delivery Receipts
- β Presence Updates
- β Call Events
The project is built using modern backend technologies that enable secure authentication, scalable APIs, real-time communication, and production-ready deployment.
| Technology | Purpose |
|---|---|
| π Python 3.12 | Programming Language |
| π Django | Backend Web Framework |
| π Django REST Framework | REST API Development |
| β‘ Django Channels | WebSocket Support |
| π΄ Redis | Channel Layer & Real-Time Communication |
| π PostgreSQL / SQLite | Database |
| π JWT (Simple JWT) | Authentication |
| π drf-spectacular | OpenAPI & Swagger Documentation |
| π‘ WebRTC | Audio & Video Call Signaling |
| π³ Docker | Containerization |
| π GitHub Actions | Continuous Integration (CI) |
The backend follows a layered architecture that separates business logic, data access, and communication layers to improve maintainability and scalability.
ββββββββββββββββββββββββββββββ
β Client Applications β
β Flutter β’ React β’ Next.js β
β Android β’ iOS β’ Web β
ββββββββββββββββ¬ββββββββββββββ
β
REST API / WebSocket
β
ββββββββββββββββββββββ΄βββββββββββββββββββββ
β β
Django REST Framework Django Channels
β β
ββββββββββββββββββββββ¬βββββββββββββββββββββ
β
Business Logic Layer
β
ββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββ
β β β
Accounts Module Chat Module Calls Module
β β β
ββββββββββββββββββββββββββββββββββΌβββββββββββββββββββββββββββββββ
β
Status Module
β
βΌ
Django Models & ORM Layer
β
ββββββββββββββββββββ΄ββββββββββββββββββ
β β
PostgreSQL / SQLite Redis
β β
ββββββββββββββββββββ¬ββββββββββββββββββ
β
Real-Time Communication
WhatsUp-Backend/
β
βββ apps/
β βββ accounts/ # Authentication & Profiles
β βββ chat/ # Messaging System
β βββ calls/ # Audio & Video Calls
β βββ status/ # WhatsApp Status Module
β
βββ config/
β βββ settings/
β β βββ base.py
β β βββ development.py
β β βββ production.py
β β
β βββ asgi.py
β βββ urls.py
β βββ wsgi.py
β
βββ docs/
β βββ architecture.md
β βββ sequence.md
β βββ swagger.png
β
βββ docker/
β
βββ media/
βββ static/
βββ tests/
βββ scripts/
β
βββ .github/
β βββ workflows/
β βββ django.yml
β
βββ .dockerignore
βββ .env.example
βββ .gitignore
βββ docker-compose.yml
βββ Dockerfile
βββ manage.py
βββ README.md
βββ requirements.txt
git clone https://github.com/MuhammadHaseeb3112/WhatsUp-Backend.git
cd WhatsUp-Backendpython -m venv venvvenv\Scripts\activatesource venv/bin/activatepip install -r requirements.txtCreate a .env file in the project root.
Example:
SECRET_KEY=your_secret_key
DEBUG=True
ALLOWED_HOSTS=127.0.0.1,localhost
DATABASE_URL=sqlite:///db.sqlite3
REDIS_URL=redis://127.0.0.1:6379
ACCESS_TOKEN_LIFETIME=30
REFRESH_TOKEN_LIFETIME=7You can also copy the sample configuration:
cp .env.example .envCreate the database tables.
python manage.py makemigrations
python manage.py migrateCreate an administrator account.
python manage.py createsuperuserStart the Django development server.
python manage.py runserverYour backend will be available at:
http://127.0.0.1:8000/
Start the Redis server before using WebSocket functionality.
redis-serverRedis is used for:
- β‘ Django Channels
- π‘ WebSocket Communication
- π Real-Time Events
- π Call Signaling
The project includes Docker support for easy local development.
docker compose builddocker compose upOr build and start everything with one command:
docker compose up --buildRun in detached mode:
docker compose up -dStop all services:
docker compose down| Service | Description |
|---|---|
| Django | Backend API |
| Redis | Channel Layer |
| PostgreSQL (optional) | Production Database |
After the containers start successfully, open:
http://127.0.0.1:8000/
to access the application.
The backend exposes a fully documented REST API using drf-spectacular (OpenAPI 3.0).
Interactive API documentation makes it easy to explore, test, and integrate every endpoint.
http://127.0.0.1:8000/api/docs/
http://127.0.0.1:8000/api/schema/
The API uses JWT (JSON Web Token) authentication.
After a successful login, the backend returns:
- Access Token
- Refresh Token
Include the access token in every authenticated request.
Authorization: Bearer <access_token>Example:
GET /api/accounts/me/
Authorization: Bearer eyJhbGciOiJIUzI1NiIs...Real-time communication is handled using Django Channels and Redis.
ws://127.0.0.1:8000/ws/chat/<room_id>/
Used for:
- Live Messages
- Typing Indicators
- Read Receipts
- Delivery Receipts
- Presence Updates
ws://127.0.0.1:8000/ws/calls/<call_id>/
Used for:
- Incoming Calls
- Accept / Reject
- ICE Candidates
- SDP Offer / Answer
- Hold / Resume
- Screen Share Events
- Camera Toggle
- Call End Events
POST /api/accounts/register/{
"phone_number": "+923001234567",
"password": "StrongPassword123",
"first_name": "Muhammad",
"last_name": "Haseeb"
}{
"message": "User registered successfully.",
"user": {
"id": 1,
"phone_number": "+923001234567",
"first_name": "Muhammad",
"last_name": "Haseeb"
}
}POST /api/accounts/login/{
"phone_number": "+923001234567",
"password": "StrongPassword123"
}{
"access": "eyJhbGciOi...",
"refresh": "eyJhbGciOi...",
"user": {
"id": 1,
"phone_number": "+923001234567"
}
}POST /api/chat/messages/{
"room": 12,
"content": "Hello World!"
}{
"message": "Message sent successfully.",
"data": {
"id": 145,
"content": "Hello World!",
"sender": {
"id": 1
},
"created_at": "2026-07-07T14:30:00Z"
}
}POST /api/calls/start/{
"room": 12,
"call_type": "video"
}{
"id": 5,
"status": "ringing",
"call_type": "video",
"started_at": "2026-07-07T15:20:00Z"
}sequenceDiagram
participant User A
participant Backend
participant Redis
participant User B
User A->>Backend: Send Message
Backend->>Redis: Publish Event
Redis->>User B: WebSocket Message
Backend-->>User A: Success Response
sequenceDiagram
participant Caller
participant Backend
participant Redis
participant Receiver
Caller->>Backend: Start Call API
Backend->>Redis: Broadcast Incoming Call
Redis->>Receiver: Ringing Event
Receiver->>Backend: Accept Call
Backend->>Caller: Call Accepted
Caller->>Receiver: WebRTC Offer
Receiver->>Caller: WebRTC Answer
Caller->>Receiver: ICE Candidates
Receiver->>Caller: ICE Candidates
Note over Caller,Receiver: Media Connection Established
Caller->>Backend: End Call
Backend->>Redis: Broadcast End Event
The repository contains additional documentation inside the docs/ directory.
| Document | Description |
|---|---|
| architecture.md | Overall Backend Architecture |
| sequence.md | Chat & Call Sequence Diagrams |
| swagger.png | Swagger UI Screenshot |
| api_examples.md (optional) | REST API Examples |
| deployment.md (optional) | Deployment Guide |
| Module | Description |
|---|---|
| π Accounts | Registration, Login, JWT Authentication, User Profile |
| π¬ Chat | Private Chat, Groups, Media, Search, Reactions |
| π Calls | Audio/Video Call Signaling, Hold, Resume, History |
| πΈ Status | WhatsApp-style Status Sharing & Privacy |
The project is structured to support automated testing using Django's built-in testing framework.
Run all tests:
python manage.py testRun tests with verbose output:
python manage.py test -v 2Future improvements include:
- β Unit Tests
- β Integration Tests
- β API Tests
- β WebSocket Tests
- β Performance Tests
GitHub Actions is used to automatically verify the project on every push and pull request.
The CI pipeline performs:
- β Install Dependencies
- β Run Django Checks
- β Apply Database Migrations
- β Execute Test Suite
- β Verify Build
Workflow location:
.github/
βββ workflows/
βββ django.yml
The project supports containerized deployment using Docker and Docker Compose.
docker compose builddocker compose updocker compose up --builddocker compose up -ddocker compose down| Service | Purpose |
|---|---|
| Django | REST API & WebSockets |
| Redis | Channel Layer |
| PostgreSQL (optional) | Production Database |
The backend is deployment-ready and can be hosted on:
- Render
- Railway
- DigitalOcean
- AWS EC2
- Microsoft Azure
- Google Cloud Platform
- Docker VPS
- Ubuntu Server
- Nginx + Gunicorn
Recommended production stack:
Client
β
Nginx
β
Gunicorn
β
Django
β
Redis
β
PostgreSQL
The project follows modern backend security practices.
- β JWT Authentication
- β Refresh Tokens
- β Token Blacklisting
- β Permission-Based Access
- β Participant Validation
- β Ownership Validation
- β Serializer Validation
- β Input Sanitization
- β Authentication Middleware
- β Protected Endpoints
- β WebSocket Authentication
- β Secure Call Signaling
- β Protected Media Access
The backend is designed with scalability in mind.
- β select_related()
- β prefetch_related()
- β Database Indexing
- β Redis Channel Layer
- β Asynchronous WebSockets
- β Modular Django Apps
- Multiple Concurrent Users
- Real-Time Messaging
- Real-Time Calls
- Efficient Database Queries
- Horizontal Scaling
| Metric | Value |
|---|---|
| Django Apps | 4 |
| REST APIs | 30+ |
| WebSocket Consumers | 2 |
| Authentication | JWT |
| Real-Time Features | 10+ |
| Media Types | 5 |
| Swagger Documentation | β |
| Docker Support | β |
| CI/CD Ready | β |
Planned future enhancements include:
- π Firebase Push Notifications
- π STUN/TURN Server Integration
- π₯ Group Audio Calling
- π₯ Group Video Calling
- πΉ Call Recording
- π Call Quality Metrics
- π Automatic Reconnection Handling
- π End-to-End Encryption
- π€ AI Spam Detection
- β Cloud Storage Integration
- π± Flutter Mobile Client
- π React / Next.js Frontend
- π Admin Analytics Dashboard
Contributions are welcome!
If you'd like to improve this project:
- Fork the repository
- Create a feature branch
git checkout -b feature/new-feature- Commit your changes
git commit -m "Add new feature"- Push your branch
git push origin feature/new-feature- Open a Pull Request
Please ensure your code follows Django best practices and includes appropriate tests where applicable.
This project is licensed under the MIT License.
See the LICENSE file for more information.
BS Computer Science
Backend Developer | Python Developer | Django Developer
- π Python
- π Django
- π Django REST Framework
- β‘ Django Channels
- π΄ Redis
- π‘ WebSockets
- π WebRTC Signaling
- π PostgreSQL
- π³ Docker
- π GitHub Actions
GitHub
https://github.com/MuhammadHaseeb3112
If you found this project useful:
β Star the repository
π΄ Fork the project
π Report issues
π‘ Suggest new features
π’ Share it with others
Your support helps improve the project and motivates future development.
Made with β€οΈ using Django, Django REST Framework, Django Channels, Redis & WebRTC.


