The API is built using Clean Architecture. The principles of DIP (Dependency Inversion Principle) and DI (Dependency Injection) are utilized. The error handling structure is designed to provide maximum flexibility at the API level and convenience for the client.
- gin
- gorm
- zap
- cleanenv
- testify
- mockery
- swaggo
make up
- to start the API using docker-composemake test
- to run testsmake docs
- to generate swagger documentationmake mocs
- to generate mocks for testing
The documentation is available at the following link: http://localhost:8080/api/v1/docs/swagger/index.html
-
Use DTOs for Data Transfer: Utilize DTOs for data transfer to the storage layer, as currently, database details are leaking into the entity (gorm tags). However, this might significantly complicate the code without providing substantial benefits for such a small API, which is why it hasn't been implemented.
-
Add Health Checks: Implement health checks for the database and server, and invoke them periodically when the API is running.
-
Enhance Error Checking in Tests: In all negative test cases, do not only check for the presence of an error (using expectErr) but also ensure that the error type is verified (whether it is expected or not, and if expected, what exactly it is).
-
Add Controller-Level Tests: Implement controller-level tests using mocks for the service layer.