Skip to content

Latest commit

Β 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ’¬ WhatsUp Backend

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.


Python Django DRF Redis WebSocket JWT OpenAPI License Status


🌟 Why WhatsUp Backend?

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.

πŸ“‘ Table of Contents

πŸ“– Overview

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.

πŸš€ Project Highlights

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 βœ…

✨ Features

πŸ” Authentication

  • βœ… User Registration
  • βœ… Login & Logout
  • βœ… JWT Authentication
  • βœ… User Profile
  • βœ… Profile Update

πŸ’¬ Messaging

  • βœ… 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

πŸ‘₯ Group Management

  • βœ… Create Group
  • βœ… Add Participants
  • βœ… Remove Participants
  • βœ… Leave Group
  • βœ… Admin Management

πŸ“‚ Media Sharing

  • βœ… Images
  • βœ… Videos
  • βœ… Documents
  • βœ… Audio Files
  • βœ… Voice Notes
  • βœ… Multiple Attachments

πŸ“Έ Status

  • βœ… Upload Status
  • βœ… Image Status
  • βœ… Video Status
  • βœ… Status Privacy
  • βœ… Status Viewers
  • βœ… Delete Status

πŸ“ž Calls

  • βœ… Audio Calls
  • βœ… Video Calls
  • βœ… Busy Detection
  • βœ… Hold Call
  • βœ… Resume Call
  • βœ… Call History
  • βœ… Missed Calls
  • βœ… Screen Sharing Signaling
  • βœ… Camera Toggle Events
  • βœ… WebRTC Signaling

⚑ Real-Time

  • βœ… Django Channels
  • βœ… Redis Channel Layer
  • βœ… WebSocket Messaging
  • βœ… Live Typing Indicators
  • βœ… Read Receipts
  • βœ… Delivery Receipts
  • βœ… Presence Updates
  • βœ… Call Events

πŸ›  Technology Stack

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)

πŸ— System Architecture

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

πŸ“ Project Structure

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

βš™ Installation

1️⃣ Clone the Repository

git clone https://github.com/MuhammadHaseeb3112/WhatsUp-Backend.git

cd WhatsUp-Backend

2️⃣ Create a Virtual Environment

python -m venv venv

3️⃣ Activate the Virtual Environment

Windows

venv\Scripts\activate

Linux / macOS

source venv/bin/activate

4️⃣ Install Dependencies

pip install -r requirements.txt

πŸ”‘ Environment Variables

Create 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=7

You can also copy the sample configuration:

cp .env.example .env

πŸ—„ Database Migration

Create the database tables.

python manage.py makemigrations

python manage.py migrate

Create an administrator account.

python manage.py createsuperuser

πŸš€ Running the Development Server

Start the Django development server.

python manage.py runserver

Your backend will be available at:

http://127.0.0.1:8000/

πŸ”΄ Running Redis

Start the Redis server before using WebSocket functionality.

redis-server

Redis is used for:

  • ⚑ Django Channels
  • πŸ“‘ WebSocket Communication
  • πŸ”„ Real-Time Events
  • πŸ“ž Call Signaling

🐳 Docker Setup

The project includes Docker support for easy local development.

Build the containers

docker compose build

Start all services

docker compose up

Or build and start everything with one command:

docker compose up --build

Run in detached mode:

docker compose up -d

Stop all services:

docker compose down

Docker Services

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.

πŸ“– API Documentation

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.

🌐 Swagger UI

http://127.0.0.1:8000/api/docs/

πŸ“„ OpenAPI Schema

http://127.0.0.1:8000/api/schema/

πŸ“– Swagger UI

API Overview

Swagger


Accounts APIs

Accounts


Chat APIs

Chat

πŸ” Authentication

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...

πŸ“‘ WebSocket Endpoints

Real-time communication is handled using Django Channels and Redis.

πŸ’¬ Chat WebSocket

ws://127.0.0.1:8000/ws/chat/<room_id>/

Used for:

  • Live Messages
  • Typing Indicators
  • Read Receipts
  • Delivery Receipts
  • Presence Updates

πŸ“ž Call WebSocket

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

πŸ“š API Examples

πŸ‘€ Register User

Request

POST /api/accounts/register/
{
  "phone_number": "+923001234567",
  "password": "StrongPassword123",
  "first_name": "Muhammad",
  "last_name": "Haseeb"
}

Response

