{"id":29715637,"url":"https://github.com/danielace1/kuvaka-tech-chat-app","last_synced_at":"2025-07-24T05:38:29.358Z","repository":{"id":302072708,"uuid":"1011019745","full_name":"danielace1/kuvaka-tech-chat-app","owner":"danielace1","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-30T11:46:39.000Z","size":47,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-30T12:40:50.021Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://kuvaka-tech-chat-app.vercel.app","language":"JavaScript","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/danielace1.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-06-30T07:23:51.000Z","updated_at":"2025-06-30T12:00:18.000Z","dependencies_parsed_at":"2025-06-30T12:52:06.931Z","dependency_job_id":null,"html_url":"https://github.com/danielace1/kuvaka-tech-chat-app","commit_stats":null,"previous_names":["danielace1/kuvaka-tech-chat-app"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/danielace1/kuvaka-tech-chat-app","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielace1%2Fkuvaka-tech-chat-app","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielace1%2Fkuvaka-tech-chat-app/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielace1%2Fkuvaka-tech-chat-app/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielace1%2Fkuvaka-tech-chat-app/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/danielace1","download_url":"https://codeload.github.com/danielace1/kuvaka-tech-chat-app/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/danielace1%2Fkuvaka-tech-chat-app/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266797010,"owners_count":23985519,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-24T02:00:09.469Z","response_time":99,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"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":[],"created_at":"2025-07-24T05:38:28.795Z","updated_at":"2025-07-24T05:38:29.350Z","avatar_url":"https://github.com/danielace1.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kuvaka Tech - 💬 Real-Time Chat App\n\nA real-time chat application built using the **MERN stack** (MongoDB, Express, React, Node.js) and **WebSockets**. Users can join by entering a username and chat instantly with others in real-time. Messages are saved to a MongoDB database and chat history is automatically loaded.\n\n## Live Links\n\n- **Frontend** (Vercel): https://kuvaka-tech-chat-app.vercel.app\n\n- **Backend** (Render): https://kuvaka-tech-chat-app-backend.onrender.com\n\n## Technologies Used :\n\n- **_Frontend_**: React.js, TailwindCSS\n- **_Backend_**: Node.js, Express.js, WebSocket\n- **_Database_**: MongoDB with Mongoose\n\n## Architecture Overview :\n\n- **Frontend**: React SPA with WebSocket client\n- **Backend**: Express.js server + native WebSocket server via `ws` package\n- **Database**: MongoDB stores messages with timestamps\n- **WebSocket**: Manages real-time communication and message broadcasting\n\n## Features :\n\n- Real-time chat using WebSocket\n- Message persistence with MongoDB\n- Automatically loads previous 50 messages\n- Simple username-based entry (no authentication)\n- Graceful handling of connection/disconnection\n- Leave chat functionality with confirmation\n\n## Concurrency Handling:\n\n- A `Set` tracks all active WebSocket clients.\n- Each socket is associated with a username using a `Map`.\n- On new connection:\n  - Server receives `{ type: \"init\", username }`\n  - Sends back recent message history\n- When a user sends a message:\n  - Server saves to MongoDB\n  - Broadcasts the message to all connected clients using `WebSocket.OPEN` status\n- On disconnect:\n  - The user is removed from active socket tracking\n\n## WebSocket Communication Flow :\n\n- Client connects to WebSocket and sends `{ type: \"init\", username }`.\n- Server stores the socket-user mapping, sends recent chat history.\n- User sends a message `{ type: \"message\", message }`.\n- Server stores the message in MongoDB and broadcasts to all connected clients.\n- On disconnect, server cleans up socket-user tracking.\n\n## Assumptions \u0026 Design Choices\n\n- Messages are stored with timestamps and retrieved in order.\n- WebSocket is used natively instead of Socket.io to keep the stack lightweight.\n- A simple username-based login is used for quick entry; no authentication.\n- day.js is used for lightweight date formatting.\n- Message sending is disabled on empty input to avoid blank messages.\n- Disconnection is handled gracefully with a confirmation prompt.\n\n## Using the App :\n\n- Open the frontend URL.\n- Enter a username to join the chat.\n- Start chatting with others in real time!\n\n## Local Setup \u0026 Running Instructions\n\n### Prerequisites\n\n- Node.js \u0026 npm\n- MongoDB\n\n1. Clone the Repository\n\n```bash\ngit clone https://github.com/danielace1/kuvaka-tech-chat-app.git\n\n```\n\n2. Backend Setup\n\n```bash\ncd backend\nnpm install\n```\n\n- Configure Environment Variables:\n  _Create a .env file in the backend_\n\n```bash\nMONGO_DB_URL =\nPORT =\nCLIENT_URL =\n```\n\n- Run the backend.\n\n```bash\ncd backend\nnpm run dev\n```\n\n3. Frontend Setup\n\n```bash\ncd frontend\nnpm install\n```\n\n- Configure Environment Variables:\n  _Create a .env file in the frontend_\n\n```bash\nVITE_WEB_SOCKET_URL_PROD =\n```\n\n- Run the frontend.\n\n```bash\ncd frontend\nnpm run dev\n```\n\n- Now visit `http://localhost:5173` in your browser.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielace1%2Fkuvaka-tech-chat-app","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdanielace1%2Fkuvaka-tech-chat-app","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdanielace1%2Fkuvaka-tech-chat-app/lists"}