-
What we will see?
- Clean code
- Use of https://grpc.io/
- Use of https://go-chi.io/#/
- Use of https://gorm.io/docs/
- Database Integration
- Unit Tests
-
Not a requirement, but will be good to see if possible:
- Use of https://github.com/swaggo/swag and a public swagger documentation
- The Docker file with the
PostgresSQl,service, andAPIs
One of our customers bought a TVBox display, which can call APIs and display some books, a random book need to be displayed at the TVBox with the last book displayed (except at the first API request), and the TVBox will send this in an interval of 1m, the customer wants every next book not to be among the last 10 books displayed.
- The customer will send a request to our public service, and we need to provide some books about "Dungeon&Dragons" to be displayed on a TVBox at the company reception
- He sent to us a list of the books he needs (see create_database.sql)
- The customer will need one public API with a
hashauthentication at the request header, just for authentication
// All endpoint at public
// api need a header: "api-Key: string"
//
// +-------------+ +---------------+
// +-------------+ | | | |
// | | | | | | +---------------+
// | User | | | | Private | | |
// | |<----------| Public |<--------------| API |------>| Database |
// | +---------->| +-------------->| |<------| |
// | | | Api | GRPC | GRPC | +---------------+
// | | | | | only |
// | | | | | |
// +-------------+ | | | |
// +-------------+ +---------------+
- Create a user hash to use at the
bodyheader- Key:
Api-Key- Type:string
- Key:
- Each endpoint will need to be validated with the Authentication Key given in the request header
- The first book displayed doesn’t need to have a latest_book
- The public-api will call the Private API GRPC service
- The public-api will call the Private API GRPC service
You can generate the service with the private-service.proto file
- Get the next random book
- Update the flag
actual_booktotruefor the selected book - Update the flag
actual_booktofalsefor all other books - Make sure the book are not in the latest 10 books.
- Update the flag
- If is the first call, the
latest_bookcan be empty
- Get one book by
book_idfrom the database the book details and return it.
- Request:
curl -X GET 'https://localhost:9191/api/v1/books/random-one' -H "Auth-Key: HUAKAs123ASdk123lDIOQ"- Return (example):
{
"random_book": {...},
"last_book": {...}
} When the user select (touch) at the TVBox display to expand the book details, we will need more details about the book
- Request
curl -X GET 'https://localhost:9191/api/v1/books/{book_id}' -H "Auth-Key: HUAKAs123ASdk123lDIOQ"