Giter Site home page Giter Site logo

bagashiz / go-pos Goto Github PK

View Code? Open in Web Editor NEW
169.0 3.0 29.0 544 KB

Simple RESTful Point of Sale (POS) Service API written in Go using Gin web framework, PostgreSQL database, and Redis cache. Proof of concept of implementing Hexagonal Architecture in Go.

Home Page: https://gopos.bagashiz.xyz/docs/index.html

License: MIT License

Go 99.82% Dockerfile 0.18%
go redis golang pgx rest-api gin hexagonal-architecture point-of-sales postgresql

go-pos's Introduction

Go POS

Description

A simple RESTful Point of Sale (POS) web service written in Go programming language. This project is a part of my learning process in understanding Hexagonal Architecture in Go.

It uses Gin as the HTTP framework and PostgreSQL as the database with pgx as the driver and Squirrel as the query builder. It also utilizes Redis as the caching layer with go-redis as the client.

This project idea was inspired by the Ide Project untuk Upgrade Portfolio Backend Engineer video on YouTube by Asdita Prasetya, which provided valuable guidance and inspiration for its development.

Getting Started

  1. If you do not use devcontainer, ensure you have Go 1.23 or higher and Task installed on your machine:

    go version && task --version
  2. Create a copy of the .env.example file and rename it to .env:

    cp .env.example .env

    Update configuration values as needed.

  3. Install all dependencies, run docker compose, create database schema, and run database migrations:

    task
  4. Run the project in development mode:

    task dev

Documentation

For database schema documentation, see here, powered by dbdocs.io.

API documentation can be found in docs/ directory. To view the documentation, open the browser and go to http://localhost:8080/docs/index.html. The documentation is generated using swaggo with gin-swagger middleware.

Contributing

Developers interested in contributing to Go POS project can refer to the CONTRIBUTING file for detailed guidelines and instructions on how to contribute.

License

Go POS project is licensed under the MIT License, providing an open and permissive licensing approach for further development and usage.

Learning References

go-pos's People

Contributors

bagashiz avatar dependabot[bot] avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

go-pos's Issues

Naming convention in Hexagonal architecture

Hi,

I took a look at your article about Hexagonal architecture, and I really appreciate your effort.

I was wondering If we could rename CacheService into CacheRepository since it's implemented inside the Adapter layer and the Core layer is using it?

type CacheService interface {
	// Set stores the value in the cache
	Set(ctx context.Context, key string, value []byte, ttl time.Duration) error
	// Get retrieves the value from the cache
	Get(ctx context.Context, key string) ([]byte, error)
	// Delete removes the value from the cache
	Delete(ctx context.Context, key string) error
	// DeleteByPrefix removes the value from the cache with the given prefix
	DeleteByPrefix(ctx context.Context, prefix string) error
	// Close closes the connection to the cache server
	Close() error
}

Is there a general rule in this architecture, stating that any interface provided by the Core layer should have a name ending with Service and anything else provided by the Adapter Layer to end with Repository? I'm specifically thinking about interfaces residing inside the Port directory.

docs: add more response

// adminMiddleware is a middleware to check if the user is an admin
func adminMiddleware() gin.HandlerFunc {
	return func(ctx *gin.Context) {
		payload := getAuthPayload(ctx, authorizationPayloadKey)

		isAdmin := payload.Role == domain.Admin
		if !isAdmin {
			err := port.ErrForbidden
			handleAbort(ctx, err)
			return
		}

		ctx.Next()
	}
}

need to add 403 forbidden

Migrate from paseto

Hi. You are using the paseto library in your project, but it has not been supported for more than two years. It's not very safe, it's best to use another library.

suggestion

Hi,

I think this example would be improved if it didn't have an anemic domain model, read about it here https://en.wikipedia.org/wiki/Anemic_domain_model

I'm saying this since your domain only contains the structs for your models without any business logic at all

This is just a suggestion you didn't ask for, so take it with a grain of salt :)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.