Go-gin-ddd-cqrs - Clean api rest with Go, Gin and GORM

GOLANG API REST

Clean api rest with Go, Gin and GORM.

Clean Architecture with DDD, CQRS.

Use Redis for cache and Postgres for database.

---

Table of Contents

Getting Started

Develop: With local Go

make localrun
make createdb
make migrateup

Release: With dockerized Go

make run
make createdb
make migrateup

Endpoints

  • Public methods

    • GET /register
    • GET /login
  • With authorization

    • GET /api/v1/products

Package Structure

.
├── LICENSE
├── README.md
├── Makefile
├── Dockerfile
├── docker-compose.yml
├── docker-compose.local.yml
├── .env
├── .env.local
└── src                                       # Main Application
     ├── application
     │   ├── product
     │   │   └── query  
     │   │       └── get_products      
     │   │           ├── get_products_query.go
     │   │           ├── get_products_query_handler.go
     │   │           ├── get_products_query_response.go
     │   │           └── main.go
     │   └── user
     │       ├── command  
     │       │   ├── create_user      
     │       │   │   ├── create_user_command.go
     │       │   │   ├── create_user_command_handler.go
     │       │   │   └── main.go   
     │       └── query  
     │           ├── get_user_by_email      
     │           │   ├── get_user_by_email_query.go
     │           │   ├── get_user_by_email_query_handler.go
     │           │   ├── get_user_by_email_query_response.go
     │           │   └── main.go        
     │           └── login_user      
     │               ├── login_user_query.go
     │               ├── login_user_query_handler.go
     │               ├── login_user_query_response.go
     │               └── main.go               
     ├── domain
     │   ├── common
     │   │   ├── custom-error      
     │   │   │    └── invalid_argument_error.go
     │   │   ├── service      
     │   │   │   ├── auth      
     │   │   │   │   ├── auth.go
     │   │   │   │   └── token.go
     │   │   │   └── security      
     │   │   │       └── security.go
     │   │   └── valueobject      
     │   │       ├── access      
     │   │       │   └── access_detail.go
     │   │       └── token      
     │   │           └── token_detail.go
     │   ├── product
     │   │   ├── aggregate      
     │   │   │   └── product_aggregate.go
     │   │   ├── repository      
     │   │   │   └── product_repository.go
     │   │   ├── service      
     │   │   │   └── get_products      
     │   │   │       └── get_products.go
     │   │   └── valueobject      
     │   │       ├── cost      
     │   │       │   └── cost.go
     │   │       ├── id      
     │   │       │   └── id.go
     │   │       └── name      
     │   │           └── name.go
     │   └── user
     │       ├── aggregate      
     │       │   └── product_aggregate.go
     │       ├── errors      
     │       │   ├── already_exists_error.go
     │       │   ├── incorrect_user_or_password_error.go
     │       │   └── not_found_error.go
     │       ├── repository      
     │       │   └── user_repository.go
     │       ├── service      
     │       │   ├── create_user      
     │       │   │   └── create_user_service.go
     │       │   ├── get_user_by_email      
     │       │   │   └── get_user_by_email_service.go
     │       │   └── login_user      
     │       │       └── login_user_service.go
     │       └── valueobject      
     │           ├── email      
     │           │   └── email.go
     │           ├── first_name      
     │           │   └── first_name.go
     │           ├── id      
     │           │   └── id.go
     │           ├── last_name      
     │           │   └── last_name.go
     │           └── password      
     │               └── password.go
     └── infrastructure
         ├── common
         │   ├── config
         │   │   ├── database.go
         │   │   ├── main.go
         │   │   ├── redis.go
         │   │   ├── server.go
         │   │   └── swagger.go
         │   │
         │   ├── persistence
         │   │   ├── migration   
         │   │   └── model    
         │   │        ├── product_model.go                                
         │   │        └── user_model.go                                
         │   └── service
         │       ├── auth   
         │       │   ├── auth.go                                
         │       │   ├── redisdb.go            
         │       │   └── token.go            
         │       ├── middleware   
         │       │   └── middleware.go                     
         │       └── security    
         │           └── security.go           
         ├── product
         │   ├── controller   
         │   │   ├── get_products   
         │   │   │   ├── get_products_controller.go     
         │   │   │   └── main.go   
         │   ├── repository  
         │   │   └── product_repository  
         │   └── main.go                                                                                                                              
         └── user
             ├── controller   
             │   ├── create_user   
             │   │   ├── create_user_controller.go     
             │   │   └── main.go   
             │   └── login_user   
             │       ├── login_user_controller.go     
             │       └── main.go           
             ├── repository  
             │   └── user_repository  
             └── main.go           

Feedbacks

Feel free to write your thoughts

License

GNU General Public License v3.0.

Author

srcanton

Owner
Similar Resources

A ToDoList Demo based on Vue+Gin+Gorm+mysql

A ToDoList Demo based on Vue+Gin+Gorm+mysql

bubble清单 一个基于gin+gorm开发的练手小项目,通过该项目可初识go web开发该有的姿势。 前端页面基于vue和ElementUI开发,对前端不熟悉的童鞋可直接下载templates和static文件夹下的内容使用。 使用指南 下载 [email protected]:mao888/GoWe

Mar 16, 2022

GinGoExample - Implement rest api using gin and go and mongodb

GinGoExample Implement rest api using gin and go and mongodb Optimizations using Singlton pattern to avoid repetetive commiunication with mongodb . Fe

Mar 25, 2022

Golang gin clean

Dependency go get github.com/gin-gonic/gin go get github.com/jinzhu/gorm go get

Feb 11, 2022

Clean Architecture using Golang with Gin framework

Clean Architecture using Golang with Gin framework Template Structure Gin is a web framework written in Go (Golang). It features a martini-like API wi

Dec 16, 2022

REST API for a shoe store using Go and Gin Web Framework

REST API for a shoe store using Go and Gin Web Framework This API uses a local PostgreSQL database that's set through the /gopostgres/driverConfig.go

Dec 26, 2021

Go-service-gin - Simple Web api application developed in Golang and Gin

Simple Web api application developed in Golang and Gin Initial Tutorial URL http

Jan 4, 2022

Dating-server - Go (Golang) API REST Template/Boilerplate with Gin Framework

go-rest-template Go (Golang) API REST Template/Boilerplate with Gin Framework 1.

Apr 3, 2022

Gin-easy-todo - golang 의 RESTful API 프레임워크 gin 을 활용해 아주 간단한 Todo 애플리케이션을 만들어보자.

Gin-easy-todo - golang 의 RESTful API 프레임워크 gin 을 활용해 아주 간단한 Todo 애플리케이션을 만들어보자.

목차 1. 요약 2. 목표 3. API 목록 4. 프로젝트 구조 5. 패키지 별 기능과 관계 6. 사전 작업 6.1. DB, Table 생성 6.2. 모듈 생성 6.3. 패키지 다운로드 7. Gin 작성 7.1. 데이터베이스 설정 7.2. 테이블, 스키마 정의 7.3.

Jan 2, 2022

Ecommerce-api - Rest api of e-commerce web application

Ecommerce-api - Rest api of e-commerce web application

E-commerce Rest API Swagger documentation to test api Domain diagram

Jan 2, 2023
Sample Go REST API implementation with DDD using Clean Architecture.

This layer is a part developed for client-side (mobile, web, etc.) applications to access our domain. It will forward the requests from this layer to the application layer and expose the response it receives from the application layer.

Jan 3, 2023
Go (Golang) API REST with Gin FrameworkGo (Golang) API REST with Gin Framework

go-rest-api-aml-service Go (Golang) API REST with Gin Framework 1. Project Description Build REST APIs to support AML service with the support of exte

Nov 21, 2021
Implementation of clean architecture in golang with gin-gonic & gorm

Boilerplate API Boilerplate API template includes all the common packages and setup used for API development in this Company. Development Copy .env.ex

Feb 15, 2022
Gin-boilerplate - Gin boilerplate preconfigured with basic rest api features

Gin Boilerplate Build apis with gin faster with this template Features Validatio

Jun 24, 2022
Gin-boilerplate - This repository contains boilerplate code of a REST service using Gin (golang) framework.

Boilerplate REST service using Gin web framework (golang) Introduction This repository contains a boilerplate REST API service using Gin web framework

Apr 28, 2022
Go-gin-mongo-api - A backend RESTful API built using golang, gin and mongoDB

go-gin-mongo-API This is a RESTful backend API which is developed using the gola

Jul 19, 2022
Gin-errorhandling - Gin Error Handling Middleware is a middleware for the popular Gin framework

Gin Error Handling Middleware Gin Error Handling Middleware is a middleware for

Sep 19, 2022
前端使用Vue3、CompositionAPI、typescript、vite、element plus,后端使用Go + Gin + Gorm,实现的后端管理系统,支持菜单、页面按钮及后端API的权限管控。
前端使用Vue3、CompositionAPI、typescript、vite、element plus,后端使用Go + Gin + Gorm,实现的后端管理系统,支持菜单、页面按钮及后端API的权限管控。

本系统使用最新的 Vue3 及相关技术栈,实现了菜单及页面按钮的权限管控,基于 Casbin 实现了后端 API 接口的管控,不进行过度的封装,代码简洁易懂,方便二次开发及当成后端管理平台脚手架使用,数据库暂时仅支持 postgres 。 演示站点:http://fdevops.com:8088 文

Apr 1, 2022
Menggunakan gol ver 1.13.15 dan framework gin dan gorm

Menggunakan gol ver 1.13.15 dan framework gin dan gorm

Jul 11, 2022
Golang : Use gorm with mysql in gin

Golang : Use gorm with mysql in gin This repository guides to how ORM can be implemented in Golang. After cloning the code, follow below steps to let

Dec 9, 2021