Skip to content

This is a REST API mini-project created for Deall Application Proccess for Backend Engineer position. The project is created in Go Programming Language and uses MySQL as the RDBMS.

Notifications You must be signed in to change notification settings

daffaalex22/seleksi-deall

Repository files navigation

REST API

By: Daffa' Alexander, for Deall Backend Engineer Application Process (Technical Assessment)


Key Points

  • The API hasn't deployed on a VPS as requested (only locally using minikube, yaml files for the API and the database are attached). To compensate for this, the author adds some additional features including:

  • The screenshot for proof of local deployment is attached here inside the local-deployment-screenshots folder. View it according to the sorted order.

  • The Architecture Diagram can be accessed on Figjam. It is also attached inside the root folder as local-architecture-diagram.png.

  • The API Documentation is accessible here

  • Admin credential is the following

email: admin@gmail.com

password: deall123

  • User credential is the following

email: user@gmail.com

password: deall123

Description

This is a REST API mini-project created for Deall Application Proccess for Backend Engineer position. The project is created in Go Programming Language and uses MySQL as the RDBMS. The project is using Uncle Bob's Clean Architecture of Systems. See more here. Without further ado, lets jump right in into the contents.

Tech Stacks

As previously mentioned, the project is created using Go Programming Language and MySQL RDBMS. The Technologies/Libraries use in this project are followings:

Testing & Utilities:

Deployment:

  • Docker
  • Minikube for Local Kubernetes Cluster

Accessing The API

The API Documentation can be accessed here.

Local

Deploying the project locally is pretty straightforward. Follow the How To Deploy The Project Locally part and access with routes provided in the API Documentation.

Running Locally

It can be also ran without Docker or Kubernetes.

  1. Clone the repo.
  2. Provides the following environment variables. Make sure MySQL is installed and schema created. Type those values in to their respective variables.
DB_URL=localhost:3306
DB_USER=<<YOUR_MYSQL_USERNAME>>
DB_PASSWORD=<<YOUR_MYSQL_PASSWORD>>
DB_NAME=<<YOUR_CREATED_DB>>

Or use the following launch.json for running on debug mode on vscode:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "${workspaceFolder}/main.go",
            "cwd": "${workspaceFolder}",
            "env": {
                "DB_URL": "localhost:3306",
                "DB_USER": <<YOUR_MYSQL_USERNAME>>,
                "DB_PASSWORD": <<YOUR_MYSQL_PASSWORD>>,
                "DB_NAME": <<YOUR_CREATED_DB>>,
            },
            "args": []
        }
    ]
}
  1. Run using debug mode on vscode or type:
go run main.go
  1. Then access the following url.

http://localhost:8080/

Unit Testing

Run the following command to test the API.

The following command is applicable for Windows Powershell. Other OS might edit some of the command for it to run.

go test ./... -coverprofile="cover.out"
go test ./business/ -coverprofile="cover.out"
go tool cover -html="cover.out"

Public IP Address


How To Deploy The Project Locally

The project is (currently) can only be ran locally.

Prerequisites:

  • Docker and minikube installed (Check here for docker installation and her for minikube installation)
  • Kubectl installed (minikube usually has kubectl dependency so additional installation is not necessary)
  1. Starting minikube using docker
minikube start --driver=docker
  1. Applying yaml for mysql application deployment. Secrets, configmap, deployment and service are inside the same file.
kubectl apply -f https://raw.githubusercontent.com/daffaalex22/seleksi-deall/main/mysql.yaml
  1. Applying yaml for API application deployment
kubectl apply -f https://raw.githubusercontent.com/daffaalex22/seleksi-deall/main/api.yaml
  1. Check if the application is running
kubectl get all

Or

kubectl get pods
  1. Forward service to be LOCALLY accessible. With the following command, minikube will return a url for accessing the API. The API is can then be tested on postman.
minikube service api-service --url
  1. Stop minikube
minikube stop

About

This is a REST API mini-project created for Deall Application Proccess for Backend Engineer position. The project is created in Go Programming Language and uses MySQL as the RDBMS.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published