Giter Club home page Giter Club logo

go-coffeeshop's Introduction

go-coffeeshop

An event-driven microservices coffee shop application has been written in Golang and deployed using Nomad, Consul Connect, Vault, and Terraform.

Other versions in .NET/C# can be found at:

Technical stack

CoffeeShop - Choreography Saga

coffeeshop

Services

No. Service URI
1 grpc-gateway http://localhost:5000
2 product service http://localhost:5001
3 counter service http://localhost:5002
4 barista service worker only
5 kitchen service worker only
6 web http://localhost:8888

Starting project

Jump into .devcontainer, then

> make docker-compose

From vscode => Press F1 => Type Simple Browser View => Choose it and enter http://localhost:8888. Enjoy!!!

Screenshots

Home screen

home_screen

Payment screen

payment_screen

Order list screen

order_list_screen

HashiCorp stack deployment

coffeeshop_hashicorp

The details of how to run it can be find at deployment with Nomad, Consult Connect and Vault.

Development

Clean Domain-driven Design

clean_ddd

Generate dependency injection instances with wire

> make wire

Generate code with sqlc

> make sqlc

Debug Apps

Debug golang app in monorepo

Trouble shooting

Development project trouble shooting

Roadmap

  • ✅ Enhance project structure with DDD patterns
  • Add testing
  • Add and integrate with observability libs and tools
  • Add user identity management (authentication and authorization)
  • Add resiliency

Credits

go-coffeeshop's People

Contributors

thangchung 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  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

go-coffeeshop's Issues

Infrastructure Nomad

Hi anh thangchung,

Anh cho em hỏi là với source code nomad hiện tại thì có thể chạy trên production được không anh, hay khi chạy trên production còn cần config gì nữa ạ, em đang học nomad nên chưa rõ lắm.

anh có thể cho e xin tài liệu hoặc tutorial gì đó để học nomad được không ạ vì trên document của hashicorp khá là rời rạc em không thể hiểu rõ nomad và consul được ạ em cám ơn anh

How to run demo in local PC?

I would like to run this project on local mac book, but don't know how to run it? which softwares I need to install?
Do you have any detailed installation guide?

ERROR: .FileNotFoundError: [Errno 2] No such file or directory: './docker-compose-full.yaml'

I jumped into .devcontainer, then ran

> docker-compose -f docker-compose-full.yaml build

I got this error

ERROR: .FileNotFoundError: [Errno 2] No such file or directory: './docker-compose-full.yaml'

I tried to cd ..
and run above command again then got

ERROR: The Compose file './docker-compose-full.yaml' is invalid because:
services.barista.depends_on contains an invalid type, it should be an array
services.counter.depends_on contains an invalid type, it should be an array
services.kitchen.depends_on contains an invalid type, it should be an array

What did it go wrong?
Thank you.

Cannot start the project

Hi Mr ThangChung,

When jumped to .devcontainner and did the command make docker-compse, I ran into this error

docker-compose down --remove-orphans -v
Removing network go-coffeeshop_coffeeshop-network
docker-compose up --build
Creating network "go-coffeeshop_coffeeshop-network" with the default driver
Building product
ERROR: BuildKit is enabled but the buildx component is missing or broken.
       Install the buildx component to build images with BuildKit:
       https://docs.docker.com/go/buildx/
ERROR: Service 'product' failed to build : Build failed
make: *** [Makefile:42: docker-compose-start] Error 1

Could you me help me get through this issue.

Get refused to connect after following instructions

image

Get above.

Actually get this:

Use 'docker scan' to run Snyk tests against images to find vulnerabilities and learn how to fix them

