Skip to content

carson-brill/event-driven-checkout

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

event-driven-checkout

Event-driven checkout system built with Go microservices, NATS pub/sub, Docker, Postgres, gRPC, and grpc-gateway.

Services

  1. Orders service

    • gRPC: checkout.v1.OrderService/CreateOrder
    • HTTP (grpc-gateway): POST /v1/orders
    • Persists order in orders.orders
    • Publishes orders.created
  2. Payments service

    • Subscribes to orders.created
    • Mocks payment processing
    • Persists payment result in payments.payments
    • Publishes payments.succeeded or payments.failed
  3. Notifications service

    • Subscribes to payment result events
    • Mocks email by logging to console
    • Persists record in notifications.notifications

Project Layout

/cmd
  /orders
  /payments
  /notifications
/internal
  /orders
  /payments
  /notifications
/pkg
  /events
  /config
  /logger
/proto
/deploy
  docker-compose.yml
/scripts
Makefile

Run with Docker Compose

make up

Send a request through HTTP -> grpc-gateway -> gRPC:

curl -X POST http://localhost:8080/v1/orders \
  -H "Content-Type: application/json" \
  -d '{"user_email":"jane@example.com","amount_cents":2599,"currency":"USD"}'

Watch logs:

make logs

Run smoke check:

make smoke

Shutdown:

make down

Protobuf Generation

checkout.proto is included under proto/checkout/v1. To generate official grpc/grpc-gateway stubs:

make proto

Requirements:

  • protoc
  • protoc-gen-go
  • protoc-gen-go-grpc
  • protoc-gen-grpc-gateway

Event Flow

  1. Client calls POST /v1/orders
  2. Orders service stores order and publishes orders.created
  3. Payments service consumes event, stores payment result, publishes payment status event
  4. Notifications service consumes payment status and stores/logs notification

About

Event-driven microservices system in Go using NATS, Docker, and Postgres

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors