Overview
The Ordering service manages the shopping cart and order lifecycle. It handles adding reserved seats to a cart, transitioning orders from draft to pending state, and preparing orders for payment processing. Port: 5003Database Schema:
bc_orderingDependencies: PostgreSQL, Redis, Kafka
Responsibilities
- Manage shopping cart (draft orders)
- Create and track orders through their lifecycle
- Support both authenticated users and guest checkout (via guest tokens)
- Transition orders from
draft→pending→paid→fulfilled - Link orders to seat reservations
- Consume Kafka events from other services
- Provide order details for fulfillment service
API Endpoints
Add to Cart
Adds a reserved seat to the user’s cart. Creates a draft order if none exists.
The ID of the reservation
The ID of the seat
The price of the seat
The authenticated user ID (required if GuestToken not provided)
The guest token for anonymous checkout (required if UserId not provided)
~/workspace/source/services/ordering/src/Api/Controllers/CartController.cs
The updated order (cart) object
Checkout Order
Checks out an order, transitioning it from
draft to pending state (ready for payment).The ID of the order to checkout
The authenticated user ID
The guest token for anonymous checkout
~/workspace/source/services/ordering/src/Api/Controllers/OrdersController.cs
The checked-out order in
pending state- 400 Bad Request: Validation errors
- 401 Unauthorized: UserId/GuestToken mismatch
- 404 Not Found: Order not found
Get Order Details
Retrieves order details by ID. Used by the Fulfillment service for ticket enrichment.
The order ID
~/workspace/source/services/ordering/src/Api/Controllers/OrdersController.cs
Domain Models
Order
Represents a customer order (cart).Unique order identifier
Authenticated user ID (null for guest orders)
Guest checkout token (null for authenticated orders)
Total order amount
Order state:
draft, pending, paid, fulfilled, or cancelledWhen the order was created
When the order was paid (null if unpaid)
Collection of order items (seats)
~/workspace/source/services/ordering/src/Domain/Entities/Order.cs
OrderItem
Represents a single seat/ticket within an order.Unique order item identifier
Reference to the parent order
Reference to the seat
Price for this item
~/workspace/source/services/ordering/src/Domain/Entities/Order.cs
Configuration
Database Connections
appsettings.json
JWT Authentication
Kafka Consumer
Order State Machine
Orders progress through the following states:- draft: Initial state when items are added to cart
- pending: After checkout, ready for payment
- paid: Payment successfully processed (updated by Payment service)
- fulfilled: Tickets generated and delivered (updated by Fulfillment service)
- cancelled: Order was cancelled or payment failed
Kafka Integration
The Ordering service consumes Kafka events to update order state:- payment-succeeded: Transitions order from
pending→paid - ticket-issued: Transitions order from
paid→fulfilled
Use Cases
- AddToCart: Adds a reserved seat to the user’s cart (draft order)
- CheckoutOrder: Validates and transitions order to
pendingstate - GetOrder: Retrieves order details for internal service consumption
Architecture Notes
- Uses MediatR for CQRS-style command/query handling
- Supports both authenticated and guest checkout flows
- Infrastructure services registered via
AddInfrastructure()extension method - Listens to Kafka for order state updates from downstream services
