HRV-Mart
Tags: githubhack23, microservices, githubactions, kafka
Published: 2023-05-08 03:22:37

## What I built 
HRV-Mart is an open-source e-commerce platform. 
### Category Submission: 
Wacky Wildcards
### App Link
Currently, front-end of application in not ready. Therefore, I am sharing GitHub link of project. [HRV-Mart-Frontend](https://www.github.com/HRV-Mart/HRV-Mart)
You can find app link in `about section` of above repository.

### Screenshots 
#### Home Page
![Home Page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k9xovq8enupucobaecjp.png)
#### Login Page
![Login Page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y6f5o31t0f9onbmnrtcx.png)


#### Product page
![Product page](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g3iyhsheqzkt94a3gzlr.png)
#### Response to Add To Cart
![Response to Add To Cart](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1n36lmjd452uqh5wt4s6.png)


### Description 
A platform where you can browse different products, add them in your cart and buy them.
### Link to Source Code 
[HRV-Mart GitHub](https://www.github.com/HRV-Mart/)
### Permissive License 
[Apache License](https://www.apache.org/licenses/)
## Background
Most of popular e-commerce platform out in market are closed-source and are not transparent. Because of which I decided to create a open-source and transparent e-commerce platform.

### How I built it
In order to create a scalable back-end I use micro-service architecture. Current version of HRV-Mart back-end consist of [Product-Microservice](https://github.com/HRV-Mart/Backend-Product), [User-Microservice](https://github.com/HRV-Mart/Backend-User), [Auth-Microservice](https://github.com/HRV-Mart/Backend-Auth), [Order-Microservice](https://github.com/HRV-Mart/Backend-Order), [Cart-Microservice](https://github.com/HRV-Mart/Backend-Cart), [Like-Micorservice](https://github.com/HRV-Mart/Backend-Like) and [API-Gateway](https://github.com/HRV-Mart/API-Gateway). Above micro-services are loosely couple and communication between them happens via [Apache Kafka](https://kafka.apache.org/). In order to make them more secure, I added unit tests. The `master` branch is protected via [branch protection rules](https://docs.github.com/en/repositories/configuring-branches-and-merges-in-your-repository/managing-protected-branches/about-protected-branches)

![Branch Protection Rules](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/92ngq8uw86k22affm59q.png)

In protection rules, I added `build workflow` in `Require status checks to pass before merging`. This is to ensure that before merging code in `master` branch, build should run successfully. I also added [Jacoco Code Coverage](https://www.jacoco.org/jacoco/) to make sure that enough unit tests are available in project and [Detekt](https://detekt.dev/) to make sure that code in project is readable. I added them in `build` configuration. Even if one of them gives error, build will fail. Whenever, someone push code in pull request, build action will run and check if build is running successfully or not.

To deploy these services, I use docker. Docker images are created with help help of GitHub Action. When someone want to deploy their code in Production, they need to create a new release. In that release, they need to specify `tag name`, `version` and `change logs`. After they clink on `Publish Release`, `docker-image` Action start running. It first build project and then build a docker image. That docker image is then publish on both `Docker Hub` and `GitHub Packages` by the workflow itself. After that, docker image from Docker Hub is pulled by `Azure Container Apps` where we also have `Kafka Container` running.

In HRV-Mart organisation, their are some libraries created which are meant to use by multiple micro-services. For example, [Custom-Pageable](https://github.com/HRV-Mart/Custom-Pageable) is use to add pagination in Backend-Product, Backend-Order, Backend-Like and Backend-Cart, [Cart-Response](https://github.com/HRV-Mart/cart-response) contains cart model, [Product-library](https://github.com/HRV-Mart/product) which contains product model, [user-library](https://github.com/HRV-Mart/user-library) is use to receive `create user request` from `auth micro-service` and [order-library](https://github.com/HRV-Mart/order-library) is use to receive order request. Both of them receive requests via Kafka. Both Cart-library and Product-library are use to calculate total cost of cart. They get data from `REST-endpoint` of Cart and Product respectively by using [API-Call](https://github.com/HRV-Mart/API-Call) library.

Here you can find the workflow templates which I used in above repositories:

- [build.yml](https://github.com/HRV-Mart/Backend-Product/blob/master/.github/workflows/build.yml)
- [publish.yml](https://github.com/HRV-Mart/API-Call/blob/master/.github/workflows/publish.yml)
- [docker-image.yml](https://github.com/HRV-Mart/Backend-Product/blob/master/.github/workflows/docker_image.yml)


### Additional Resources/Info
Managing so many repository by a single person without any help is a nightmare. Because of which, I use `GitHub project` to manage these repositories. I also integrated them with `Discord` using [web-hooks](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks). I use GitHub Issues and GitHub Pull Request a lot to keep track of the tasks which I have to do.