This project is a real-time messaging system built with Django and Django Rest Framework (DRF). It provides an API-based chat system with WebSocket support, user authentication via OTP, profile management, and real-time message exchange, storing data in PostgreSQL.
- Login with a mobile number and OTP (default code:
12345) - If the account does not exist, a new user account is created
- JWT authentication for secure API access
- Retrieve user profile information
- Update username, first name, last name, mobile number, and profile picture
- Retrieve a list of chats for the authenticated user
- Fetch a list of registered users (with search by phone number or username)
- Create a new chat with another user
- Get a list of users previously chatted with
- WebSocket infrastructure for real-time messaging
- Send and receive text, images, and files
- Store all messages in the database
- Pagination, search, and sorting for chat lists and user lists
- Docker support with
docker-composefor easy deployment - PostgreSQL as the main database (can be switched to SQLite if needed)
git clone https://github.com/hassandn/messenger.git
cd messengerdocker build .docker-compose builddocker-compose up -ddocker-compose exec web python manage.py makemigrationsdocker-compose exec web python manage.py migrateYou can create a superuser or run scripts using this structure:
docker-compose exec web python manage.py createsuperuserThe Swagger documentation is complete, but WebSocket integration is not included in it.
Below is an example URL for using WebSocket in chat:
ws://127.0.0.1:8000/ws/chat/?token=<user-access-token>&chat_id=<chat_id>Note: You must have an existing chat between two users, otherwise, you will receive an error.