{"id":27009611,"url":"https://github.com/shreyansh1410/codematebackend","last_synced_at":"2026-04-10T14:37:30.202Z","repository":{"id":284569606,"uuid":"954086830","full_name":"shreyansh1410/codeMateBackend","owner":"shreyansh1410","description":"Backend repo for CodeMate","archived":false,"fork":false,"pushed_at":"2025-04-03T06:46:58.000Z","size":231,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-03T07:35:43.636Z","etag":null,"topics":["aws","aws-ec2","backend","cors","expressjs","jwt-authentication","mongodb","mongoose","nodejs"],"latest_commit_sha":null,"homepage":"https://codematebackend-w3xw.onrender.com/","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/shreyansh1410.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}},"created_at":"2025-03-24T14:42:57.000Z","updated_at":"2025-04-03T06:47:02.000Z","dependencies_parsed_at":"2025-03-26T15:51:19.709Z","dependency_job_id":null,"html_url":"https://github.com/shreyansh1410/codeMateBackend","commit_stats":null,"previous_names":["shreyansh1410/codematebackend"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/shreyansh1410/codeMateBackend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shreyansh1410%2FcodeMateBackend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shreyansh1410%2FcodeMateBackend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shreyansh1410%2FcodeMateBackend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shreyansh1410%2FcodeMateBackend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shreyansh1410","download_url":"https://codeload.github.com/shreyansh1410/codeMateBackend/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shreyansh1410%2FcodeMateBackend/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260780472,"owners_count":23062040,"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":["aws","aws-ec2","backend","cors","expressjs","jwt-authentication","mongodb","mongoose","nodejs"],"created_at":"2025-04-04T10:17:53.954Z","updated_at":"2025-12-30T19:21:54.712Z","avatar_url":"https://github.com/shreyansh1410.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CodeMate - Find Your Coding Partner\n\nCodeMate is a platform designed to help developers find coding partners and collaborate on projects. It features real-time chat, user profiles, and a matching system to connect developers with similar interests and skills.\n\n## Features\n\n- 🔐 User Authentication and Authorization\n- 👤 User Profiles and Matching System\n- 💬 Real-time Chat using Socket.IO\n- 📧 Email Notifications using AWS SES\n- 🔄 Automated Tasks using Node Cron\n- 🔒 Secure Password Hashing with Bcrypt\n- 🍪 JWT-based Authentication\n- 🌐 CORS-enabled API\n- 📱 Responsive Design\n\n## Tech Stack\n\n- **Backend Framework**: Express.js with TypeScript\n- **Database**: MongoDB with Mongoose ODM\n- **Real-time Communication**: Socket.IO\n- **Authentication**: JWT (JSON Web Tokens)\n- **Email Service**: AWS SES\n- **Password Hashing**: Bcrypt\n- **API Security**: CORS, Cookie Parser\n- **Development Tools**: TypeScript, Nodemon\n\n## Detailed Technical Overview\n\n### Core Architecture\n- **Runtime Environment**: Node.js (v16+)\n- **Language**: TypeScript\n- **Framework**: Express.js\n- **Database**: MongoDB with Mongoose ODM\n- **Real-time Communication**: Socket.IO\n- **Authentication**: JWT (JSON Web Tokens)\n- **Email Service**: AWS SES (Simple Email Service)\n- **Task Scheduling**: Node Cron\n- **Security**: Bcrypt for password hashing, CORS, Cookie Parser\n\n### Key Components and Features\n\n#### User Management System\n- Comprehensive user schema with validation\n- Fields include: firstName, lastName, emailId, age, gender, skills, bio, photoURL\n- Built-in password hashing and comparison methods\n- JWT token generation for authentication\n- Email validation and uniqueness constraints\n- Age restrictions (18-150 years)\n- Skills limit (max 10 skills, 30 chars each)\n- Bio length limit (200 chars)\n\n#### Real-time Chat System\n- Secure room creation using SHA-256 hashing\n- Event handlers for:\n  - `joinChat`: Manages chat room joining with request validation\n  - `disconnect`: Handles user disconnection\n  - `sendMessage`: Manages message sending and persistence\n- Chat persistence in MongoDB\n- Request-based chat access control\n- CORS configuration for multiple origins\n\n#### Request System\n- Handles user connection requests\n- Status tracking (accepted/rejected)\n- Validation before chat access\n- MongoDB-based persistence\n\n#### Email Service\n- AWS SES integration for email notifications\n- Environment-based configuration\n- Secure credential management\n\n#### Automated Tasks\n- Node Cron implementation for scheduled tasks\n- Located in `src/utils/cronjobs.ts`\n\n### Security Features\n\n#### Authentication \u0026 Authorization\n- JWT-based authentication\n- Secure password hashing with Bcrypt\n- Token-based session management\n- Protected routes with middleware\n\n#### Data Security\n- Input validation on all models\n- Password field exclusion from queries\n- Secure room ID generation for chats\n- CORS protection with specific origins\n\n#### API Security\n- Rate limiting\n- Request validation\n- Error handling middleware\n- Secure cookie handling\n\n### Database Design\n\n#### Collections\n- Users\n- Chats\n- Requests\n- Messages\n\n#### Indexing\n- Email uniqueness index\n- Name search optimization\n- Gender-based filtering index\n\n### API Structure\n\n#### Route Organization\n- Authentication routes (`/auth`)\n- Profile routes (`/profile`)\n- Request routes (`/request`)\n- User routes (`/user`)\n- Chat routes (`/chat`)\n\n#### Middleware\n- Authentication middleware\n- Error handling middleware\n- Request validation\n- CORS handling\n\n### Development Features\n\n#### Development Tools\n- TypeScript for type safety\n- Nodemon for development\n- Environment-based configuration\n- Build process with TypeScript compilation\n\n#### Code Organization\n```\nsrc/\n├── app.ts              # Application entry point\n├── routes/            # API route definitions\n├── models/            # Database models\n├── controllers/       # Business logic\n├── middleware/        # Custom middleware\n├── utils/            # Utility functions\n└── types/            # TypeScript definitions\n```\n\n### Performance Optimizations\n- Database indexing\n- Efficient query design\n- Socket.IO room management\n- Caching considerations\n- Error handling and logging\n\n## Prerequisites\n\n- Node.js \u003e= 16.0.0\n- MongoDB\n- AWS Account (for email services)\n\n## Environment Variables\n\nCreate a `.env` file in the root directory with the following variables:\n\n```env\nPORT=5000\nMONGODB_URI=your_mongodb_connection_string\nJWT_SECRET=your_jwt_secret\nAWS_ACCESS_KEY=your_aws_access_key\nAWS_SECRET_KEY=your_aws_secret_key\n```\n\n## Installation\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/yourusername/codemate.git\ncd codemate\n```\n\n2. Install dependencies:\n```bash\nnpm install\n```\n\n3. Build the TypeScript code:\n```bash\nnpm run build\n```\n\n## Running the Application\n\n### Development Mode\n```bash\nnpm run dev\n```\n\n### Production Mode\n```bash\nnpm start\n```\n\n## API Endpoints\n\n### Authentication Routes\n- POST `/auth/register` - Register a new user\n- POST `/auth/login` - Login user\n- POST `/auth/logout` - Logout user\n- GET `/auth/me` - Get current user profile\n\n### Profile Routes\n- GET `/profile` - Get user profile\n- PUT `/profile` - Update user profile\n- GET `/profile/:id` - Get specific user profile\n\n### Request Routes\n- POST `/request` - Create a new request\n- GET `/request` - Get all requests\n- PUT `/request/:id` - Update request status\n\n### User Routes\n- GET `/user` - Get all users\n- GET `/user/:id` - Get specific user\n- PUT `/user/:id` - Update user information\n\n### Chat Routes\n- GET `/chat` - Get chat history\n- POST `/chat` - Send a message\n- GET `/chat/:id` - Get specific chat\n\n## Contributing\n\n1. Fork the repository\n2. Create your feature branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your changes (`git commit -m 'Add some AmazingFeature'`)\n4. Push to the branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n## License\n\nThis project is licensed under the ISC License - see the LICENSE file for details.\n\n## Author\n\nShreyansh Shukla\n\n## Acknowledgments\n\n- Express.js team for the amazing framework\n- MongoDB team for the database\n- Socket.IO team for real-time capabilities\n- AWS team for email services\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshreyansh1410%2Fcodematebackend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshreyansh1410%2Fcodematebackend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshreyansh1410%2Fcodematebackend/lists"}