{"id":29027008,"url":"https://github.com/baberlabs/chatr","last_synced_at":"2026-04-12T06:31:57.047Z","repository":{"id":298682251,"uuid":"1000352378","full_name":"baberlabs/chatr","owner":"baberlabs","description":"Real-time chat application focused on backend correctness, authentication boundaries, and Socket.IO-based messaging. Built as a systems-minded learning project with strong test coverage and clear invariants.","archived":false,"fork":false,"pushed_at":"2025-12-26T18:21:54.000Z","size":438,"stargazers_count":0,"open_issues_count":5,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-12T06:31:53.663Z","etag":null,"topics":["authentication","backend-architecture","express","integration-testing","javascript","jwt","learning-project","mongodb","nodejs","react","real-time","rest-api","socket-io"],"latest_commit_sha":null,"homepage":"https://chatr.baberr.com","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/baberlabs.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,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-06-11T16:39:49.000Z","updated_at":"2025-12-26T18:25:16.000Z","dependencies_parsed_at":"2025-06-12T10:30:35.636Z","dependency_job_id":"0f76288e-be4c-443b-bd3e-14860e7a029b","html_url":"https://github.com/baberlabs/chatr","commit_stats":null,"previous_names":["baberlabs/chat-app","baberlabs/chatr"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/baberlabs/chatr","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baberlabs%2Fchatr","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baberlabs%2Fchatr/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baberlabs%2Fchatr/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baberlabs%2Fchatr/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/baberlabs","download_url":"https://codeload.github.com/baberlabs/chatr/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/baberlabs%2Fchatr/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31706764,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-12T06:22:27.080Z","status":"ssl_error","status_checked_at":"2026-04-12T06:21:52.710Z","response_time":58,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5: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":["authentication","backend-architecture","express","integration-testing","javascript","jwt","learning-project","mongodb","nodejs","react","real-time","rest-api","socket-io"],"created_at":"2025-06-26T06:01:52.893Z","updated_at":"2026-04-12T06:31:57.035Z","avatar_url":"https://github.com/baberlabs.png","language":"JavaScript","readme":"# Chatr\n\nA full-stack real-time messaging application built to explore correct backend design, authentication boundaries, and real-time communication using modern web technologies.\n\nThis repository prioritises **correctness, testability, and clear separation of concerns** over feature breadth.\n\n---\n\n## Overview\n\nChatr is a one-to-one chat application with real-time messaging, user authentication, and image sharing. It is designed as a learning and demonstration project focused on:\n\n- API correctness and error handling\n- Authentication and authorisation boundaries\n- Real-time communication with Socket.IO\n- Test-driven backend development\n- Clean frontend state management\n\nA live deployment is available at: https://chatr.baberr.com\n\n---\n\n## Tech Stack\n\n### Frontend\n\n- React\n- React Router\n- Tailwind CSS\n- Zustand (state management)\n- Socket.IO client\n\n### Backend\n\n- Node.js\n- Express\n- MongoDB with Mongoose\n- Socket.IO\n- JWT authentication (HTTP-only cookies)\n- Cloudinary (image uploads)\n\n### Testing\n\n- Jest\n- SuperTest\n- mongodb-memory-server (isolated integration tests)\n\n### Deployment\n\n- Hetzner VPS\n- Nginx reverse proxy\n- Frontend served statically via Express\n\n---\n\n## Core Features\n\n### Authentication \u0026 Users\n\n- Email-based registration and login\n- JWT authentication stored in HTTP-only cookies\n- Protected routes with explicit `401` / `403` handling\n- Profile updates and account deletion\n\n### Messaging\n\n- One-to-one real-time messaging\n- Message persistence in MongoDB\n- Deterministic message ordering\n- Message deletion with authorisation checks\n- Image messages via Cloudinary\n\n### Real-Time Behaviour\n\n- Socket.IO for instant delivery\n- Room-based chat organisation\n- Online / offline presence tracking\n- Typing indicators\n\n---\n\n## Architecture \u0026 Design Decisions\n\n### Separation of Concerns\n\n- REST API is the source of truth for persistence\n- Socket.IO is used only for delivery and presence\n- Authentication is enforced consistently at route and socket boundaries\n- Frontend state is isolated in Zustand stores rather than components\n\n### Authentication Model\n\n- JWT tokens are stored in HTTP-only cookies to reduce XSS exposure\n- Tokens are validated on every protected request\n- Socket connections rely on authenticated HTTP sessions\n\n### Message Invariants\n\n- Messages always belong to a chat\n- Only participants of a chat may read or write messages\n- Only the message author may delete a message\n- Messages are returned in a consistent, chronological order\n\n### Testing Strategy\n\n- Integration-level tests validate behaviour, not implementation\n- Each test suite runs against an in-memory MongoDB instance\n- External services (Cloudinary) are mocked to isolate side effects\n- Error conditions are explicitly tested\n\n---\n\n## API Endpoints (Summary)\n\n| Endpoint                | Method       | Description               |\n| ----------------------- | ------------ | ------------------------- |\n| `/api/v1/auth/register` | POST         | Register a new user       |\n| `/api/v1/auth/login`    | POST         | Log in                    |\n| `/api/v1/auth/logout`   | POST         | Log out                   |\n| `/api/v1/users`         | GET          | List users                |\n| `/api/v1/users/:id`     | PUT / DELETE | Update or delete user     |\n| `/api/v1/chats`         | GET / POST   | List or create chats      |\n| `/api/v1/chats/:id`     | GET          | Fetch messages for a chat |\n| `/api/v1/messages`      | POST         | Send a message            |\n| `/api/v1/messages/:id`  | DELETE       | Delete a message          |\n\n---\n\n## Project Structure\n\n```text\nbackend/\n  src/\n    controllers/\n    services/\n      domain/\n      infrastructure/\n    models/\n    routes/\n    middleware/\n    realtime/\n    utils/\n  __tests__/\n\nfrontend/\n  src/\n    pages/\n    components/\n    store/\n    lib/\n\n```\n\n---\n\n## Running Locally\n\n### Requirements\n\n- Node.js ≥ 18\n- MongoDB (local or Atlas)\n\n### Setup\n\n```bash\ngit clone https://github.com/baberlabs/chatr.git\ncd chatr\nnpm run build\n```\n\nCreate `backend/.env`:\n\n```env\nMONGODB_URI=your_mongodb_uri\nJWT_SECRET=your_secret\nCLOUDINARY_CLOUD_NAME=your_cloud_name\nCLOUDINARY_API_KEY=your_key\nCLOUDINARY_API_SECRET=your_secret\nPORT=5001\n```\n\nCreate `frontend/.env`:\n\n```env\nVITE_API_URL=http://localhost:5001/api/v1\n```\n\nStart the application:\n\n```bash\nnpm start\n```\n\nDevelopment mode:\n\n```bash\nnpm run dev\n```\n\n---\n\n## Testing\n\n```bash\ncd backend\nnpm test\n```\n\nTests run against an isolated in-memory database and do not require external services.\n\n---\n\n## Known Limitations\n\n- No group chat support\n- No message pagination\n- No retry or back-pressure handling on socket reconnect\n- Limited logging and observability\n\nThese omissions are deliberate to keep the project focused and understandable.\n\n---\n\n## Future Work\n\n- Group chats\n- Read receipts\n- Message pagination\n- Improved indexing strategy\n- Structured logging\n- Rate limiting\n\n---\n\n## License\n\n[MIT License](LICENSE)\n\n---\n\nThis project is intended as a **technical portfolio artifact**, not a production messaging platform.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaberlabs%2Fchatr","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbaberlabs%2Fchatr","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbaberlabs%2Fchatr/lists"}