{"id":30327391,"url":"https://github.com/mobasirsarkar/chatservice","last_synced_at":"2026-05-06T17:34:53.609Z","repository":{"id":309380893,"uuid":"1036056458","full_name":"MobasirSarkar/chatservice","owner":"MobasirSarkar","description":"A real-time multi-server chat application built with Go, NATS, WebSockets, and React (Vite). Supports cross-server communication, room-based messaging, and persistent chat history. Designed to showcase distributed systems, WebSocket handling, and scalable backend architecture","archived":false,"fork":false,"pushed_at":"2025-08-11T14:32:55.000Z","size":8366,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-08-11T16:09:52.819Z","etag":null,"topics":["golang","multi-server","nats","react","server","websockets"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MobasirSarkar.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-08-11T13:48:07.000Z","updated_at":"2025-08-11T14:32:58.000Z","dependencies_parsed_at":"2025-08-11T16:20:56.315Z","dependency_job_id":null,"html_url":"https://github.com/MobasirSarkar/chatservice","commit_stats":null,"previous_names":["mobasirsarkar/chatservice"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/MobasirSarkar/chatservice","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MobasirSarkar%2Fchatservice","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MobasirSarkar%2Fchatservice/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MobasirSarkar%2Fchatservice/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MobasirSarkar%2Fchatservice/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MobasirSarkar","download_url":"https://codeload.github.com/MobasirSarkar/chatservice/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MobasirSarkar%2Fchatservice/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32704577,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-06T08:33:17.875Z","status":"ssl_error","status_checked_at":"2026-05-06T08:33:17.221Z","response_time":117,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["golang","multi-server","nats","react","server","websockets"],"created_at":"2025-08-18T00:40:26.137Z","updated_at":"2026-05-06T17:34:53.591Z","avatar_url":"https://github.com/MobasirSarkar.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# 🚀 Multi-Server Chat Application (Go + React + WebSocket + NATS)\n\nA real-time chat system built with **Go** (backend) and **React** (frontend), powered by **WebSockets** for instant communication and **NATS** for multi-server message broadcasting.\n\nThis project demonstrates:\n- Multi-server WebSocket chat with NATS as the message bus\n- Custom React hooks for managing chat connections\n- Graceful server shutdown handling in Go\n- Modular, production-ready architecture\n\n---\n\n## 📺 Demo Video\nhttps://github.com/user-attachments/assets/0b874bba-29f1-4808-bfe1-59a024781436\n## 🛠 Tech Stack\n\n### Backend\n- **Go** – High performance server\n- **NATS** – Lightweight messaging system for multi-server pub/sub\n- **WebSockets** – Real-time bidirectional communication\n- Graceful shutdown handling\n\n### Frontend\n- **React + TypeScript**\n- **@tanstack/react-router**\n- **Custom Hooks** (`useChatSocket`)\n- Tailwind CSS styling\n\n---\n\n## 📂 Project Structure\n```\nserver/\n  ├── main.go                # Server entrypoint\n  ├── internal/\n  │    ├── server/           # HTTP + WebSocket handling\n  │    └── nats/              # NATS connection wrapper\nfrontend/\n  ├── src/\n  │    ├── hooks/            # useChatSocket.ts\n  │    ├── routes/           # /chat route\n  │    └── components/       \n```\n\n---\n\n## 🚦 Getting Started\n\n### 1️⃣ Run NATS\n```bash\ndocker run -p 4222:4222 nats\n```\n\n### 2️⃣ Start Multiple Servers\n```bash\ncd server\ngo run main.go server1   # :8080\ngo run main.go server2   # :8081\ngo run main.go server3   # :8082\n```\n\n### 3️⃣ Start the Frontend\n```bash\ncd frontend\nnpm install\nnpm run dev\n```\n\n### 4️⃣ Connect Clients\nExample WebSocket URLs:\n```\nws://localhost:8080/ws?token=user:alice\nws://localhost:8081/ws?token=user:bob\nws://localhost:8082/ws?token=user:charlie\n```\n\n---\n\n## ✨ Features\n- **Multi-server chat**: Join from any server and message broadcasts to all.\n- **Room support**: Currently defaults to `general`, but can be extended.\n- **Persistent messages**: Uses `localStorage` to keep messages across reloads.\n- **Automatic reconnect**: Gracefully handles page refresh or network hiccups.\n- **Custom React hook**: Encapsulates WebSocket logic (`useChatSocket`).\n\n---\n\n## 📌 Example\n### Sending a message:\n```json\n{\n  \"action\": \"message\",\n  \"room\": \"general\",\n  \"type\": \"chat\",\n  \"payload\": {\n    \"text\": \"Hello from Alice!\",\n    \"user\": \"alice\"\n  },\n  \"client_id\": \"client-123456789\"\n}\n```\n\n---\n\n## 💡 Notes\n- For a production-grade system, use **server-side message history** (database) and replay on reconnect.\n- Authentication here is **demo-only** via `token=user:name` — not secure for production.\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmobasirsarkar%2Fchatservice","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmobasirsarkar%2Fchatservice","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmobasirsarkar%2Fchatservice/lists"}