{
  "message": "User registered successfully.",
  "user": {
    "id": 1,
    "phone_number": "+923001234567",
    "first_name": "Muhammad",
    "last_name": "Haseeb"
  }
}

πŸ”‘ Login

Request

POST /api/accounts/login/
{
  "phone_number": "+923001234567",
  "password": "StrongPassword123"
}

Response

{
  "access": "eyJhbGciOi...",
  "refresh": "eyJhbGciOi...",
  "user": {
    "id": 1,
    "phone_number": "+923001234567"
  }
}

πŸ’¬ Send Message

Request

POST /api/chat/messages/
{
  "room": 12,
  "content": "Hello World!"
}

Response

{
  "message": "Message sent successfully.",
  "data": {
    "id": 145,
    "content": "Hello World!",
    "sender": {
      "id": 1
    },
    "created_at": "2026-07-07T14:30:00Z"
  }
}

πŸ“ž Start Call

Request

POST /api/calls/start/
{
  "room": 12,
  "call_type": "video"
}

Response

{
  "id": 5,
  "status": "ringing",
  "call_type": "video",
  "started_at": "2026-07-07T15:20:00Z"
}

πŸ’¬ Chat Message Flow

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
Loading

πŸ“ž Call Flow

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
Loading

πŸ› Project Documentation

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

πŸ“Š API Modules

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

πŸ§ͺ Testing

The project is structured to support automated testing using Django's built-in testing framework.

Run all tests:

python manage.py test

Run tests with verbose output:

python manage.py test -v 2

Future improvements include:

  • βœ… Unit Tests
  • βœ… Integration Tests
  • βœ… API Tests
  • βœ… WebSocket Tests
  • βœ… Performance Tests

βš™ Continuous Integration (CI)

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

🐳 Docker Deployment

The project supports containerized deployment using Docker and Docker Compose.

Build Containers

docker compose build

Start Services

docker compose up

Build & Start

docker compose up --build

Run in Background

docker compose up -d

Stop Services

docker compose down

Docker Services

Service Purpose
Django REST API & WebSockets
Redis Channel Layer
PostgreSQL (optional) Production Database

πŸš€ Deployment

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

πŸ”’ Security Features

The project follows modern backend security practices.

Authentication

  • βœ… JWT Authentication
  • βœ… Refresh Tokens
  • βœ… Token Blacklisting

Authorization

  • βœ… Permission-Based Access
  • βœ… Participant Validation
  • βœ… Ownership Validation

API Security

  • βœ… Serializer Validation
  • βœ… Input Sanitization
  • βœ… Authentication Middleware
  • βœ… Protected Endpoints

Communication

  • βœ… WebSocket Authentication
  • βœ… Secure Call Signaling
  • βœ… Protected Media Access

πŸ“ˆ Performance & Scalability

The backend is designed with scalability in mind.

Optimizations

  • βœ… select_related()
  • βœ… prefetch_related()
  • βœ… Database Indexing
  • βœ… Redis Channel Layer
  • βœ… Asynchronous WebSockets
  • βœ… Modular Django Apps

Supports

  • Multiple Concurrent Users
  • Real-Time Messaging
  • Real-Time Calls
  • Efficient Database Queries
  • Horizontal Scaling

πŸ“Š Project Statistics

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 βœ…

πŸ›£ Roadmap

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

🀝 Contributing

Contributions are welcome!

If you'd like to improve this project:

  1. Fork the repository
  2. Create a feature branch
git checkout -b feature/new-feature
  1. Commit your changes
git commit -m "Add new feature"
  1. Push your branch
git push origin feature/new-feature
  1. Open a Pull Request

Please ensure your code follows Django best practices and includes appropriate tests where applicable.


πŸ“„ License

This project is licensed under the MIT License.

See the LICENSE file for more information.


πŸ‘¨β€πŸ’» Author

Muhammad Haseeb

BS Computer Science

Backend Developer | Python Developer | Django Developer

Technical Skills

  • 🐍 Python
  • 🌐 Django
  • πŸš€ Django REST Framework
  • ⚑ Django Channels
  • πŸ”΄ Redis
  • πŸ“‘ WebSockets
  • πŸ“ž WebRTC Signaling
  • πŸ—„ PostgreSQL
  • 🐳 Docker
  • πŸ”„ GitHub Actions

Connect

GitHub

https://github.com/MuhammadHaseeb3112

⭐ Support the Project

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.

About

Production-ready WhatsApp-inspired backend built with Django, DRF, Channels, Redis, WebSockets, and WebRTC signaling.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages