- This is a RESTful API written in Go (1.14);
- Data is persisted through a JSON file;
- The endpoints are documented using Swagger and can be tested using the Postman collection and the environment attached;
Command | Description |
---|---|
$ make run |
Run app (development mode) * |
$ make run-native |
Run app (locally in your machine) * |
$ make build |
Build source code |
$ make shutdown |
Shutdown app (development mode) |
$ make test |
Run tests |
$ make doc |
Generate swagger doc files ** |
$ make format |
Format code |
$ make lint |
Run linter |
$ make audit |
Audit dependencies |
* runs development image (with environment variables)
** once the server is running locally, the Swagger docs can be seen here
- Gingonic was used as the HTTP web framework, for its benchmarked performance (avoiding reflection and a small memory footprint, and with an efficient router);
- A MVC architecture was followed, in which the model defines the entities in the given domain; the controller exposes an interface to deal with the entities, and the view (or services, as they are called here) provide the business rules for the manipulation and presentation/visualization of the entities.
- This approach keeps the code more modular (with separation of concerns), extensible and decoupled, improving developers' experience.
Folder/File | Description |
---|---|
main.go |
Entry point for the app; starts application. |
app/ |
Defines the HTTP server; maps the URLs. |
controllers/ |
Defines the functions called for each of URLs; they handle HTTP requests and respond to them. |
services/ |
Defines and apply business rules. |
domain/ |
Defines the data models of the domain, some related utilities and CRUD operations. |
utils/ |
Defines utility functions. |
logger/ |
Sets up the logger, defined as a global variable. |
docs/ |
Documentation files generated by Swagger. |
- Use document based database (e.g. MongoDB) to store data.
- Add performance tests;