A polyglot, event-driven commerce backend built with Go, Python, gRPC, RabbitMQ, PostgreSQL, and Docker Compose. Go services handle users, orders, and the HTTP gateway. The Python payment service processes order events asynchronously and publishes payment completion events back to the order service.
flowchart LR
Client -->|REST| Gateway[Go API Gateway]
Gateway -->|gRPC| User[Go User Service]
Gateway -->|gRPC| Order[Go Order Service]
Order -->|order.created| Rabbit[(RabbitMQ)]
Rabbit -->|order.created| Payment[Python Payment Service]
Payment --> PaymentsDB[(Payments PostgreSQL)]
Payment -->|payment.completed| Rabbit
Rabbit -->|payment.completed| Order
Order --> OrdersDB[(Orders PostgreSQL)]
User --> UsersDB[(Users PostgreSQL)]
The event handlers are designed for at-least-once delivery. The Python payment
service upserts payments by order_id, and the order service applies status
updates idempotently, making message retries safe.
| Service | Language | Responsibility |
|---|---|---|
gateway |
Go | REST API and REST-to-gRPC translation |
usersvc |
Go | User creation and retrieval |
ordersvc |
Go | Order persistence, gRPC API, and payment-status updates |
paymentsvc |
Python | Payment validation, persistence, and event processing |
rabbitmq |
RabbitMQ | Durable asynchronous event delivery |
postgres |
PostgreSQL | Isolated user, order, and payment databases |
Requirements: Docker with the Compose plugin.
docker compose up --buildThe API Gateway is available at http://localhost:8080, and the RabbitMQ
management console is available at http://localhost:15672 with the default
local credentials guest / guest.
Create a user:
curl -sS -X POST http://localhost:8080/users \
-H 'Content-Type: application/json' \
-d '{"name":"Ada Lovelace","email":"ada@example.com"}'Use the returned user ID to create an order:
curl -sS -X POST http://localhost:8080/orders \
-H 'Content-Type: application/json' \
-d '{"user_id":"<USER_ID>","amount_cents":12500}'The order is created with a pending status. The Python service consumes the
order.created event, stores an idempotent payment record, publishes
payment.completed, and the order service updates the order to paid.
Confirm the final order status:
curl -sS http://localhost:8080/orders/<ORDER_ID>Run the complete local verification suite, including Go tests, Python tests, static analysis, and Docker Compose configuration validation:
make verifyUse make test, make vet, or make compose-check to run an individual
verification stage.
Regenerate Go and Python Protocol Buffer bindings after changing a .proto
file:
make proto