Spring Boot application package structure - jamongx/twitter-clone GitHub Wiki

com.example.myproject
|-- MyApplication.java
|-- model
|   |-- User.java
|-- repository
|   |-- UserRepository.java
|-- service
|   |-- UserService.java
|-- controller
|   |-- UserController.java
|-- configuration
|   |-- WebConfig.java
|-- dto
|   |-- UserDTO.java
|-- exception
|   |-- UserNotFoundException.java
|-- util
|   |-- DateUtils.java
|-- security
|   |-- JwtFilter.java
|-- ...

To include this structure in your Coding Convention document:

  • Root Package:
com.example.myproject: This should contain the main class (MyApplication.java) of the application.
  • Model Package:
Contains the core domain models of the application.
  • Repository Package:
Contains the Repository interfaces related to the domain models.
  • Service Package:
Contains classes related to the service layer.
  • Controller Package:
Contains controllers that handle web requests.
  • Configuration Package:
Contains the configuration classes of the application.
  • DTO (Data Transfer Object) Package:
Contains objects used for data transfer between the client and server.
  • Exception Package:
Contains custom exceptions.
  • Util Package:
Contains general utility classes.
  • Security Package:
Contains security-related classes (e.g., JWT filter, security configuration).