# muhammadatif12101982/events-platform architecture

> Architecture diagram of the GitHub repository muhammadatif12101982/events-platform, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-29). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/muhammadatif12101982/events-platform
- Repository: https://github.com/muhammadatif12101982/events-platform

## Overview

#### 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`](https://github.com/muhammadatif12101982/events-platform/blob/main/docker-compose.yml) (Docker Compose), [`src/Orders/Orders.Api/Program.cs`](https://github.com/muhammadatif12101982/events-platform/blob/main/src/Orders/Orders.Api/Program.cs) (Orders API), [`src/Identity/Identity.Server/Program.cs`](https://github.com/muhammadatif12101982/events-platform/blob/main/src/Identity/Identity.Server/Program.cs) (IdentityServer), [`src/Gateway/Gateway.Api/Program.cs`](https://github.com/muhammadatif12101982/events-platform/blob/main/src/Gateway/Gateway.Api/Program.cs) (Gateway API)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_access["Identity &amp; Edge"]
  node_identity["IdentityServer<br/>OAuth2/OIDC issuer<br/>[Program.cs]"]
  node_signing_keys["Signing keys<br/>persisted key material"]
  node_gateway["Gateway API<br/>YARP reverse proxy<br/>[Program.cs]"]
end

subgraph group_orders["Orders Service"]
  node_orders_api["Orders API<br/>Minimal API<br/>[Program.cs]"]
  node_order_commands["Order command slice<br/>vertical feature<br/>[CreateOrder.cs]"]
  node_orders_context["Orders DB context<br/>EF Core persistence<br/>[OrdersDBContext.cs]"]
  node_postgres[("Orders PostgreSQL<br/>transactional database")]
  node_outbox[("Outbox messages<br/>transactional event log<br/>[OutboxMessage.cs]")]
  node_outbox_publisher["Outbox publisher<br/>background publisher<br/>[OutboxPublisher.cs]"]
  node_projection["Order projection<br/>CQRS projector<br/>[OrderProjection.cs]"]
end

subgraph group_async["Async Notification"]
  node_rabbitmq["RabbitMQ<br/>message broker"]
  node_notification_worker["Notification worker<br/>.NET worker<br/>[Worker.cs]"]
end

subgraph group_ops["Observability"]
  node_telemetry["OpenTelemetry pipeline<br/>traces and metrics"]
  node_prometheus[("Prometheus<br/>metrics store<br/>[prometheus.yml]")]
  node_grafana["Grafana dashboards<br/>visualization<br/>[overview.json]"]
end

node_compose{{"Docker Compose<br/>local orchestration<br/>[docker-compose.yml]"}}

node_compose -->|"runs"| node_identity
node_compose -->|"runs"| node_gateway
node_compose -->|"runs"| node_orders_api
node_compose -->|"runs"| node_postgres
node_compose -->|"runs"| node_rabbitmq
node_compose -->|"runs"| node_notification_worker
node_identity -->|"persists"| node_signing_keys
node_gateway -->|"validates JWTs against"| node_identity
node_gateway -->|"routes authorized requests"| node_orders_api
node_orders_api -->|"validates JWTs against"| node_identity
node_orders_api -->|"dispatches commands"| node_order_commands
node_order_commands -->|"persists through"| node_orders_context
node_orders_context -->|"reads and writes"| node_postgres
node_orders_context -->|"commits with order changes"| node_outbox
node_outbox_publisher -->|"reads pending"| node_outbox
node_outbox_publisher -->|"publishes events"| node_rabbitmq
node_rabbitmq -->|"delivers order-created events"| node_notification_worker
node_projection -->|"writes order summaries"| node_postgres
node_orders_api -.->|"updates read model"| node_projection
node_identity -->|"exports"| node_telemetry
node_gateway -->|"exports"| node_telemetry
node_orders_api -->|"exports"| node_telemetry
node_notification_worker -->|"exports"| node_telemetry
node_telemetry -->|"metrics"| node_prometheus
node_prometheus -->|"dashboard data"| node_grafana

