A chat app built using ReactJS, Tailwind CSS, NodeJs, ExpressJs, Socket.IO, and PostgreSQL.
- Navigate to the client directory:
cd client
- Install the dependencies:
npm install
- Run the development server:
npm run dev
- Create a
.env
file in the root directory and add the following:PG_USER=chat PG_DATABASE=chatapp PG_PASSWORD=password PG_HOST=localhost PG_PORT=5432 JWT_SECRET=mysecret
- Install the dependencies:
npm install
- Pull the Docker image for PostgreSQL:
docker pull postgres
- Run the Docker container:
docker run --name some-postgres -e POSTGRES_USER=root -e POSTGRES_PASSWORD=mysecretpassword -d postgres
- Login to the PostgreSQL CLI:
psql -U root -h localhost
- Create a new user and database:
CREATE USER chatapp WITH PASSWORD 'password'; CREATE DATABASE chatapp;
- Create the necessary tables:
CREATE TABLE users ( id UUID DEFAULT gen_random_uuid() PRIMARY KEY, name VARCHAR(100) NOT NULL, username VARCHAR(50) UNIQUE NOT NULL, password VARCHAR(255) NOT NULL ); CREATE TABLE messages ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), conversation_id UUID NOT NULL REFERENCES conversations(id), sender_id UUID NOT NULL REFERENCES users(id), content TEXT NOT NULL, created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ); CREATE TABLE conversations ( id UUID PRIMARY KEY DEFAULT gen_random_uuid(), sender_id UUID NOT NULL REFERENCES users(id), receiver_id UUID NOT NULL REFERENCES users(id), created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP );
- Grant privileges to the
chatapp
user:GRANT SELECT, INSERT, UPDATE, DELETE ON ALL TABLES IN SCHEMA public TO chatapp;
- Move to server directory
cd server
- Start the backend server:
npm start
- Open your browser and go to
http://localhost:5173
to access the website.
- Fork the repository
- Create a new branch (
git checkout -b feature-branch
) - Commit your changes (
git commit -m 'Add some feature'
) - Push to the branch (
git push origin feature-branch
) - Open a pull request
This project is licensed under the MIT License.