/django_chatroom

Chatroom webapp created with Django and React

Primary LanguageJavaScript

logo

logo

Code style: black Code style: black Node.js CI Django CI/CD Workflow


Chat Application with Django and React

AboutWhat I Have LearnedDevelopmentDeploymentTechnical Decisions

About

This is a simple chat application that uses Django (with Channels) as a backend and React as a frontend.

Goal of this project: This was my introduction project to Channels (WebSockets).

What I Have Learned

This project was created because I wanted to learn the basics of the WebSockets (and Channels module).

Development

Running backend

The backend was implemented in Python (Django) with Channels for WebSockets connections.

  1. Change directory to backend with cd backend
  2. Create a virtual environment with virtualenv .venv.
  3. Activate venv with .venv\Scripts\activate.bat.
  4. Install requirements with pip install -r requirements.txt
  5. Perform Django migrations with python manage.py migrate
  6. Run server with python manage.py runserver.

The server should be running on 127.0.0.1:8000. Go to /chat/default/ to access Django view (basic frontend) of default chatroom.

Running frontend

The frontend application was written in React.

  1. Change directory to the frontend with cd frontend.
  2. Install requirements with npm install.
  3. Run frontend application with npm run start.

The frontend application should be available on 127.0.0.1:3000 if you configured .env properly.

Environmental variables

Currently, .env file in the frontend directory is used to defining the host and port for the frontend application. I've changed it to 127.0.0.1 for more consistency with backend app.

Deployment

I've managed to deploy it to Heroku. It requires Redis configuration.

⚠️ Alert:

I've temporarily removed Redis add-on from Heroku as I have problems with theirs billing system.

Technical Decisions

  1. One repository two projects: as it was only learning purpose project I thought the monorepo structure would be good enough.
  2. No docker: didn't need it.
  3. No tests: I have not written tests here as it was not the goal of the project. If you want to check how i write tests look at react-django-todoist or react-fastify-smarthome. Channels has a good documentation on testing. It can be accessed here.

Screenshots

logo

logo