How muhammadatif12101982/events-platform works
Purpose and Composition
Events Platform is a .NET 10 microservices learning system for authenticated order/product operations, asynchronous order-event notification, CQRS read models, and observability. Docker Compose is the local integration boundary; the solution root is EventsPlatform.slnx and service startup entry points are each service’s Program.cs.
Identity and Access Control
Duende IdentityServer issues OAuth2/OIDC client-credentials JWTs with orders.read and orders.write scopes. Signing-key material is persisted with the identity service. Both gateway and Orders API validate tokens, so the domain API remains protected when called outside the proxy.
• src/Identity/Identity.Server/Program.cs
• src/Identity/Identity.Server/Config.cs
• src/Identity/Identity.Server/keys/is-signing-key-E4BA4B017D41DA53A708465B895045F9.json
Edge Routing
The Gateway is a YARP reverse proxy and authenticated ingress for client API traffic. It validates bearer tokens, then routes permitted requests to Orders. Its runtime/container boundary is defined separately from the downstream service.
• src/Gateway/Gateway.Api/Program.cs
• src/Gateway/Gateway.Api/appsettings.json
• src/Gateway/Gateway.Api/Dockerfile
Orders Command and Domain Model
Orders is a Minimal API organized as vertical feature slices. Product and order commands operate on EF Core entities; pure business calculations are isolated from infrastructure. API handlers authorize by scope and persist state through the Orders database context.
• src/Orders/Orders.Api/Program.cs
• src/Orders/Orders.Api/Features/Orders/CreateOrder.cs
• src/Orders/Orders.Api/OrdersDBContext.cs
PostgreSQL Persistence and CQRS Read Path
PostgreSQL is the primary transactional store for products, customers, orders, outbox records, and denormalized order summaries. EF Core migrations define schema evolution. OrderProjection builds/maintains OrderSummary, making summary reads eventually consistent with order writes rather than directly querying normalized order state.
• src/Orders/Orders.Api/Entities/Order.cs
• src/Orders/Orders.Api/Entities/OrderSummary.cs
• src/Orders/Orders.Api/Infrastructure/OrderProjection.cs
Transactional Outbox and Messaging
Order creation records an OrderCreatedEvent in the same PostgreSQL transaction as domain changes through OutboxMessage. The Orders-side background publisher relays pending outbox entries to RabbitMQ, separating durable command completion from broker availability. RabbitMQ consumers receive the event asynchronously.
• src/Orders/Orders.Api/Entities/OutboxMessage.cs
• src/Orders/Orders.Api/Infrastructure/OutboxPublisher.cs
• src/Orders/Orders.Api/Domain/Events/OrderCreatedEvent.cs
Notification Worker
A standalone .NET worker consumes RabbitMQ order-created events and performs idempotent notification processing. It has its own event contract and broker configuration, creating an explicit service boundary rather than referencing Orders internals.
• src/NotificationWorker/NotificationWorker/Program.cs
• src/NotificationWorker/NotificationWorker/Worker.cs
• src/NotificationWorker/NotificationWorker/Domain/OrderCreatedEvent.cs
Runtime, Operations, and Observability
docker-compose.yml orchestrates Identity, Gateway, Orders, PostgreSQL, RabbitMQ, Notification Worker, and observability dependencies. OpenTelemetry-based traces/metrics flow to the local monitoring stack; Prometheus scrapes metrics and Grafana provisions dashboards. Architectural commitments are recorded in ADRs, notably vertical slices, PostgreSQL, auth, outbox, observability, and CQRS.
• docker-compose.yml
• observability/prometheus.yml
• observability/grafana/provisioning/dashboards/overview.json
Main entry points: docker-compose.yml Docker Compose · Orders.Api/Program.cs Orders API · Identity.Server/Program.cs IdentityServer · Gateway.Api/Program.cs Gateway API
Components 16
Identity & Edge
- IdentityServer · Issues client-credentials JWTs with order scopes.
src/Identity/Identity.Server/Program.cs - Signing keys
src/Identity/Identity.Server/keys/is-signing-key-E4BA4B017D41DA53A708465B895045F9.json - Gateway API · Authenticated ingress that routes permitted requests to Orders.
src/Gateway/Gateway.Api/Program.cs
Orders Service
- Orders API · Independently validates tokens and exposes scoped order/product operations.
src/Orders/Orders.Api/Program.cs - Order command slice · Creates orders through authorized API handlers.
src/Orders/Orders.Api/Features/Orders/CreateOrder.cs - Orders DB context · Persists transactional entities and outbox records.
src/Orders/Orders.Api/OrdersDBContext.cs - Orders PostgreSQL · Stores normalized state, outbox messages, and order summaries.
- Outbox messages · Order-created events commit with domain changes.
src/Orders/Orders.Api/Entities/OutboxMessage.cs - Outbox publisher · Relays pending durable events to RabbitMQ.
src/Orders/Orders.Api/Infrastructure/OutboxPublisher.cs - Order projection · Maintains eventually consistent order summaries.
src/Orders/Orders.Api/Infrastructure/OrderProjection.cs
Async Notification
- RabbitMQ
- Notification worker · Idempotently consumes order-created notifications using its own contract.
src/NotificationWorker/NotificationWorker/Worker.cs
Observability
- OpenTelemetry pipeline · Receives service telemetry for the local monitoring stack.
- Prometheus · Scrapes service metrics.
observability/prometheus.yml - Grafana dashboards · Provisions the local overview dashboard.
observability/grafana/provisioning/dashboards/overview.json
Other components
- Docker Compose · Local integration boundary for all runtime services.
docker-compose.yml
Connections 25
- Docker Compose → IdentityServer: runs
- Docker Compose → Gateway API: runs
- Docker Compose → Orders API: runs
- Docker Compose → Orders PostgreSQL: runs
- Docker Compose → RabbitMQ: runs
- Docker Compose → Notification worker: runs
- IdentityServer → Signing keys: persists
- Gateway API → IdentityServer: validates JWTs against
- Gateway API → Orders API: routes authorized requests
- Orders API → IdentityServer: validates JWTs against
- Orders API → Order command slice: dispatches commands
- Order command slice → Orders DB context: persists through
- Orders DB context → Orders PostgreSQL: reads and writes
- Orders DB context → Outbox messages: commits with order changes
- Outbox publisher → Outbox messages: reads pending
- Outbox publisher → RabbitMQ: publishes events
- RabbitMQ → Notification worker: delivers order-created events
- Order projection → Orders PostgreSQL: writes order summaries
- Orders API → Order projection: updates read model
- IdentityServer → OpenTelemetry pipeline: exports
- Gateway API → OpenTelemetry pipeline: exports
- Orders API → OpenTelemetry pipeline: exports
- Notification worker → OpenTelemetry pipeline: exports
- OpenTelemetry pipeline → Prometheus: metrics
- Prometheus → Grafana dashboards: dashboard data