This project is a demonstration of Server-Sent Events (SSE) using Django without relying on third-party libraries.
- An example shown here is of a real-time updates for logged-in users of posts where they have been mentioned
- Python (>=3.11)
- Django (>=5.0)
Before starting anything
Have a .env file in the repo. Copy the env.example and then put in your secret key
In theory, you can run the following commands to start the project:
make start
This command uses Docker Compose and sets up four major parts:
- Data systems: Postgres and Redis.
- A synchronous Django app.
- An asynchronous Django app.
- Nginx for serving the application.
Ensure that you have Docker and Docker Compose installed on your machine.
-
Home Page:
- http://localhost:8000
- The home page where you can log in or sign up.
-
:A place where posts mentioning you as a user are present
- http://localhost:8000/posts/lobby/
- No login required. Get the latest content from Mastodon.
-
Data Systems:
- Postgres and Redis for data storage and stream handling.
-
Synchronous Django App:
- Provides all the functionalities for the user like posts
-
Asynchronous Django App:
- Enhances real-time capabilities asynchronously.
-
Nginx:
- Serves the application and routes the traffic
- Create a user account and log in.
- Navigate to the Posts link to see what posts you were mentioned on.
- In another window click on create post and write a post mentioning yourself or other users
This project also demonstrates how to quickly convert a polling-based system to real-time.
Contributions are welcome! Feel free to open issues or submit pull requests.