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
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:
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.
- Role: Admin
Username: admin
Password: 1234
- Role: User
Username: user
Password: 1234
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
kubectl apply -f k8s-deploy/app/app_deployment.yml
kubectl apply -f k8s-deploy/app/app_service.yml
kubectl get svc
kubectl get pods
go mod vendor -v
go test ./... -v
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).
This API was deployed to Google Kubernetes Engine (GKE) cluster with following 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:
- Login
- Refresh Token
- Create User
- Update User
- Get Users
- Get User By ID
- Delete User