This project is a challenge designed to test your skills in Go, Docker, and various types of APIs. The goal is to create a system for managing orders, with a REST API, a gRPC service, and a GraphQL server. You will also need to set up a database using Docker and create the necessary database migrations.
The challenge is divided into several parts:
- Setting up the project and the Dockerized database.
- Creating the REST API endpoint for listing orders.
- Implementing the ListOrders service in gRPC.
- Creating the ListOrders query in GraphQL.
- Writing the necessary database migrations.
- Documenting your work in a README file, including the GraphQL queries.
This project is a Go application that provides a REST API, a gRPC service, and a GraphQL server for managing orders. It uses Docker for setting up the database.
- Docker
- Go 1.16 or later
- Clone the repository:
git clone https://github.com/obrunogonzaga/cleanArch.git
cd cleanArch- Build and run the Docker containers:
docker-compose up -d| This will start the PostgreSQL database.
- Run the database migrations:
make migrateup- Start the Go application:
make startThe application will start and listen on the following ports:
- REST API: Port defined in configs.WebServerPort
- gRPC Service: Port defined in configs.GRPCServerPort
- GraphQL Server: Port defined in configs.GraphQLServerPort
To list all orders, send a GET request to /orders.
The gRPC service provides a ListOrders method in the OrderService.
The GraphQL server provides a listOrders query and a createOrder mutation.
listOrders Query
query queryOrders {
listOrders {
id
Price
Tax
FinalPrice
}
}createOrder Mutation
mutation createOrder {
createOrder(input: {id: "eeeeee", Price: 12.2, Tax: 1.0}) {
id
Price
Tax
FinalPrice
}
}To test the application, you can use the provided api.http file, which contains HTTP requests for creating and listing orders.
This project is licensed under the MIT License.