typical-rest-server

The aims of project is provide simple, straight-forward and easy-to-adopt Rest-Server implementation in Go.
How to Use
- Use the project as reference for project layout and code best practice.
- The
pkg package is general library that can help in various needs
Prerequisite
Quick Start
The project using typical-go as its build-tool.
./typicalw docker up # equivalent with `docker-compose up -d` (if infrastructure not up)
./typicalw pg reset # drop, create and migrate postgres database (if database not ready)
./typicalw mock # generate mock (if require mock)
./typicalw test # run test
./typicalw run # run the application
Project Layout
internal Exclusive go source files for the project
internal/app main functionality/entry-point
internal/infra infrastructure for the project e.g. config and connection object
internal/profiler for profiling the project e.g. HealthCheck, PProf, etc
internal/server REST-Server actual code
pkg Shareable go source files e.g. helper/utitily Library
api Any related scripts for API e.g. api-model script (swagger, raml, etc) or client script
databases Any related scripts for Databases e.g. migration scripts and seed data
tools External program that used by the project
typical Build-Tool descriptor
Layered Architecture
controller
- Handling HTTP routes
- Parsing the request
- Sending response (both success & error)
service
- Intermediary between controller (end-point) and repository (data)
- Logic of controller
- Data Validation
- DTO (Data Transfer Object) Model
repository
- Data access layer
- No logic except operation to database
- Repository pattern
- DAO (Data Access Object) Model
- Database Entity or Business Entity
Annotations
The project utilize Typical-Go annotation for code generation
@ctor functions will be provided in dig service-locator
@dtor functions will be execute when program end
@mock interfaces is target for mock generation
Configurations
Config in environment as 12factor recommentation. The build-tool (typical-go) will load values in .env file and generated it if not available.
Simple CLI to prepare the database learn more
./typicalw pg
Pkg Library
3rd Party Library
Concepts
Golang References
Project Status
The project status is WIP (Work in progress), means the author plan to continously improve and add more best-practices.
License
This project is licensed under the MIT License - see the LICENSE.md file for details