Skip to content

fix(architecture): adapt for clean architecture#88

Closed
MayuriXx wants to merge 1 commit into
mainfrom
fix/architecture
Closed

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

Conversation

@MayuriXx

@MayuriXx MayuriXx commented May 5, 2026

Copy link
Copy Markdown
Collaborator

🔁 Renames
LocalUserService → UserService (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/ directory → features/ (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 UserEntity → UserDTO
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)
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

@sonarqube-xpeho

Copy link
Copy Markdown

@MayuriXx MayuriXx closed this May 5, 2026
@MayuriXx MayuriXx deleted the fix/architecture branch May 5, 2026 10:25
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