Project 9: Django Channels Clone (Real-Time)

Build a real-time layer with WebSockets, channel routing, and pub/sub.


Quick Reference

Attribute Value
Difficulty Advanced
Time Estimate 2-3 weeks
Language Python
Prerequisites Async basics, ASGI
Key Topics websockets, channel layers, pub/sub
Output Chat demo with groups

Learning Objectives

By completing this project, you will:

  1. Accept WebSocket connections under ASGI.
  2. Route paths to consumer classes.
  3. Build an in-memory channel layer.
  4. Broadcast messages to groups.
  5. Manage connect/receive/disconnect lifecycle.

The Core Question You’re Answering

“How do I build real-time messaging that scales beyond one connection?”


Concepts You Must Understand First

Concept Why It Matters Where to Learn
WebSocket protocol Full-duplex communication MDN WebSockets
Channel layers Message bus abstraction Channels docs
Pub/Sub Broadcast patterns Messaging basics

Project Specification

Functional Requirements

  1. Implement WebSocket accept/receive/send.
  2. Route to consumer classes.
  3. Group add/remove and broadcast.
  4. Provide a chat demo with multiple clients.

Implementation Guide

Project Structure

project-root/
├── channels_like/
│   ├── app.py
│   ├── routing.py
│   ├── consumers.py
│   └── layer.py
└── demo_chat.py

Questions to Guide Your Design

  1. How will you store active connections?
  2. How will you clean up on disconnect?
  3. How will you handle failed sends?

Testing Strategy

  • Two clients receive broadcasts.
  • Disconnect removes from groups.
  • Invalid messages handled gracefully.

Extensions

  • Redis channel layer.
  • Presence tracking.
  • Private rooms.

This guide was generated from LEARN_DJANGO_WEB_FRAMEWORKS.md. For the complete learning path, see the parent directory LEARN_DJANGO_WEB_FRAMEWORKS/README.md.