~/clones/go-coffeeshop main 1m 51s
base ❯ docker-compose -f docker-compose-full.yaml up
Creating network "go-coffeeshop_coffeeshop-network" with the default driver
Pulling postgres (postgres:14-alpine)...
14-alpine: Pulling from library/postgres
261da4162673: Pull complete
5dc5a1575ff6: Pull complete
4753903688c5: Pull complete
afadd6a70e8a: Pull complete
257391ea2d32: Pull complete
8058995a64a2: Pull complete
c965d7969de7: Pull complete
98c6fa46b756: Pull complete
Digest: sha256:1785b8611bb46e7b8776841be5febc322cdb84c3b72c12bfed364379ecdf9b0d
Status: Downloaded newer image for postgres:14-alpine
Pulling rabbitmq (rabbitmq:3.11-management-alpine)...
3.11-management-alpine: Pulling from library/rabbitmq
6875df1f5354: Pull complete
b7d42b41512a: Pull complete
38ce1e51f146: Pull complete
30f3b8c492fe: Pull complete
d0a640a44f52: Pull complete
222d71114c97: Pull complete
e4ed5fb5aa18: Pull complete
607ce441501c: Pull complete
4971aa665d3a: Pull complete
3dd21f62f233: Pull complete
Digest: sha256:144122321e04952e54ec12eb8946ae784aa05bd42ef69b59ed153599b84a5d69
Status: Downloaded newer image for rabbitmq:3.11-management-alpine
Creating go-coffeeshop_product_1  ... done
Creating go-coffeeshop_rabbitmq_1 ... done
Creating go-coffeeshop_postgres_1 ... done
Creating go-coffeeshop_barista_1  ... done
Creating go-coffeeshop_kitchen_1  ... done
Creating go-coffeeshop_counter_1  ... done
Creating go-coffeeshop_proxy_1    ... error

ERROR: for go-coffeeshop_proxy_1  Cannot start service proxy: Ports are not available: listen tcp 0.0.0.0:5000: bind: address already in use

ERROR: for proxy  Cannot start service proxy: Ports are not available: listen tcp 0.0.0.0:5000: bind: address already in use
ERROR: Encountered errors while bringing up the project.

GraphQL endpoint

Hi.

Thanks for creating this awesome “boilerplate” to learn the best practice.

Is there any plan to add GraphQL endpoint for this?

Thanks! ❤️

Event/message driven

Empty web page with docker-compose

Setting:

Windows:

Edition	Windows 10 Pro
Version	21H2
Installed on	‎9/‎3/‎2022
OS build	19044.2251
Experience	Windows Feature Experience Pack 120.2212.4180.0

Docker:

v4.15.0

Command:

docker-compose -f docker-compose-full.yaml up

Result

  • White page when access business service

Capture

image

image

image

image

Look like problem with Postres?

