The Book Lender API - Powered by Low-Code, deployed by code
Tags: azuretrialhack, azure, terraform
Published: 2022-03-08 22:42:42

### Overview of My Submission
This project has kept me busy over the last few days, and is probably going to keep me busy for the next few weeks 😅

The global idea is to help a small group of people to lend books to each other and to track who each book is lent to.
The inspiration behind this comes from my wife who is running an association with four of her friends.  
This association aims to help parents in our locality whose children have neurodevelopmental disorders, by creating social link, organizing events to gather the families, help them to get in touch with the right people.  
If you understand French and want to know more about the association you can check their FB page [here](https://www.facebook.com/parentaisesolidaire/).

So globally the association is ran by 5 persons, and has a few dozen of members. The people running the association have several books that they lend to the other members, and it's getting difficult to track where the books are.  
They could have used a spreadsheet for this but my wife asked me if I could build something better 😊  

Technically the app is composed of a frontend powered by VueJs 3 and Bootstrap 5, an API built with Azure Logic Apps exposed through Azure API Management and the data is stored in Cosmos Db. As I still have a ton of work to do on the frontend I have decided to scope my submission to the backend side of the project. 
I have probably over-estimated my frontend skills for this project, which are closed to zero as I'm a backend developer who is currently working in an infrastructure team. But I have stepped out of my comfort zone and learned a lot over the last few days, and will continue to do so. 

### Submission Category: 

Low-Code Legends

As I've written on the project's readme, I have hesitated a bit before choosing a category, I hope my submission is compliant with this one 🤞

### Link to Code on GitHub

{% github https://github.com/xaviermignot/book-lender-app %}

### Additional Resources / Info

The app's design is centered around the following principles:
- Optimized for use on a smartphone, with a few use cases: lend a book, list the books, and return a book
- Use the camera to scan the ISBN bar codes already present on the books (trying to avoid the use of the keyboard at most)
- From a ISBN code, the information of a book can be retrieved using an external source like Google Books API

This diagram shows the whole architecture of the project:
![Architecture diagram](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/r37jwxzauhm1g6auwup3.png)

#### Introducing... Low-Code as Code

As I have mentioned in previous posts I try to deploy the Azure resources of my projects using IaC, mostly Terraform, and for this one the Logic Apps was more challenging than usual.
I have described in the project's [readme](https://github.com/xaviermignot/book-lender-app#deploying-logic-apps-using-terraform) on how I have overcome theses challenges.  

The Logic Apps themselves are not very complicated, here is a screenshot of the designer showing a snippet of the "Get book by ISBN" workflow when the data is either retrieved from Google Books API or from Cosmos Db:

![Logic Apps designer](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ko0i5esvlqjcdn5ty1f.png)

#### Exposing the Logic Apps using API Management

Importing the Logic Apps in API Management turns a bunch of isolated Logic Apps into a single API definition:
![APIM](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3cyt969361v43083w7a2.png)

So that the Logic Apps can be called as an API using tools like Postman or Rest-Client in VS Code:
![Rest Client](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/7qx0uiiq6un1dgaa5xm5.png)

Using API Management in the consumption tier brings the following features:
- Protect the API using policies, from CORS to rate limits
- Manage API keys for apps and other consumers of the API
- Adding a custom domain with a managed certificate (currently in preview)

#### A quick view of the frontend

Last but not the least I have uploaded this quick video to share my progress on the frontend side (be gentle):
{% youtube https://youtu.be/SkUV__KrKTA %}

The scanning UI is brought by [this awesome lib](https://github.com/mebjas/html5-qrcode). Once the scan is complete, the API is called and the result is quickly displayed in the view. 
Of course this will be improved in the upcoming weeks, this project will live beyond the Azure Trial Hackathon, as it's a real world project and people are waiting for me to finish this 🤗

Thanks for reading !