Skip to content

A complete, easy-to-use chat application using the websocket protocol.

License

Notifications You must be signed in to change notification settings

aissam-out/chat-with-sockets

Repository files navigation

Chat application with SocketIO

This project is a chat application based on websockets, it supports both private messages and chatrooms. The code also covers the registration and login processes. The database being utilized is Postgres.

Login page

Public chatrooms

After registration, user credentials will be stored in the Postgres DB. Check below to see how to setup the project.

Upon login, users are automatically redirected to the Genaral chatroom. They can change rooms, and only users in the same room can see each others' messages.

Chatrooms page

Private chat

Connected users can be viewed in the "Users" section. To initiate a private chat, simply click on a user and they will receive a notification, allowing you to start the private conversation.

Private chat page

.

Private chat page

How run the project

To run this project, you'll need to set up a Postgres DB. The easiest way to do it is to run a postgres container.

To do so, and assuming you have Docker installed in your machine, pull the posgres image docker pull postgres, then start a postgres instance docker run --name pg_instance -d -p 2023:5432 -e POSTGRES_PASSWORD=postgres postgres

Now that you have the DB up and running, you can connect to postgres using command line, or a SQL client like DBeaver, then create a "chatDB" database.

The code extracts the URI of this postgres instance from your environment variables. Thus, make sure you have an .env file containing export POSTGRES_URI="postgresql://postgres:postgres@localhost:2023/chatDB" (Also, don't forget to load the environment variables source .env before starting the app)

Run python create.py

Congrats. Everything is set up now. All you have to do is to run python app.py and enjoy :D

Aknowledgement

While learning websockets I learned a lot from this repo. Special thanks to the creator.

About

A complete, easy-to-use chat application using the websocket protocol.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published