https://github.com/mingpv/clean-go-template
GO Clean Architecture Template
https://github.com/mingpv/clean-go-template
api clean-architecture docker fiber go golang gorm gotemplate grpc rest-api restful template
Last synced: 7 months ago
JSON representation
GO Clean Architecture Template
- Host: GitHub
- URL: https://github.com/mingpv/clean-go-template
- Owner: MingPV
- License: mit
- Created: 2025-05-21T14:43:26.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-08-17T08:20:52.000Z (7 months ago)
- Last Synced: 2025-08-17T09:17:24.336Z (7 months ago)
- Topics: api, clean-architecture, docker, fiber, go, golang, gorm, gotemplate, grpc, rest-api, restful, template
- Language: Go
- Homepage:
- Size: 93.8 KB
- Stars: 10
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# clean-go-template
**go-clean-template** is a clean and scalable starter template for building backend applications in Go, following Clean Architecture principles. This template uses:
- **Fiber v2** as a fast and lightweight web framework for building RESTful APIs
- **GORM** as the ORM for PostgreSQL database access
- **Redis** for caching to improve performance and reduce database load
- **gRPC** for high-performance RPC communication
- **Docker Compose** for easy setup of PostgreSQL and Redis services
## Features
- Clear separation of concerns with Clean Architecture
- High-performance HTTP handling with Fiber v2
- Robust database integration using GORM with PostgreSQL
- Caching support via Redis
- REST and gRPC APIs supported
- Data Transfer Objects (DTO) to manage data structure transformations between layers
- Swagger API documentation with automatic generation
- Ready-to-use Docker Compose setup for dependencies
## Getting Started
Follow the steps below to set up and run the project:
1. Clone the repository:
```bash
git clone https://github.com/MingPV/clean-go-template.git
cd clean-go-template
```
2. Install Go module dependencies:
```bash
go mod tidy
```
3. Rename the environment file and configure it:
```bash
cp .env.example .env
```
Open the `.env` file and fill in all required configuration values such as PostgreSQL credentials, Redis connection details, and any other environment-specific settings.
4. Start PostgreSQL and Redis services using Docker Compose:
```bash
docker-compose up -d
```
5. Run the application:
```bash
go run ./cmd/app
```
6. Test:
```bash
go test ./pkg/routes
```
Swagger UI for the API documentation is available at: localhost:8080/api/v1/docs

## Project structure
```bash
/clean-go-template
├── cmd/
│ └── app/
│ └── main.go
├── docs/
│ └── v1/
├── internal/
│ ├── app/
│ ├── entities/
│ ├── order/
│ │ ├── handler/
│ │ │ ├── grpc/
│ │ │ └── rest/
│ │ ├── usecase/
│ │ ├── repository/
│ │ └── dto/
│ └── user/
├── pkg/
│ ├── config/
│ ├── database/
│ ├── middleware/
│ ├── redisclient/
│ ├── responses/
│ └── routes/
├── proto/
│ └── order/
├── utils/
├── .env.example
├── .gitignore
├── LICENSE
├── README.md
├── docker-compose.yaml
└── go.mod
```