This repository was archived by the owner on Oct 24, 2025. It is now read-only.
feat: Implement Role-Based Access Control (RBAC) with Clean Architecture - #9
Merged
Conversation
…s and ports; update DI tokens and app module
…ove favorites from user controller; wire controllers into InterfacesModule
…ser services; add isElectiveInUse check in repository
…ponents and updating user type definitions
- Create discriminated union types for UserDTO (StudentUserDTO, TeacherUserDTO, AdminUserDTO) - Add UserRole type definition for consistent role typing - Update user controller to use UserDTO import and new types - Add missing decorators (Post, Put, Patch, Delete) to controller
- Allow Partial<T> in update methods for both ElectiveRepository and UserRepository - Rename getModulesGiven to getElectivesGiven in ITeacherService port - Remove outdated comments from teacher interface - Align repository interfaces with service requirements
- Update ElectiveService.updateElective to accept Partial<Elective> - Update UserService.updateElective to accept Partial<User> - Rename TeacherService.getModulesGiven to getElectivesGiven - Add enrollment validation logic in UserService.deleteUser (TODO) - Improve service method signatures for flexibility
- Improve type safety in MongooseElectiveRepository by removing unnecessary 'as unknown' casts - Update MongooseUserRepository.update signature to accept Partial<User> - Add missing HTTP method decorators (Post, Put, Patch, Delete) to ElectiveController - Rename TeacherController method from getModulesGiven to getElectivesGiven - Update route from /me/modules to /me/electives in TeacherController - Add type annotation for Elective import in ElectiveController - Add AdminDashboard component with role-based access control
… files and consolidating favorite handling in user controller
…structure and design decisions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request introduces a major architectural refactor to the backend application, implementing Clean Architecture and Domain-Driven Design principles for role-based user management. The changes split user-related business logic into dedicated services for students and teachers, refactor the service interfaces, and add comprehensive documentation of the new architecture. This lays the groundwork for maintainable, scalable, and testable code, while improving type safety and separation of concerns.
Architecture Documentation
ARCHITECTURE.mdfile explaining the Clean Architecture layers, role-based domain modeling, project structure, authentication/authorization flow, API endpoints, testing strategy, and key design patterns.Service Layer Refactor
UserService(generic CRUD),StudentService(student favorites logic), andTeacherService(teacher electives logic). Added implementations forStudentServiceandTeacherService.Service Interface Changes
IUserServiceand moved them into new interfaces:IStudentServiceandITeacherService. This enforces single responsibility and improves type safety.Authentication Improvements
Codebase Cleanup
user.service.tsto reflect the new separation of concerns.Let me know if you’d like to walk through any part of this refactor in detail, or if you have questions about how the new architecture affects your work!