https://github.com/geshtng/go-base-backend
Go backend clean architecture boilerplate.
https://github.com/geshtng/go-base-backend
architecture article backend boilerplate clean-architecture database gin go go-architecture go-clean-architecture go-rest-api go-template golang gorm grpc mysql postgresql project-template rest rest-api
Last synced: 2 months ago
JSON representation
Go backend clean architecture boilerplate.
- Host: GitHub
- URL: https://github.com/geshtng/go-base-backend
- Owner: geshtng
- Created: 2022-10-13T10:33:20.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2024-08-22T02:13:27.000Z (over 1 year ago)
- Last Synced: 2024-11-25T18:39:14.348Z (over 1 year ago)
- Topics: architecture, article, backend, boilerplate, clean-architecture, database, gin, go, go-architecture, go-clean-architecture, go-rest-api, go-template, golang, gorm, grpc, mysql, postgresql, project-template, rest, rest-api
- Language: Go
- Homepage:
- Size: 133 KB
- Stars: 24
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Focused on PostgreSQL database (master branch)
# go-base-backend
## Release List
1. Database using PostgreSQL: master branch
2. Database using MySQL: checkout branch [mysql](https://github.com/geshtng/go-base-backend/tree/mysql)
3. Support for gRPC (database using PostgreSQL): checkout branch [grpc-postgresql](https://github.com/geshtng/go-base-backend/tree/grpc-postgresql)
4. Support for gRPC (database using MySQL): checkout branch [grpc-mysql](https://github.com/geshtng/go-base-backend/tree/grpc-mysql)
## Description
Example implementation go backend (clean) architecture. It is very easy to configure.
This project has 4 domain layers:
- Model
This layer will save models that were used in the other domains. Can be accessed from any other layer and other domains.
- Handler
This layer will do the job as the presenter of the application.
- Service
This layer will do the job as a controller and handle the business logic.
- Repository
This layer is the one that stores the database handler. Any operation on database like querying, inserting, updating, and deleting, will be done on this layer.
## Setup
1. Clone project.
```bash
$ git clone https://github.com/geshtng/go-base-backend
```
2. Init Database.
- Create a new database. Example database name: `go_base_backend`.
- After you run the server, it will automatically create tables and relations in the database `go_base_backend`.
3. Change config.
Make a new file named `config.yaml` inside the folder `/config`.
Use `config.yaml.example` to see the example or see the config sample below.
```yaml
app:
name: go-base-backend
server:
host: localhost
port: 8080
database:
db_host: localhost
db_port: 5432
db_name: go_base_backend
db_username: postgres
db_password: postgres
db_postgres_ssl_mode: disable
jwt:
expired: 60
issuer: go-base-backend
secret: sKk6E5gpVD
```
## Run the Project
```bash
$ make run
```
## API List
You can find API list on file `routes/routes.go`
## Example API with Authentication
I have set up an example of an API that uses authentication:
```http
GET localhost:8080/profiles
```
## Postman Collection
Import files `go-base-backend.postman_collection.json` to your postman
## Framework and Library
- [Gin](https://github.com/gin-gonic/gin)
- [Gorm](https://github.com/go-gorm/gorm)
- [Copier](https://github.com/jinzhu/copier)
- [Golang-jwt](https://github.com/golang-jwt/jwt)
- [Viper](https://github.com/spf13/viper)
- [Testify](https://github.com/stretchr/testify)
- [Go-Sqlmock](https://github.com/DATA-DOG/go-sqlmock)
- Other libraries listed in `go.mod`