{"id":27946028,"url":"https://github.com/valentinocarmonas/realtimechat","last_synced_at":"2026-04-12T13:34:31.413Z","repository":{"id":291831260,"uuid":"978918891","full_name":"ValentinoCarmonaS/RealTimeChat","owner":"ValentinoCarmonaS","description":"A Real Time Chat API project","archived":false,"fork":false,"pushed_at":"2025-05-06T19:22:29.000Z","size":112,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-05-06T19:32:19.112Z","etag":null,"topics":["docker","expressjs","jwt","mongodb","mvc-pattern","nodejs","real-time-chat","socket-io","tdd-javascript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ValentinoCarmonaS.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-05-06T17:54:36.000Z","updated_at":"2025-05-06T19:22:32.000Z","dependencies_parsed_at":"2025-05-06T19:32:21.642Z","dependency_job_id":"b1521d20-079a-490b-b8ec-5b3779f7b4d7","html_url":"https://github.com/ValentinoCarmonaS/RealTimeChat","commit_stats":null,"previous_names":["valentinocarmonas/realtimechat"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ValentinoCarmonaS%2FRealTimeChat","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ValentinoCarmonaS%2FRealTimeChat/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ValentinoCarmonaS%2FRealTimeChat/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ValentinoCarmonaS%2FRealTimeChat/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ValentinoCarmonaS","download_url":"https://codeload.github.com/ValentinoCarmonaS/RealTimeChat/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252890302,"owners_count":21820365,"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","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":["docker","expressjs","jwt","mongodb","mvc-pattern","nodejs","real-time-chat","socket-io","tdd-javascript"],"created_at":"2025-05-07T13:47:39.883Z","updated_at":"2025-10-13T03:21:25.343Z","avatar_url":"https://github.com/ValentinoCarmonaS.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Real-Time Chat System\n\n![Build Status](https://github.com/ValentinoCarmonaS/RealTimeChat/actions/workflows/ci.yml/badge.svg)\n[![Codecov](https://codecov.io/gh/ValentinoCarmonaS/RealTimeChat/branch/main/graph/badge.svg)](https://codecov.io/gh/ValentinoCarmonaS/RealTimeChat)\n\nA **real-time chat application** built with **Node.js**, **Express**,\n**Socket.IO**, and **MongoDB**, enabling multiple users to send and receive\nmessages instantly in a shared chat room. It implements the **MVC** pattern,\nfeaturing a minimal frontend, persistent message storage, and easy deployment.\n\n## 🚀 Features\n\n- **Real-Time Messaging**: Send and receive messages instantly using WebSockets.\n- **Persistence**: Store messages in MongoDB for chat history.\n- **Notifications**: Alerts for user connections and disconnections.\n- **Minimal Interface**: Simple frontend with HTML, CSS, and JavaScript.\n- **Testing**: Comprehensive automated tests with Jest and Supertest (93.75%\n  branch coverage).\n- **Docker**: Containerized setup for easy deployment.\n\n## 📋 Prerequisites\n\n- **Node.js** v16+\n- **MongoDB Atlas** or a local MongoDB instance\n- **Docker** and **Docker Compose** (optional, for containerized setup)\n- Modern web browser (Chrome, Firefox, etc.)\n\n## 🛠️ Installation\n\n1. Clone the repository:\n\n      ```bash\n      git clone https://github.com/ValentinoCarmonaS/RealTimeChat.git\n      cd RealTimeChat\n      ```\n\n2. Install dependencies:\n\n      ```bash\n      npm install\n      ```\n\n3. Create a `.env` file in the root directory with:\n\n      ```bash\n      PORT=3000\n      MONGODB_URI=mongodb+srv://\u003cuser\u003e:\u003cpassword\u003e@cluster0.mongodb.net/realtime-chat?retryWrites=true\u0026w=majority\n      ```\n\n## ▶️ Running the Application\n\n- **Locally**:\n\n     ```bash\n     npm start\n     ```\n\n     The application will be available at `http://localhost:3000`.\n\n- **With Docker**:\n\n     ```bash\n     make build\n     make up\n     ```\n\n     Stop containers with:\n\n     ```bash\n     make down\n     ```\n\n## 🧪 Testing\n\nRun tests with Docker:\n\n```bash\nmake test\n```\n\nOr run tests with npm:\n\n```bash\nnpm test\n```\n\n- View detailed reports in `coverage/lcov-report/index.html`.\n\n## 📚 Main Functionalities\n\n- **User Connection**: Users enter a username and join a shared chat room.\n- **Messages**: Messages are sent in real-time, stored in MongoDB, and displayed\n  with the sender’s username.\n- **History**: Retrieve historical messages when a new user connects.\n- **Notifications**: Alerts when a user connects or disconnects.\n\n## 📡 API Endpoints\n\nThe API is deployed and accessible at https://realtimechat-59t7.onrender.com.\nThe following RESTful endpoints are available under the\n`https://realtimechat-59t7.onrender.com/api` base path. All endpoints require a\nvalid JWT token via the `Authorization Bearer` header unless otherwise noted.\n\n### 🔐 Authentication\n\n| Method | Endpoint             | Description         | Auth |\n| ------ | -------------------- | ------------------- | ---- |\n| POST   | `/api/auth/login`    | Authenticate user   | ❌   |\n| POST   | `/api/auth/register` | Register a new user | ❌   |\n\n### 👤 Users\n\n| Method | Endpoint         | Description         | Auth |\n| ------ | ---------------- | ------------------- | ---- |\n| GET    | `/api/users`     | Get all users       | ✅   |\n| GET    | `/api/users/:id` | Get a user by ID    | ✅   |\n| POST   | `/api/users`     | Create a new user   | ✅   |\n| PUT    | `/api/users/:id` | Update a user by ID | ✅   |\n| DELETE | `/api/users/:id` | Delete a user by ID | ✅   |\n\n### 🧩 Rooms\n\n| Method | Endpoint        | Description         | Auth |\n| ------ | --------------- | ------------------- | ---- |\n| GET    | `/api/room`     | Get all rooms       | ✅   |\n| POST   | `/api/room`     | Create a new room   | ✅   |\n| DELETE | `/api/room/:id` | Delete a room by ID | ✅   |\n\n### 💬 Messages\n\n| Method | Endpoint                             | Description                                 | Auth |\n| ------ | ------------------------------------ | ------------------------------------------- | ---- |\n| GET    | `/api/message?roomId=\u003cid\u003e\u0026limit=\u003c#\u003e` | Get messages for a room (requires `roomId`) | ✅   |\n| POST   | `/api/message`                       | Create a new message                        | ✅   |\n\n\u003e **Note**: Use the `roomId` query parameter to fetch messages for a specific\n\u003e room. The `limit` parameter is optional to control the number of returned\n\u003e messages.\n\n### Example Interaction\n\n```\nUser enters their name: \"Ana\"\nAna sends: \"Hello, how are you?\"\nAll users see: \"Ana: Hello, how are you?\" (stored in MongoDB)\nAna disconnects, all users see: \"Ana has disconnected\"\n```\n\nFor more details, refer to the [technical specification](docs/statement.md).\n\n## 📚 API Documentation\n\nThe API is documented using **Swagger (OpenAPI)**. Access the interactive documentation at: \n```bash\nhttp://localhost:3000/api-docs \n```\nor in production at:\n```bash\nhttps://realtimechat-59t7.onrender.com/api-docs\n```\n\nExplore endpoints, test requests, and view response examples directly in the Swagger UI.\n\n## 🗂️ Project Structure\n\n```\nRealTimeChat/\n├── backend/\n│   ├── src/\n│   │   ├── config/         # Environment and database setup\n│   │   ├── controllers/    # Business logic for WebSockets and messages\n│   │   ├── middlewares/    # Validation and error handling\n│   │   ├── models/         # MongoDB schemas for messages\n│   │   ├── routes/         # HTTP routes for frontend and auxiliary endpoints\n│   │   ├── sockets/        # WebSocket-specific logic\n│   │   ├── tests/          # Unit and integration tests\n│   │   ├── app.js          # Express application setup\n│   │   └── server.js       # Server init file\n├── .env                    # Environment variables\n├── Dockerfile              # Docker configuration\n├── docker-compose.yml      # Docker Compose setup\n├── Makefile                # Automation scripts\n└── package.json            # Dependencies and scripts\n```\n\n## 📜 License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvalentinocarmonas%2Frealtimechat","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvalentinocarmonas%2Frealtimechat","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvalentinocarmonas%2Frealtimechat/lists"}