2022-12-03 08:53:51 The files belonging to this database system will be owned by user "postgres".
2022-12-03 08:53:51 This user must also own the server process.
2022-12-03 08:53:51 
2022-12-03 08:53:51 The database cluster will be initialized with locale "en_US.utf8".
2022-12-03 08:53:51 The default database encoding has accordingly been set to "UTF8".
2022-12-03 08:53:51 The default text search configuration will be set to "english".
2022-12-03 08:53:51 
2022-12-03 08:53:51 Data page checksums are disabled.
2022-12-03 08:53:51 
2022-12-03 08:53:51 fixing permissions on existing directory /var/lib/postgresql/data ... ok
2022-12-03 08:53:51 creating subdirectories ... ok
2022-12-03 08:53:51 selecting dynamic shared memory implementation ... posix
2022-12-03 08:53:51 selecting default max_connections ... 100
2022-12-03 08:53:51 selecting default shared_buffers ... 128MB
2022-12-03 08:53:51 selecting default time zone ... UTC
2022-12-03 08:53:51 creating configuration files ... ok
2022-12-03 08:53:51 running bootstrap script ... ok
2022-12-03 08:53:51 performing post-bootstrap initialization ... ok
2022-12-03 08:53:53 syncing data to disk ... ok
2022-12-03 08:53:53 
2022-12-03 08:53:53 
2022-12-03 08:53:53 Success. You can now start the database server using:
2022-12-03 08:53:53 
2022-12-03 08:53:53     pg_ctl -D /var/lib/postgresql/data -l logfile start
2022-12-03 08:53:53 
2022-12-03 08:53:53 waiting for server to start....2022-12-03 01:53:53.255 UTC [36] LOG:  starting PostgreSQL 14.6 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r4) 12.2.1 20220924, 64-bit
2022-12-03 08:53:53 2022-12-03 01:53:53.260 UTC [36] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2022-12-03 08:53:53 2022-12-03 01:53:53.273 UTC [37] LOG:  database system was shut down at 2022-12-03 01:53:51 UTC
2022-12-03 08:53:53 2022-12-03 01:53:53.278 UTC [36] LOG:  database system is ready to accept connections
2022-12-03 08:53:53  done
2022-12-03 08:53:53 server started
2022-12-03 08:53:53 
2022-12-03 08:53:53 /usr/local/bin/docker-entrypoint.sh: ignoring /docker-entrypoint-initdb.d/*
2022-12-03 08:53:53 
2022-12-03 08:53:53 waiting for server to shut down...2022-12-03 01:53:53.352 UTC [36] LOG:  received fast shutdown request
2022-12-03 08:53:53 .2022-12-03 01:53:53.356 UTC [36] LOG:  aborting any active transactions
2022-12-03 08:53:53 2022-12-03 01:53:53.357 UTC [36] LOG:  background worker "logical replication launcher" (PID 43) exited with exit code 1
2022-12-03 08:53:53 2022-12-03 01:53:53.357 UTC [38] LOG:  shutting down
2022-12-03 08:53:53 2022-12-03 01:53:53.393 UTC [36] LOG:  database system is shut down
2022-12-03 08:53:53  done
2022-12-03 08:53:53 server stopped
2022-12-03 08:53:53 
2022-12-03 08:53:53 PostgreSQL init process complete; ready for start up.
2022-12-03 08:53:53 
2022-12-03 08:53:51 sh: locale: not found
2022-12-03 08:53:51 2022-12-03 01:53:51.628 UTC [30] WARNING:  no usable system locales were found
2022-12-03 08:53:53 initdb: warning: enabling "trust" authentication for local connections
2022-12-03 08:53:53 You can change this by editing pg_hba.conf or using the option -A, or
2022-12-03 08:53:53 --auth-local and --auth-host, the next time you run initdb.
2022-12-03 08:53:53 2022-12-03 01:53:53.469 UTC [1] LOG:  starting PostgreSQL 14.6 on x86_64-pc-linux-musl, compiled by gcc (Alpine 12.2.1_git20220924-r4) 12.2.1 20220924, 64-bit
2022-12-03 08:53:53 2022-12-03 01:53:53.469 UTC [1] LOG:  listening on IPv4 address "0.0.0.0", port 5432
2022-12-03 08:53:53 2022-12-03 01:53:53.469 UTC [1] LOG:  listening on IPv6 address "::", port 5432
2022-12-03 08:53:53 2022-12-03 01:53:53.477 UTC [1] LOG:  listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2022-12-03 08:53:53 2022-12-03 01:53:53.485 UTC [48] LOG:  database system was shut down at 2022-12-03 01:53:53 UTC
2022-12-03 08:53:53 2022-12-03 01:53:53.490 UTC [1] LOG:  database system is ready to accept connections
2022-12-03 08:54:21 2022-12-03 01:54:21.186 UTC [62] FATAL:  role "root" does not exist
2022-12-03 08:54:51 2022-12-03 01:54:51.253 UTC [102] FATAL:  role "root" does not exist
2022-12-03 08:55:21 2022-12-03 01:55:21.334 UTC [110] FATAL:  role "root" does not exist
2022-12-03 08:55:51 2022-12-03 01:55:51.423 UTC [117] FATAL:  role "root" does not exist
2022-12-03 08:56:21 2022-12-03 01:56:21.514 UTC [125] FATAL:  role "root" does not exist
2022-12-03 08:56:51 2022-12-03 01:56:51.593 UTC [132] FATAL:  role "root" does not exist
2022-12-03 08:57:21 2022-12-03 01:57:21.714 UTC [140] FATAL:  role "root" does not exist
2022-12-03 08:57:51 2022-12-03 01:57:51.796 UTC [147] FATAL:  role "root" does not exist

bug: KitchenOrderPub will overwrite the configuration of BaristaOrderPub

eventPublisher, err := publisher.NewPublisher(connection)

baristaEventPublisher := infras.NewBaristaEventPublisher(eventPublisher)
kitchenEventPublisher := infras.NewKitchenEventPublisher(eventPublisher)

a.KitchenOrderPub.Configure(
pkgPublisher.ExchangeName("kitchen-order-exchange"),
pkgPublisher.BindingKey("kitchen-order-routing-key"),
pkgPublisher.MessageTypeName("kitchen-order-created"),
)
a.Consumer.Configure(
pkgConsumer.ExchangeName("counter-order-exchange"),
pkgConsumer.QueueName("counter-order-queue"),
pkgConsumer.BindingKey("counter-order-routing-key"),
pkgConsumer.ConsumerTag("counter-order-consumer"),
)

Here, KitchenOrderPub will overwrite the configuration of BaristaOrderPub

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.