## Aqarsas Microservice
**Problem**
To Implement two endpoints using golang as core;
1. For the first task Your job to implement /hai/ endpoint that accepts any of the three parameters (id - hai - city) and return hai data in JSON format. You have to query the database to get the results. Additionally, string parameters (hai-city) may contain part or full expected string, and you have to search the database for a possible list of matches.
2. For the second task Your job to implement /haicounter/ endpoint that returns list of cities and number of hais in each city. You have to query the database to get the results.
**Implementation**
I have solved the given problem using a five-layer approach as following;

**api_call->endpoint->handler->service->database->Model**
This approach helps in mainting clean code along with unit-tests at different layers. For the given task, I have implemented unit-testing at main-body and database layer. Following are the unit-test execution snapshots;
#### **Database Unit Testing**

#### **Endpoints Unit Testing**

#### **Use Cases**
Considering the first endpoint ***/hai/***, all the mentioned use-cases are covered that are;
1. To show result for id parameter
2. To show result for city parameter
3. To show result for hai parameter
4. To show result for city and hai paramter
Adding some snapshots for given endpoints calls;
### 1. **localhost:3333/haicounter/**

### 2. **localhost:3333/hai/?id=4**

### 3. **localhost:3333/hai/?hai=م

### 4. **localhost:3333/haicounter/ (Method:POST)**

---
### 5. **localhost:3333/simsim (checking for path restriction)**

The microserice can be further improved as follows;
1. golangci-lint for code standarization check
2. Make file for automation
3. Runtime DB instantance initialization
4. adding logs
5. Dockerization