Event-driven checkout system built with Go microservices, NATS pub/sub, Docker, Postgres, gRPC, and grpc-gateway.
-
Orders service
- gRPC:
checkout.v1.OrderService/CreateOrder - HTTP (grpc-gateway):
POST /v1/orders - Persists order in
orders.orders - Publishes
orders.created
- gRPC:
-
Payments service
- Subscribes to
orders.created - Mocks payment processing
- Persists payment result in
payments.payments - Publishes
payments.succeededorpayments.failed
- Subscribes to
-
Notifications service
- Subscribes to payment result events
- Mocks email by logging to console
- Persists record in
notifications.notifications
/cmd
/orders
/payments
/notifications
/internal
/orders
/payments
/notifications
/pkg
/events
/config
/logger
/proto
/deploy
docker-compose.yml
/scripts
Makefile
make upSend 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 logsRun smoke check:
make smokeShutdown:
make downcheckout.proto is included under proto/checkout/v1. To generate official grpc/grpc-gateway stubs:
make protoRequirements:
protocprotoc-gen-goprotoc-gen-go-grpcprotoc-gen-grpc-gateway
- Client calls
POST /v1/orders - Orders service stores order and publishes
orders.created - Payments service consumes event, stores payment result, publishes payment status event
- Notifications service consumes payment status and stores/logs notification