The per-user shopping cart: which products are selected, in what quantity, and the price snapshot taken when they were added.
- Owns: cart items for a user — product, quantity, and the denormalised add-time price — plus the cart totals derived from them.
- Does not own: the product catalog or current prices (
product-service), stock and availability (inventory-service), or the order the cart becomes (order-service,checkout-service).
| Area | Technology |
|---|---|
| Runtime | Go 1.27 |
| Transports | HTTP (private customer routes, one internal route) · gRPC (east-west read) |
| Data | PostgreSQL — one table, cart_items |
| Platform libraries | authmw, dbx, grpcx, httpx, logger/zapx, migratex, obsx, proto |
- Canonical contract:
homelab/docs/api/cart.md - Shared conventions:
homelab/docs/api/api.md - Surfaces: JWT-protected HTTP for the customer's own cart, one tokenless
internal route used by the order workflow to clear a cart, and
cart.v1.CartServiceeast-west so checkout can read a cart snapshot. HTTP:8080also carries/healthand/ready.
Routes, payloads and error codes live in the contract, so there is one place to change when they change.
Prefer the homelab local-stack — the customer routes need a signed token and a catalog to add from.
Standalone you need PostgreSQL reachable through the DB_* variables:
go run cmd/main.go migrate # apply schema migrations
go run cmd/main.go seed # demo cart rows — development only, refuses production
go run cmd/main.go # serve HTTP :8080 + gRPC :9090The commands CI runs, so a green local run means a green pipeline:
go build ./...
go test -race ./...
go test -tags=integration ./internal/core/repository/... # needs Docker (testcontainers)
golangci-lint runMIT