RealChat is a real-time chat application built with Django and Django Channels. It supports user authentication, message storage, and real-time messaging.
- User Signup and Login, LogOut
- Real-time messaging using WebSockets
- Display online users
- Message history
- Python 3.10+
- Django 4.2+
- Django Channels 4.0+
-
Clone the repository:
git clone https://github.com/sumanbalayar08/RealChat.git cd RealChat
-
Install Dependencies:
pip install -r requirements.txt
-
Apply the migrations:
python3 manage.py makemigrations python3 manage.py migrate
-
Create A SuperUser:
python manage.py createsuperuser
-
Run the development server:
python3 manage.py runserver
The project structure is organized as follows:
-
Chatter/: This directory contains the Django app for the chat functionality.
- migrations/: Directory for Django database migrations.
- __init__.py: Python package initialization file.
- admin.py: Configuration for Django admin interface.
- apps.py: Configuration for Django app.
- consumers.py: WebSocket consumer for handling chat functionality.
- models.py: Definition of Django models for message storage.
- routing.py: Routing configuration for WebSocket connections.
- tests.py: Unit tests for the app.
- urls.py: URL configuration for the app.
- views.py: Views for rendering HTML templates and handling HTTP requests.
-
RealChat/: This directory contains the Django project settings and configuration.
- __init__.py: Python package initialization file.
- asgi.py: ASGI configuration for running the WebSocket server.
- settings.py: Django project settings.
- urls.py: URL configuration for the project.
- wsgi.py: WSGI configuration for running the Django development server.
-
static/: Directory for static files and images.
-
templates/: Directory for HTML templates.
-
manage.py: Django project management script for administrative tasks.
-
requirements.txt: File listing all Python dependencies required to run the project.
-
README.md: Project documentation file.
- Open your browser and navigate to the homepage.
- Click on the Sign Up link or navigate to the sign-up page.
- Fill in the required details such as username, email, password, and confirm your password.
- Click the Sign Up button to create your account.
- Navigate to the login page.
- Enter your username and password.
- Click the Log In button to access your account.
- Once logged in, you will be redirected to the chat home page.
- The chat home page displays a list of connected users who are online.
- If no users are connected, you will see a message indicating that no users are available.
- To test the messaging feature, open a different browser or an incognito window and repeat the sign-up and login process with a different username.
- Reload the browser to ensure the list of online users is updated.
- On the chat home page, click on the username of the user you want to chat with.
- This will open a chat window where you can send and receive messages.
- Type your message in the chat input field and press Enter or click the Send button to send the message.
- The message will be displayed in the chat window.
- To see messages from other users, reload the browser.
- You can repeat the process of signing up, logging in, and chatting from different browsers or devices to simulate a real-time chat environment with multiple users.
- Sign up with username1.
- Log in with username1.
- Access chat home.
- Sign up with username2.
- Log in with username2.
- Access chat home.
- In Browser 1, click on username2 and send a message.
- Reload Browser 2 to see the message from username1.
- In Browser 2, reply to the message from username1.
- Reload Browser 1 to see the reply from username2.
-
Run unit tests:
python3 manage.py test Chatter