Skip to content

fix(architecture): adapt for clean architecture#86

Closed
MayuriXx wants to merge 1 commit into
mainfrom
fix(architecture)
Closed

fix(architecture): adapt for clean architecture#86
MayuriXx wants to merge 1 commit into
mainfrom
fix(architecture)

Conversation

@MayuriXx

@MayuriXx MayuriXx commented May 4, 2026

Copy link
Copy Markdown
Collaborator

🏗️ Refactoring Clean Architecture

Context

Following an architecture review, several Clean Architecture violations were identified and fixed, along with technical improvements listed in the issue.


Changes

🔁 Renames

  • LocalUserServiceUserService (domain/services/) — the "Local" prefix was redundant for a domain service interface
  • User (JPA entity) → UserDao (data/models/database/) — clearly distinguishes the persistence model from the domain model (UserEntity)
  • feature/ directoryfeatures/ (src/test/java/) — consistency with the .feature files directory (src/test/resources/features/)

🆕 New files

  • presentation/dto/UserDTO.java — HTTP response DTO, decouples domain entities from the API contract
  • presentation/dto/UserRequestDTO.java — HTTP input DTO (moved from domain/entities/UserRequest.java)
  • presentation/dto/UserRequestDTO.java — HTTP input DTO (moved from domain/entities/UserRequest.java)
  • presentation/mappers/UserMapper.java — static mapper UserEntityUserDTO
  • domain/services/UserService.java — domain service interface (replaces LocalUserService)
  • data/models/database/UserDao.java — renamed JPA entity (replaces User.java)
  • data/sources/api/UserApiConfig.java — unified Retrofit configuration (merges DummyUserApiConfig + RandomUserApiConfig)
  • config/UseCaseConfig.java — Spring @Bean declarations for all use cases, replacing @Service annotations in the domain layer

✏️ Structural changes

  • UserRequest removed from domain: CreateUserUseCase and UpdateRandomUserUseCase now accept a UserEntity (with null id); the mapping from UserRequestDTO is handled in UserHandler via toUserEntity()
  • @Service removed from use cases (domain/usecases/): the domain layer no longer depends on the Spring Framework
  • Database-level pagination on filterUsers: UserService.filterUsers(UserFilter, int page, int size) uses PageRequest + JpaSpecificationExecutor to paginate directly in the database (Page<UserDao>)
  • Spring Pageable on getRandomUsers and filterUsers: page/size parameters are injected via @PageableDefault — both endpoints now return a paginated UserResponseDTO
  • Domain entities no longer cross the HTTP boundary: all endpoints return UserDTO or UserResponseDTO

🗑️ Deleted files

  • data/models/database/User.java
  • domain/entities/UserRequest.java
  • domain/services/LocalUserService.java
  • data/sources/api/dummy/DummyUserApiConfig.java
  • data/sources/api/randomuser/RandomUserApiConfig.java

🧪 Tests

  • All unit tests updated (UserHandlerTest, UserServiceImplTest, UserConverterTest, UserSpecificationsTest, use cases, Cucumber)
  • UserGetByIdContainerTest migrated to UserDao and UserDTO
  • 78 tests — 0 failures, 0 errors

@MayuriXx MayuriXx linked an issue May 4, 2026 that may be closed by this pull request
@MayuriXx MayuriXx force-pushed the fix(architecture) branch from 514c7a3 to f79e558 Compare May 5, 2026 10:11
@sonarqube-xpeho

Copy link
Copy Markdown

@MayuriXx MayuriXx closed this May 5, 2026
@MayuriXx MayuriXx deleted the fix(architecture) branch May 5, 2026 10:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant