• Stars
    star
    117
  • Rank 301,828 (Top 6 %)
  • Language
    Go
  • Created almost 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Ecommerce Rest API application built in Go with Gin Gonic + Gorm

GoGonicEcommerceApi

Table of Contents

Introduction

This is one of my E-commerce API app implementations. It is written in Golang using go-gonic web framework.. This is not a finished project by any means, but it has a valid enough shape to be git cloned and studied if you are interested in this topic. If you are interested in this project take a look at my other server API implementations I have made with:

Full-stack Applications

E-commerce (shopping cart)

Server side implementations

The next to come are:

  • Spring Boot + Spring Data Hibernate + Kotlin
  • Spring Boot + Jax-RS Jersey + Hibernate + Kotlin
  • Spring Boot + mybatis
  • Spring Boot + mybatis + Kotlin
  • Asp.Net Web Api v2
  • Elixir
  • Golang + Beego
  • Golang + Iris
  • Golang + Echo
  • Golang + Mux
  • Golang + Revel
  • Golang + Kit
  • Flask + Flask-Restful
  • AspNetCore + NHibernate
  • AspNetCore + Dapper

Client side implementations

This client side E-commerce application is also implemented using other client side technologies:

Blog/CMS

Server side implementations

The next to come are:

  • Spring Boot + Spring Data Hibernate + Kotlin
  • Spring Boot + Jax-RS Jersey + Hibernate + Kotlin
  • Spring Boot + mybatis
  • Spring Boot + mybatis + Kotlin
  • Asp.Net Web Api v2
  • Elixir
  • Golang + Beego
  • Golang + Iris
  • Golang + Echo
  • Golang + Mux
  • Golang + Revel
  • Golang + Kit
  • Flask + Flask-Restful
  • AspNetCore + NHibernate
  • AspNetCore + Dapper

Client side

The next come are

  • Angular NgRx-Store
  • Angular + Material
  • React + Material
  • React + Redux + Material
  • Vue + Material
  • Vue + Vuex + Material
  • Ember

Simple CRUD(Create, Read, Update, Delete)

Server side implementations

Client side implementations

The next come are

  • Angular NgRx-Store
  • Angular + Material
  • React + Material
  • React + Redux + Material
  • Vue + Material
  • Vue + Vuex + Material
  • Ember
  • Vanilla javascript

CRUD + Pagination

Server side implementations

The next come are

  • NodeJs Express + Knex
  • Flask + Flask-Restful
  • Laravel + Fractal
  • Laravel + ApiResources
  • Go with Mux
  • AspNet Web Api 2
  • Jersey
  • Elixir

Client side implementations

The next come are

  • Angular NgRx-Store
  • Angular + Material
  • React + Material
  • React + Redux + Material
  • Vue + Material
  • Vue + Vuex + Material
  • Ember
  • Vanilla javascript

Social media links

  • Youtube Channel I publish videos mainly on programming
  • Blog Sometimes I publish the source code there before Github
  • Twitter I share tips on programming

WARNING

I have mass of projects to deal with so I make some copy/paste around, if something I say is missing or is wrong, then I apologize and you may let me know opening an issue.

Getting started

  1. go get https://github.com/melardev/ApiEcomGoGonic
  2. Change the .env.example as you need(see warning below)
  3. Rename .env.example to .env
  4. Seed the database passing "create seed" as arguments to the app(read main.go to understand what I mean)

WARNING

The recommended database to use is Postgresql, the other database backends may not work as expected. Unfortunately the MySQL does not work as expected, for example the BeforeSave Hook for User is not able to retrieve the Role model if using MySQL, the same code does work if SQLite, it is weird, because the SQL query generated is valid and it returns a row, but somehow the driver is not able to map it to the user.

Features

  • Authentication / Authorization
  • JWT middleware for authentication
  • Multi file upload
  • Database seed
  • Paging with Limit and Offset using GORM (Golang ORM framework)
  • CRUD operations on products, comments, tags, categories, orders Fetching products page
  • Orders, guest users may place an order Database diagram

What you will learn

  • Golang

  • Golang Go-Gonic web framework

  • JWT

  • Controllers

  • Middlewares

  • JWT Authentication

  • Role based authorization

  • GORM

    • associations: ManyToMany, OneToMany, ManyToOne
    • virtual fields
    • Select specific columns
    • Eager loading
    • Count related association
  • seed data

  • misc

    • project structure

Understanding the project

The project is meant to be educational, to learn something beyond the hello world thing we find in a lot, lot of tutorials and blog posts. Since its main goal is educational, I try to make as much use as features of APIs, in other words, I used different code to do the same thing over and over, there is some repeated code but I tried to be as unique as possible so you can learn different ways of achieving the same goal.

Project structure:

  • models: Mvc, it is our domain data.
  • dtos: it contains our serializers, they will create the response to be sent as json. They also take care of validating the input(feature incomplete)
  • controllers: well this is the mvC, they receive the request from the user, they ask the services to perform an action for them on the database.
  • seeds: contains the file that seeds the database.
  • static: a folder that will be generated when you create a product or tag or category with images
  • services: contains some business logic for each model, and for authorization
  • middlewares: it contains middlewares(golang functions) that are triggered before the controller action, for example, a middleware which reads the request looking for the Jwt token and trying to authenticate the user before forwarding the request to the corresponding controller action

TODO

  • Add model constraints such as not null
  • Refactor the seeding with http://gorm.io/docs/query.html#Select
  • Global Application Error handling
  • Can't Preload field errors:
  • Security, validations, file upload
  • Delete FileUpload if associated tag, category or product deleted
  • Delete Files if tag, category, product fail to be saved
  • Use pointers as function parameters instead of passing them by value as I did in many
  • For some reason /api/products does not work on browsers due to CORS issues, /api/home does work, on postman all routes work ....

Resources

More Repositories

1

ApiEcomSequelizeExpress

Ecommerce API app implemented with Express js and Sequelize
JavaScript
37
star
2

TutsAndroidFirebase

Java
28
star
3

ApiEcomMongooseExpress

Ecommerce API app implemented in NodeJs with Mongoose and Express
JavaScript
26
star
4

FlaskApiEcommerce

Python Ecommerce Api application built with Flask + Flask SQlAlchemy
Python
22
star
5

TutsCSharpCrypto

C# Code for Crypto In C# lessons / Codigo de las lecciones de criptografia en C#
C#
19
star
6

ApiAspCoreEcommerce

Asp.Net Core Ecommerce Api application
C#
17
star
7

XeytanWin32-RAT

WORK IN PROGRESS. RAT written in C++ using Win32 API
C++
16
star
8

DjangoRestShopApy

Python Ecommerce API application built with Rest Framework
Python
15
star
9

GoGonicBlogApi

Go
15
star
10

SBootApiEcomMVCHibernate

Ecommerce API app built with Spring Boot + Spring Data + Hibernate
Java
15
star
11

VueVuexEcommerceRestApi

Full stack Vue + Vuex Ecommerce application
Vue
12
star
12

XeytanJ-Async-RAT

WORK IN PROGRESS. RAT written in Java
Java
12
star
13

AngularEcommerceRestApi

Angular Ecommerce cart application (full stack)
TypeScript
10
star
14

XeytanWin32-Async-RAT

WORK IN PROGRESS. RAT written in C++ using Win32 API
C++
9
star
15

TutsNetLibrary

OkHttp3 Retrofit and RxJava Demos for my Youtube tutorials
Java
8
star
16

XeytanQpp-RAT

WORK IN PROGRESS. RAT written in C++ using Qt framework
C++
8
star
17

XeytanWxCpp-RAT

Work in Progress. RAT written in C++ using wxWidgets
C++
8
star
18

ReactReduxEcommerceRestApi

Ecommerce Proof of Concept app built with React + Redux
JavaScript
8
star
19

SpringBootApiJpaPaginatedCrud

Spring Boot Api sample showing how to perform CRUD with pagination
Java
7
star
20

SpringBootApiBlog

Spring Boot Blog/CMS application
Java
6
star
21

XeytanJ-RAT

WORK IN PROGRESS. RAT written in Java.
Java
6
star
22

ApiEcommerceLaravel

Ecommerce API application built with Laravel (PHP)
PHP
6
star
23

AndroidBackgroundTuts

Java
5
star
24

XeytanKeylogger

Unicode keylogger in c#
C#
5
star
25

Android_Kotlin_MVVM_Dagger_RxRetrofit_DataBinding_Crud

Android Crud application built with Architecture components, Dagger and Retrofit
Kotlin
5
star
26

SpringBootEcommerceApiJersey

Ecommerce Api application built with Spring Boot + JAX-RS Jersey
Java
5
star
27

Xeytan.Net-RAT

Work In Progress. RAT written in C#
C#
5
star
28

XeytanBoost-RAT

WORK IN PROGRESS. RAT written in C++ using Boost Libraries
C++
5
star
29

TutsAndroidUI

Android User Interface Youtube tutorials / Tutoriales de Interfaz grΓ‘fica en android
Java
5
star
30

C_Win32_BindShell_Sync

BindShell written in C using Win32API and blocking sockets
C
4
star
31

VuePaginatedAsyncCrud

Vue Todo app with async HTTP CRUD and pagination
Vue
4
star
32

Java_SpringCloud_Eureka_Zuul_Feign_Sleuth_Zipkin_RestCrud

Java
4
star
33

AngularFirebaseDbCrud

Angular Crud Application that uses Firebase Realtime Database
TypeScript
4
star
34

ReverseShell

C++
4
star
35

Elixir_Phoenix_Ecto_Crud

Elixir Rest Phoenix Crud application with Ecto
Elixir
4
star
36

AspNetCoreApiPaginatedCrud

Asp Net Core Todo Api app with pagination and Entity Framework Core
C#
4
star
37

Xeytan.Net-Async-RAT

Work In progress. RAT written in C#
C#
3
star
38

CppWxWidgetsConsoleSnippets

Cpp wxWidgets Snippets related to text processing, concurrency, filesystem, IO, etc
C++
3
star
39

FlaskApiBlog

Python Rest Blog application built with Flask + Flask SQLAlchemy
Python
3
star
40

ReactEcommerceRestApi

Full stack React E-commerce application
JavaScript
3
star
41

C_Win32ReverseShell

C
3
star
42

Angular_NgRx_NgRxEffects_Crud

Angular Crud application built using NgRx and NgRx Effects
TypeScript
3
star
43

RailsApiJBuilderCrud

Api app buitl with Rails + JBuilder
Ruby
2
star
44

GoGinGonicApiCrudPagination

Go
2
star
45

GoBeegoGormApiCrud

Go
2
star
46

ExpressBookshelfApiCrud

NodeJs Rest Api application built with Express and Bookshelf ORM
JavaScript
2
star
47

LaravelApiBlog

PHP
2
star
48

TutsDjango

Django Tutorials
JavaScript
2
star
49

VueEcommerceRestApi

Vue Ecommerce Api application
Vue
2
star
50

GoGinGonicApiGormCrud

Go
2
star
51

C_Win32BindShell

C
2
star
52

Cpp_AES_ECB_Implementation

C++
2
star
53

go-snippets

Go
2
star
54

GoGormApiCrud

Go
2
star
55

JavaSpringBootJwtCrudPagination

Java Spring Boot Crud + Pagination application secured with JWT
Java
2
star
56

TutsSpringMvc

Spring MVC projects used for my in depth Spring MVC tutorial playlist on Youtube
Java
2
star
57

VueBlog

Full stack blog application built with Vue
Vue
2
star
58

.NetCSharpReverseShell

C#
2
star
59

JavaSpringBootRxJwtSecurityRxCrud

Java Spring Boot Crud application secured with Spring Reactive Security JWT
Java
2
star
60

VueVuexPaginatedAsyncCrud

Vue + Vuex TODO app with Pagination and CRUD Http requests
Vue
2
star
61

AspCoreApiBlog

C#
2
star
62

C_Win32_ReverseShellSync

Reverse Shell written using C Win32 API
C
2
star
63

FlaskApiPaginatedCrud

Python Rest Api application built with Flask + FLask SQLAlchemy with pagination
Python
2
star
64

C_Win32KeytanLoggerHook

C
2
star
65

CppQtReverseShell

Qt Cpp Reverse shell
C++
2
star
66

.NetWebApiDapperCrud

C#
2
star
67

ApiEcomBookshelfExpress

Ecommerce API app built with Express and Bookshelf js ORM framework
JavaScript
1
star
68

CppQtBindShell

Cpp Qt Bind Shell
C++
1
star
69

Android_Kotlin_Fragments_MVVM_RxRetrofit_RxLifecycle_DataBinding_Crud

Android Crud application built with Architecture components and Retrofit
Kotlin
1
star
70

Java_SpringCloud_Eureka_Zuul_OAuth2Jwt_RestCrud

Java Spring Cloud Crud application using Microservices Architecture
Java
1
star
71

CppBoostBindShellSync

Bind Shell written in Cpp using Boost libraries
C++
1
star
72

PythonReverseShell

Python
1
star
73

.NetCoreApiNHibernateCrud

C#
1
star
74

.NetCSharpBindShell

C#
1
star
75

GoGormApiCrudPagination

Go
1
star
76

.NetWebApiAutofacCrudPagination

C#
1
star
77

.NetCoreCSharpBindShell

C#
1
star
78

AngularBlog

Full stack Blog application built with Angular
TypeScript
1
star
79

PythonConcurrencySnippets

Python Concurrency Snippets
Python
1
star
80

TutsStorage

Java
1
star
81

.NetWebApiADO.NetCrudPagination

C#
1
star
82

.NetCSharpDLLInjector

DLL Injector written in C#
C#
1
star
83

SpringBootApiSpringJpaCrud

Spring Boot Api application with Spring Data JPA hibernate implementing HTTP Crud
Java
1
star
84

Java_SpringCloud_Eureka_Zuul_Config_Kafka_OAuth2Jwt_ProxyDiscovery_RestCrud

Java Spring Cloud Crud Application with Microservices
Java
1
star
85

.NetCoreApiADO.NetCrud

C#
1
star
86

Java_SpringCloud_Eureka_Zuul_Config_Hystrix_Turbine_Feign_RestCrud

Java
1
star
87

.NetWebApiAutofacCrud

C#
1
star
88

.NetCSharpNetworkSnippets

C# Network snippets
C#
1
star
89

JavaSpringBootAuth0JwtCrud

Java Spring Boot Crud application secured with Jwt using Auth0 Library
Java
1
star
90

.NetCoreApiNHibernateCrudPagination

C#
1
star
91

Java_SpringBootApiJpaCrud

Java Spring Boot Crud Application using JPA
Java
1
star
92

CppBoostReverseShellSync

Reverse shell written in Cpp using Boost libraries
C++
1
star
93

KotlinReverseShell

Reverse Shell written in Kotlin
Kotlin
1
star
94

ExpressSequelizeApiPaginatedCrud

Express Rest api implementing CRUD with pagination using Sequelize
JavaScript
1
star
95

ExpressApiMongoosePaginatedCrud

Express Api Rest application implementing CRUD with pagination
JavaScript
1
star
96

C_Snippets

C programming snippets
C
1
star
97

.NetWebApiNHibernateCrudPagination

C#
1
star
98

DjangoApiBlog

Python
1
star
99

.NetCoreApiDapperCrud

C#
1
star
100

.NetCoreApiADO.NetCrudPagination

C#
1
star