{"id":24745941,"url":"https://github.com/vishwa-glitch/user-management","last_synced_at":"2026-04-09T02:31:57.912Z","repository":{"id":273564170,"uuid":"920093585","full_name":"vishwa-glitch/User-management","owner":"vishwa-glitch","description":"A RESTful API for user management with features like registration, authentication, profile updates, account deactivation, and admin controls. Built with Node.js, Express, and MongoDB, featuring JWT authentication and secure role-based access.","archived":false,"fork":false,"pushed_at":"2025-01-22T14:20:39.000Z","size":26,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-23T00:24:56.489Z","etag":null,"topics":["backend","express-js","jwt-authentication","mongodb","nodejs","restful-api"],"latest_commit_sha":null,"homepage":"","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/vishwa-glitch.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-01-21T14:56:02.000Z","updated_at":"2025-01-22T14:20:42.000Z","dependencies_parsed_at":"2025-01-21T17:33:36.433Z","dependency_job_id":"1af45415-f91f-477b-b028-10b232a6b326","html_url":"https://github.com/vishwa-glitch/User-management","commit_stats":null,"previous_names":["vishwa-glitch/user-management"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/vishwa-glitch/User-management","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vishwa-glitch%2FUser-management","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vishwa-glitch%2FUser-management/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vishwa-glitch%2FUser-management/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vishwa-glitch%2FUser-management/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/vishwa-glitch","download_url":"https://codeload.github.com/vishwa-glitch/User-management/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/vishwa-glitch%2FUser-management/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31582632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-08T14:31:17.711Z","status":"online","status_checked_at":"2026-04-09T02:00:06.848Z","response_time":112,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","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":["backend","express-js","jwt-authentication","mongodb","nodejs","restful-api"],"created_at":"2025-01-28T03:32:11.110Z","updated_at":"2026-04-09T02:31:57.897Z","avatar_url":"https://github.com/vishwa-glitch.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# User Management System API\n\nA RESTful API built with Node.js, Express, and MongoDB for managing users and admin functionality. This project was developed as part of a Backend Developer Internship assignment.\n\n## Assignment Objective\n\nCreate a RESTful API for User Management System that demonstrates understanding of backend development principles and problem-solving skills.\n\n## Features Required\n\n1. **User Registration**\n   - Users can create account with name, email, password, phone number\n   - Input validation for email format and password length\n   - Prevention of duplicate email registrations\n\n2. **User Authentication**\n   - Login functionality using email and password\n   - Proper error handling for invalid credentials\n\n3. **Profile Management**\n   - Users can view their details (name, email, phone number)\n   - Users can update their profile information\n\n4. **Account Deactivation**\n   - Users can deactivate their accounts\n   - Implemented using soft delete approach (maintaining data but preventing login)\n\n5. **Super Admin Features**\n   - Special access to view all users' details\n   - Secure admin authentication system\n   - Uses same database model with role-based access\n\n## Tech Stack\n\n- Node.js\n- Express.js\n- MongoDB\n- JWT for Authentication\n- bcrypt for Password Hashing\n\n## Installation\n\n1. Clone the repository\n```bash\ngit clone https://github.com/vishwa-glitch/User-management\ncd src\n```\n\n2. Install dependencies\n```bash\nnpm install\n```\n\n3. Set up environment variables in `.env`\n```env\nPORT=3000\nMONGODB_URI=mongodb://localhost:27017/user-management\nJWT_SECRET=your_jwt_secret_key\n```\n\n4. Start the server\n```bash\nnode server.js\n```\n\n## API Endpoints\n\n### Authentication\n```bash\nPOST /api/auth/register\n{\n    \"name\": \"Test User\",\n    \"email\": \"user@test.com\",\n    \"password\": \"password123\",\n    \"phoneNumber\": \"1234567890\"\n}\n\nPOST /api/auth/login\n{\n    \"email\": \"user@test.com\",\n    \"password\": \"password123\"\n}\n```\n\n### User Routes (Protected)\n```bash\nGET /api/users/me\nPATCH /api/users/update-me\nDELETE /api/users/deactivate\n```\n\n### Admin Routes (Protected)\n```bash\nGET /api/admin/users\nGET /api/admin/dashboard\nPATCH /api/admin/users/:userId/status\n```\n\n## Key Design Decisions\n\n1. **Account Deactivation Strategy**\n   - Implemented soft delete using isActive flag\n   - Preserves user data while preventing access\n   - Better for data analysis and recovery\n\n2. **Super Admin Implementation**\n   - Single user model with role-based access\n   - Admin created through setup script\n   - Secure and maintainable approach\n\n## Data Validation\n\n- Email format validation\n- Password minimum length (8 characters)\n- Phone number format validation\n- Unique email constraint\n- Required field validation\n\n## Error Handling\n\n- Graceful error messages\n- Proper HTTP status codes\n- Validation error responses\n- Authentication error handling\n\n## Testing\n\nImport the provided Postman collection to test all endpoints:\n1. Register new users\n2. Test authentication\n3. Test protected routes\n4. Test admin features\n\n## Security Features\n\n- Password hashing\n- JWT-based authentication\n- Role-based authorization\n- Input sanitization\n- Protected routes middleware\n\n## Project Structure\n```\nuser-management-system/\n├── src/\n│   ├── config/\n│   ├── controllers/\n│   ├── middleware/\n│   ├── models/\n│   ├── routes/\n│   ├── utils/\n│   ├── app.js\n│   └── server.js\n├── .env\n└── package.json\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvishwa-glitch%2Fuser-management","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvishwa-glitch%2Fuser-management","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvishwa-glitch%2Fuser-management/lists"}