This document provides a cross-repo system map for the following repositories.
All listed repositories are part of the bitovi-training GitHub organization:
api-testsauth-middlewareauth-middleware-goloyalty-serviceorder-serviceproduct-serviceuser-service
It is intended as a fast, practical context layer for AI agents navigating and modifying this ecosystem.
- order-service (Go):
http://localhost:8100 - product-service (NestJS):
http://localhost:8200 - loyalty-service (NestJS):
http://localhost:8300 - user-service (NestJS):
http://localhost:8400
service-infra/docker-compose.yml wires service-to-service URLs:
- order-service → product-service (
PRODUCT_SERVICE_URL) - order-service → loyalty-service (
LOYALTY_SERVICE_URL) - loyalty-service → order-service (
ORDER_SERVICE_URL) - loyalty-service → user-service (
USER_SERVICE_URL)
- A user signs up/signs in via user-service and gets a mock JWT.
- JWT is used to call protected endpoints in order-service, product-service, loyalty-service.
- order-service reads product data from product-service for pricing/validation.
- On submit, order-service posts order accrual data to loyalty-service (
POST /loyalty/orders). - loyalty-service calculates balances from order data and redemptions, and validates users through user-service.
- api-tests executes end-to-end and domain test suites against all services.
- Auth is mock JWT-based (intended for development/testing).
- Tokens are parsed for claims (
sub,email,roles,exp, etc.). - Signature verification is intentionally not enforced in current middleware implementations.
- NestJS services use:
@bitovi-corp/auth-middleware(auth-middlewarerepo)AuthGuardRequireRolesGuard(any-of semantics)RequireAllRolesGuard(all-of semantics)- decorators such as
@Roles()
- Go services use:
github.com/bitovi-corp/auth-middleware-go/middleware(auth-middleware-gorepo)AuthMiddlewareRequireRoles(...)(any-of semantics)RequireAllRoles(...)(all-of semantics)
Do not assume production-grade JWT verification or token revocation durability in this environment. Several components explicitly describe this as mock/dev behavior.
- Registration, authentication, and logout.
- Issues mock JWT tokens consumed by other services.
- Exposes user-validation endpoint used by loyalty-service.
POST /auth/signupPOST /auth/signinPOST /auth/logoutGET /healthGET /users/:userId/validate
- Global validation pipe enabled.
- In-memory storage patterns (users + blacklist behavior discussed in docs).
- Compatible token payload includes at least
sub,email,roles,iat,exp.
- In-memory product catalog APIs.
GET /products→ publicGET /products/:id→AuthGuardPOST /products→AuthGuard+RequireRolesGuard+@Roles('admin')
- Minimal bounded context: product listing, lookup, and create.
- Consumed by order-service via HTTP client for order creation/update validation.
- Order lifecycle management and status transitions.
- Integrates with product-service (product lookup/pricing context).
- Integrates with loyalty-service for loyalty accrual on submit.
GET /health→ publicGET /orders→ admin role requiredPOST /orders→ admin role requiredGET /orders/{orderId}→ admin role requiredPATCH /orders/{orderId}→ admin role requiredPOST /orders/{orderId}/submit→ admin role required
Auth and logging are composed centrally in cmd/server/main.go.
- Contract-first orientation around
api/openapi.yaml. - Uses
auth-middleware-gofor role-based enforcement. - On submit flow, uses loyalty client to call
POST /loyalty/orders.
- Loyalty balance calculation, redemption processing, and redemption history.
- Loyalty point accrual intake from order-service submissions.
- User validation through user-service API.
GET /loyalty/:userId/balance→AuthGuardPOST /loyalty/:userId/redeem→AuthGuardGET /loyalty/:userId/redemptions→AuthGuardPOST /loyalty/orders→AuthGuard(called by order-service)
- Calls order-service via
OrderClient(ORDER_SERVICE_URL) - Calls user-service via
UserClient(USER_SERVICE_URL)
- Balance is derived from order data + redemptions.
- Integration docs indicate migration from hardcoded users to user-service validation.
- Reusable NestJS auth/authorization building blocks for services.
AuthGuard(parse/validate token shape + claims)RequireRolesGuard(@Roles(...), any-of)RequireAllRolesGuard(@RequireAllRoles(...), all-of)@User()parameter decorator for claims extraction
- Prefer using this package in NestJS services instead of duplicating auth logic.
- Role comparisons are case-sensitive.
- Reusable Go HTTP middleware for token checks + RBAC.
AuthMiddleware(next)RequireRoles(roles...)(any-of)RequireAllRoles(roles...)(all-of)GetUserClaims(r)
- Prefer composition with this middleware in Go handlers.
- Keep auth behavior consistent with Nest counterpart when changing cross-service access behavior.
- End-to-end and service-level API tests (Jest + TypeScript).
- Validates auth behavior, role constraints, and full commerce flows across services.
- Uses
.env(auto-generated from.env.exampleif missing). - Defaults:
USER_SERVICE_URL=http://localhost:8400ORDER_SERVICE_URL=http://localhost:8100PRODUCT_SERVICE_URL=http://localhost:8200LOYALTY_SERVICE_URL=http://localhost:8300
- user auth flows (
/auth/signup,/auth/signin,/auth/logout) - product endpoints and admin enforcement
- order lifecycle and submission behavior
- loyalty balance/redeem/history and accrual input
- full E2E flows across multiple services
+-------------------+
| user-service |
| auth + users API |
+---------+---------+
^
| validate user
|
+-------------------+ calls | +-------------------+
| loyalty-service +----------+ | api-tests |
| balance/redeem |<--------------+ e2e + domain APIs |
| accrual endpoint | tests all +-------------------+
+---------+---------+
^
| POST /loyalty/orders (submit accrual)
|
+---------+---------+ fetch products +-------------------+
| order-service +------------------------->| product-service |
| order workflow | | catalog endpoints |
+-------------------+ +-------------------+
Shared auth libs:
- NestJS services use auth-middleware
- Go services use auth-middleware-go
8100→ order-service8200→ product-service8300→ loyalty-service8400→ user-service
PORTPRODUCT_SERVICE_URL(order-service)LOYALTY_SERVICE_URL(order-service)ORDER_SERVICE_URL(loyalty-service)USER_SERVICE_URL(loyalty-service)
When changing behavior across this system:
- Trace impacted contracts first
- order-service OpenAPI + controller routes
- NestJS controller DTO/guard combinations
- Check auth + role impacts
- verify both middleware packages if semantics should stay aligned
- Update integration points
- especially order ↔ loyalty and loyalty ↔ user interactions
- Update/extend
api-tests- treat tests as cross-repo safety net for regressions
- Reconcile local infra assumptions
- ensure env vars and compose wiring remain consistent
- Mock JWT behavior is intentional in multiple repos (not production hardened).
- Services are demo-friendly and often in-memory by design.
- Auth expectations are strict in role checks (case sensitivity can matter in tests).
api-tests/README.mdauth-middleware/README.mdauth-middleware-go/README.mdloyalty-service/README.mdloyalty-service/ORDER_CLIENT.mdloyalty-service/USER_SERVICE_INTEGRATION.mdorder-service/README.mdorder-service/cmd/server/main.goproduct-service/README.mdproduct-service/src/products/products.controller.tsuser-service/README.mduser-service/src/controllers/user.controller.tsservice-infra/README.mdservice-infra/docker-compose.yml