Moving Entities to System and Common
Understanding the Role of System and Common Projects
- Common Project:
For shared things that multiple projects can use (like tools, reusable code, or common settings).
Example: Same DTOs, enums, or helper functions used everywhere. - System Project:
For things specific to one application (like custom logic, workflows, and configurations).
Example: APIs, security settings, or how the app runs.
Before Migration (Example Project)
Example for “Model” entity
A) Steps to Move in Common Project :
1) Create a new package: “tech.gyri.example.query.model”
.
2) Move the “dto
, entity
, and repository”
objects from the “query”
package of the Example project to the newly created package “tech.gyri.example.model”
in the Common project.
3) Add a new enum to the “CDCCollectionEnum”
file and implement a corresponding function in the “CDCStreamWatcher”
file.
4) Add a new enum in the “application-common-properties”
file.
Common Project (After Migration)
B) Steps to Move in System Project :
1) Create the following packages in the System project:
tech.gyri.example.command
tech.gyri.example.framework
tech.gyri.example.query
tech.gyri.example.shared
2) Move the “model.command”
objects from the Example project to the “tech.gyri.example.command.model”
package in the System project.
3) In “tech.gyri.example.framework.common”
, create a “cache”
package and move the “RedisCacheConstants”
file there. Additionally, create another package named “exception”
and move the “ErrorCode”
file into it.
4) Move the “model.query”
objects from the Example project to the “tech.gyri.example.query.model”
package in the System project. Within this package, move only the “api
, exceptions
, and infrastructure”
sub-packages. Move the remaining sub-packages to the Common project.
5) Move the “shared.model.events”
objects from the Example project to “tech.gyri.example.shared”
in the System project.
6) Set the authority for the API in the “securityConfig”
file within the System project. Add all APIs from the Example project to the System project.
7) Register command and query components in the main
file of the System project.
8) Configure Consul in the application.properties
file.
System Project (After Migration)
Updated Example Project (After Migration)
The process of moving entities from the Example project to the System and Common projects helps achieve a more organized and modular software architecture. By distinguishing between system-specific logic and shared components, the system becomes more maintainable and scalable.