https://github.com/guntoroyk/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.
https://github.com/guntoroyk/go-user-api
clean-architecture crud-application design-patterns go golang rest-api
Last synced: about 2 months ago
JSON representation
A RESTFul API build using Go to demonstrate basic CRUD, authentication, and authorization. Code organized using Clean Architecture and Proxy Design Pattern.
- Host: GitHub
- URL: https://github.com/guntoroyk/go-user-api
- Owner: guntoroyk
- Created: 2022-12-10T04:54:12.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2022-12-11T09:52:17.000Z (over 3 years ago)
- Last Synced: 2025-10-08T20:03:07.573Z (6 months ago)
- Topics: clean-architecture, crud-application, design-patterns, go, golang, rest-api
- Language: Go
- Homepage:
- Size: 947 KB
- Stars: 4
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# 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:
[]()
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 git@github.com: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).

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:

## Flowchart
1. Login

2. Refresh Token

3. Create User

4. Update User

5. Get Users

6. Get User By ID

7. Delete User