click node_compose "https://github.com/muhammadatif12101982/events-platform/blob/main/docker-compose.yml"
click node_identity "https://github.com/muhammadatif12101982/events-platform/blob/main/src/Identity/Identity.Server/Program.cs"
click node_signing_keys "https://github.com/muhammadatif12101982/events-platform/blob/main/src/Identity/Identity.Server/keys/is-signing-key-E4BA4B017D41DA53A708465B895045F9.json"
click node_gateway "https://github.com/muhammadatif12101982/events-platform/blob/main/src/Gateway/Gateway.Api/Program.cs"
click node_orders_api "https://github.com/muhammadatif12101982/events-platform/blob/main/src/Orders/Orders.Api/Program.cs"
click node_order_commands "https://github.com/muhammadatif12101982/events-platform/blob/main/src/Orders/Orders.Api/Features/Orders/CreateOrder.cs"
click node_orders_context "https://github.com/muhammadatif12101982/events-platform/blob/main/src/Orders/Orders.Api/OrdersDBContext.cs"
click node_outbox "https://github.com/muhammadatif12101982/events-platform/blob/main/src/Orders/Orders.Api/Entities/OutboxMessage.cs"
click node_outbox_publisher "https://github.com/muhammadatif12101982/events-platform/blob/main/src/Orders/Orders.Api/Infrastructure/OutboxPublisher.cs"
click node_projection "https://github.com/muhammadatif12101982/events-platform/blob/main/src/Orders/Orders.Api/Infrastructure/OrderProjection.cs"
click node_notification_worker "https://github.com/muhammadatif12101982/events-platform/blob/main/src/NotificationWorker/NotificationWorker/Worker.cs"
click node_prometheus "https://github.com/muhammadatif12101982/events-platform/blob/main/observability/prometheus.yml"
click node_grafana "https://github.com/muhammadatif12101982/events-platform/blob/main/observability/grafana/provisioning/dashboards/overview.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_identity,node_signing_keys,node_gateway toneBlue
class node_orders_api,node_order_commands,node_orders_context,node_postgres,node_outbox,node_outbox_publisher,node_projection toneAmber
class node_rabbitmq,node_notification_worker toneMint
class node_telemetry,node_prometheus,node_grafana toneRose
class node_compose toneNeutral
```

## Components

### Identity & Edge

- [IdentityServer](https://github.com/muhammadatif12101982/events-platform/blob/main/src/Identity/Identity.Server/Program.cs): OAuth2/OIDC issuer · Issues client-credentials JWTs with order scopes. · `src/Identity/Identity.Server/Program.cs`
- [Signing keys](https://github.com/muhammadatif12101982/events-platform/blob/main/src/Identity/Identity.Server/keys/is-signing-key-E4BA4B017D41DA53A708465B895045F9.json): persisted key material · `src/Identity/Identity.Server/keys/is-signing-key-E4BA4B017D41DA53A708465B895045F9.json`
- [Gateway API](https://github.com/muhammadatif12101982/events-platform/blob/main/src/Gateway/Gateway.Api/Program.cs): YARP reverse proxy · Authenticated ingress that routes permitted requests to Orders. · `src/Gateway/Gateway.Api/Program.cs`

### Orders Service

- [Orders API](https://github.com/muhammadatif12101982/events-platform/blob/main/src/Orders/Orders.Api/Program.cs): Minimal API · Independently validates tokens and exposes scoped order/product operations. · `src/Orders/Orders.Api/Program.cs`
- [Order command slice](https://github.com/muhammadatif12101982/events-platform/blob/main/src/Orders/Orders.Api/Features/Orders/CreateOrder.cs): vertical feature · Creates orders through authorized API handlers. · `src/Orders/Orders.Api/Features/Orders/CreateOrder.cs`
- [Orders DB context](https://github.com/muhammadatif12101982/events-platform/blob/main/src/Orders/Orders.Api/OrdersDBContext.cs): EF Core persistence · Persists transactional entities and outbox records. · `src/Orders/Orders.Api/OrdersDBContext.cs`
- **Orders PostgreSQL**: transactional database · Stores normalized state, outbox messages, and order summaries.
- [Outbox messages](https://github.com/muhammadatif12101982/events-platform/blob/main/src/Orders/Orders.Api/Entities/OutboxMessage.cs): transactional event log · Order-created events commit with domain changes. · `src/Orders/Orders.Api/Entities/OutboxMessage.cs`
- [Outbox publisher](https://github.com/muhammadatif12101982/events-platform/blob/main/src/Orders/Orders.Api/Infrastructure/OutboxPublisher.cs): background publisher · Relays pending durable events to RabbitMQ. · `src/Orders/Orders.Api/Infrastructure/OutboxPublisher.cs`
- [Order projection](https://github.com/muhammadatif12101982/events-platform/blob/main/src/Orders/Orders.Api/Infrastructure/OrderProjection.cs): CQRS projector · Maintains eventually consistent order summaries. · `src/Orders/Orders.Api/Infrastructure/OrderProjection.cs`

### Async Notification

- **RabbitMQ**: message broker
- [Notification worker](https://github.com/muhammadatif12101982/events-platform/blob/main/src/NotificationWorker/NotificationWorker/Worker.cs): .NET worker · Idempotently consumes order-created notifications using its own contract. · `src/NotificationWorker/NotificationWorker/Worker.cs`

### Observability

- **OpenTelemetry pipeline**: traces and metrics · Receives service telemetry for the local monitoring stack.
- [Prometheus](https://github.com/muhammadatif12101982/events-platform/blob/main/observability/prometheus.yml): metrics store · Scrapes service metrics. · `observability/prometheus.yml`
- [Grafana dashboards](https://github.com/muhammadatif12101982/events-platform/blob/main/observability/grafana/provisioning/dashboards/overview.json): visualization · Provisions the local overview dashboard. · `observability/grafana/provisioning/dashboards/overview.json`

### Other components

- [Docker Compose](https://github.com/muhammadatif12101982/events-platform/blob/main/docker-compose.yml): local orchestration · Local integration boundary for all runtime services. · `docker-compose.yml`

## Connections

- 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
