Skip to content

A RESTFul API build using Go to demonstrate basic CRUD, authentication, and authorization. Code organized using Clean Architecture and Proxy Design Pattern.

Notifications You must be signed in to change notification settings

guntoroyk/go-user-api

Repository files navigation

go-user-api

A RESTFul API build using Go to demonstrate basic CRUD, authentication, and authorization. Code organized using Clean Architecture and Proxy Design Pattern.

GitHub Repository: https://github.com/guntoroyk/go-user-api

API Documentation

This API was deployed to Google Kubernetes Engine (GKE) Cluster with public IP 34.142.137.17.

API docs can be accessed through this link: https://documenter.getpostman.com/view/6929584/2s8YzTTh9w

Or, click button bellow to try the API in Postman:

Run in Postman

Or click this URL to open Postman Public Collection https://elements.getpostman.com/redirect?entityId=6929584-9e93e6a5-57ca-4250-931d-276052fe8dc0&entityType=collection

Don't forget to change the Environment located on the upper right corner of Postman app.

If you having trouble accessing that URL, you can download the the postman-collection.json here http://34.142.137.17/docs, then import it to your Postman desktop application.

Credential

  • Role: Admin
Username: admin

Password: 1234
  • Role: User
Username: user

Password: 1234

How to run on Local

Clone the repository

git clone [email protected]:guntoroyk/go-user-api.git

Run on docker

docker-compose up --build -d

The API will available at http://localhost:8000

How to run on Kubernetes cluster

kubectl apply -f k8s-deploy/app/app_deployment.yml

kubectl apply -f k8s-deploy/app/app_service.yml

kubectl get svc

kubectl get pods

Run the unit test

go mod vendor -v

go test ./... -v

Software Design & Architecture Diagram

This API has 4 domains layer to follow the Clean Architecture:

  • Entity layer
  • Repository Layer
  • Usecase Layer
  • Handler Layer

With additional Middleware to intercept HTTP request & response, and Proxy between the Usecase and Repository to modify input & output data (here I used it to hash the password).

Alt Software Design

This API was deployed to Google Kubernetes Engine (GKE) cluster with following diagram:

Alt Architecture Diagram

The kubernetes deployment config is located on ./k8s-deploy folder.

Run this command to deploy using kubectl:

kubectl apply -f k8s-deploy/app/app_deployment.yml

kubectl apply -f k8s-deploy/app/app_service.yml

Here is to check the deployment result:

Alt Check kubernetes deployment

Flowchart

  1. Login

Alt Login

  1. Refresh Token

Alt Refresh Token

  1. Create User

Alt Create User

  1. Update User

Alt Update User

  1. Get Users

Alt Get Users

  1. Get User By ID

Alt Get User By ID

  1. Delete User

Alt Delete User

About

A RESTFul API build using Go to demonstrate basic CRUD, authentication, and authorization. Code organized using Clean Architecture and Proxy Design Pattern.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published