Folder structure updates:
- Introduced
api
folder at the root of project that handles various functions in the network layer like:- Parsing requests
- Authorization
- Rendering responses etc..
- Since we are moving ahead with
gin
all the APIs defined in the service interface will have the structure:
FunctionName(ctx *gin.Context)
- Added
usecase
folder insideinternal
that houses all the functionalities defined as per business requirements. Our APIs depends on these functionalities directly. - Added
deps
folder that contains all the dependencies of our usecase as different interfaces. These interfaces are implemented by their corresponding components.
As an example, a vehicle service is created that exposes 3 APIs:
- Create Vehicle
- Get Vehicle
- List Vehicles
The above 3 APIs are 3 different business requirements and needs to be defined in the usecase
interface. To implement this, the usecase depends on vehicles
component. This component implements the VehicleRepo
dependency inside it's internal
package and exposes the functions through vehicle.MakeRepo()
.