The BookServices project is a set of microservices that enables users to manage books and user data. The project consists of three main services: bookservices-api-gateway, bookservices-books, and bookservices-users. In the BookServices project, Coreography pattern is used as part of the Saga Pattern. In the project, bookservices-api-gateway acts as the central communication and control point, forwarding external client requests and responses to internal microservices. Coreography pattern is used to ensure that each microservice can handle its own transactional part independently, while bookservices-api-gateway coordinates and orchestrates them to achieve the overall goal.
Internal communication between services is done through gRPC, using the ProtoBank contract from bookservices-protobank. The gRPC protocol implements tokens to ensure the security of services against unauthorized access. External communication is done via REST API, which is processed through bookservices-api-gateway, and then forwarded to microservices using gRPC. JWT is used to ensure the security of external communication.
Each service has its own database using PostgreSQL, and GORM is used to access these databases using Object Relational Mapping (ORM).
- PosgreSQL Database
- Go 1.20 or newer
- Go protobuf compiler (protoc)
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
- Begin by cloning the repository to your local machine.
- Set up a PostgreSQL database and create the necessary tables.
- Create an environment file by duplicating the .env.example file and filling in the required values for each service according to your needs.
- Install the necessary dependencies.
go get all
- Migrate database.
go run main.go db:migrate
- Generate Go code from the proto file.
make run-proto
- To start the service with REST API.
go run main.go
- To start the service with gRPC.
run go run main.go grpc:start
To make it easier for you to try the endpoint service, please use the "Run in Postman" button which you can click to directly open Postman with the configured environment and collections.
By using Postman, you can easily execute endpoint services and see the response results in a format that is easy to read and understand. You can also test the various types of requests supported by the endpoint service, such as GET, POST, PUT, DELETE, etc.
Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are greatly appreciated.
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "ENCHANCHEMENT". Don't forget to give the project a star! Thanks again!
- Fork the Project
- Create your Feature Branch (
git checkout -b feature/AmazingFeature
) - Commit your Changes (
git commit -m 'Add some AmazingFeature'
) - Push to the Branch (
git push origin feature/AmazingFeature
) - Open a Pull Request
Many Thanks to Ach Jailani who let me use his grpc boilerplate for this project.
Adi Khoiron Hasan - [email protected]
- go-simple-grpc https://github.com/achjailani/go-simple-grpc
- service-api-gateway https://github.com/AdiKhoironHasan/bookservices-api-gateway
- service-book https://github.com/AdiKhoironHasan/bookservices-users
- service-user https://github.com/AdiKhoironHasan/bookservices-books
- protobank https://github.com/AdiKhoironHasan/bookservices-protobank