- Send and receive messages
- Show current connection count
- Typescript
- Fastify - Backend
- Websockets - Realtime
- Next.js - Frontend
- Tailwind & Shadcn UI - Styling
- Redis - Pub/Sub
- Caddy - Load Balancer
- Docker/docker-compose - Containerization
- GitHub actions - CI/CD
- DigitalOcean - Host the backend
- Vercel - Host the frontend
git clone https://github.com/Ajaydeep123/Chat_anon.git
cd Chat_anon
- Change the url in the Caddyfile
{
debug
}
http://127.0.0.1 {
reverse_proxy chat-app-1:3001 chat-app-2:4000 chat-app-3:5000 {
header_down Strict-Transport-Security max-age=315360000
}
}
- Run the backend server
cd chatapp
pnpm install
vi run.sh // create a run.sh script and fill the details form example.run.sh file
./run.sh
- Run the client
cd ..
cd ui
pnpm install
pnpm dev
The provided code is a Node.js server built with the Fastify web framework, incorporating real-time communication with clients via websockets and using Redis as a message broker.
We are using Caddy as Load Balancer. The reverse_proxy directive in the Caddyfile is being used to distribute incoming requests evenly among the available instances of the chat application. The header_down directive can be used to set the Strict-Transport-Security header for added security.