Skip to content

ajoshua2004/nodechat

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NodeChat

By Joshua Arrevillaga

Overview

Nodechat is a real-time peer-to-peer chat application built with Go for the backend and React for the frontend. It allows users to connect to specific peers, exchange messages, and subscribe to specific topics. This application uses SQLite for local message storage and topic-based subscription management.

Setup Instructions

Prerequisites

  • Go: Version 1.18+
  • Node.js: Version 18+
  • SQLite: Installed and configured
  • Podman or Docker

Building Locally

Backend Setup (from root)

Start a peer:

go run cmd/peer/main.go --port=<listening port> --username=<username> --api-port=<api port>

Connecting to a peer:

go run cmd/peer/main.go --port=<listening port> --username=<username> --api-port=<api port> --connect=<IP of peer>

Frontend

cd ui
npm run build

Containerization with Podman

  1. Build the image
podman build -t nodechat:latest . 
  1. Run peer A (ex. alice)
podman rm -f alice 2>/dev/null
podman run -d --name alice \
  --network host \
  -v nodechat_uploads:/app/uploads \
  -v nodechat_db:/app/databases \
  nodechat:latest \
    --port=9000 --api-port=8080 --username=alice

Alice will listen on host port 9000 for P2P and 8080 for HTTP/UI

  1. run peer B (ex. bob)
podman rm -f bob 2>/dev/null
podman run -d --name bob \
  --network host \
  -v nodechat_uploads:/app/uploads \
  -v nodechat_db:/app/databases \
  nodechat:latest \
    --port=9001 --api-port=8081 --username=bob \
    --connect=localhost:9000

Bob will listen on ports 9001 and 8081, connects to alice at localhost:9000

Usage

This is how the UI looks after running

ui

In the terminal you can use /help to repeat the use cases:

unsubscribe

To subscribe to specific topics, go to the top left bar and input the topic you want to subscribe to.

subscribe

To send topic based messages in the main chat run /topic topic_name message

Likewise to unsubscribe.

unsubscribe

About

Node chat is a peer to peer chatting application made for EC530

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published