# raees21/microcommerce architecture

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

- Interactive diagram: https://gitdiagram.com/raees21/microcommerce
- Repository: https://github.com/raees21/microcommerce

## Overview

MicroCommerce is a backend-first ecommerce platform with a React checkout client, REST gateway, and separate identity, profile, catalog, cart, ordering, payment, and shipping services. The main flow is authenticate, browse, manage a cart, submit an order, and query its projected status. Ordering validates product snapshots over gRPC, then coordinates payment and shipment through Kafka events and commands. The README documents the persistence roles and saga; sampled source confirms gateway routing, order submission, and several service registrations, but not every consumer or storage call in detail.

Main entry points: [`src/BuildingBlocks/MicroCommerce.Infrastructure/Messaging/KafkaEventPublisher.cs`](https://github.com/raees21/microcommerce/blob/main/src/BuildingBlocks/MicroCommerce.Infrastructure/Messaging/KafkaEventPublisher.cs) (Kafka), [`src/Gateway/MicroCommerce.ApiGateway/Program.cs`](https://github.com/raees21/microcommerce/blob/main/src/Gateway/MicroCommerce.ApiGateway/Program.cs) (API gateway), [`src/Services/Ordering/MicroCommerce.Ordering.Api/Program.cs`](https://github.com/raees21/microcommerce/blob/main/src/Services/Ordering/MicroCommerce.Ordering.Api/Program.cs) (Order submission), [`src/Services/Ordering/MicroCommerce.Ordering.Api/Services/PaymentAndShippingConsumers.cs`](https://github.com/raees21/microcommerce/blob/main/src/Services/Ordering/MicroCommerce.Ordering.Api/Services/PaymentAndShippingConsumers.cs) (Order saga)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Client entry"]
  node_web["React frontend<br/>[App.jsx]"]
  node_gateway["API gateway<br/>[Program.cs]"]
end

subgraph group_commerce["Commerce services"]
  node_identity["Identity service<br/>[Program.cs]"]
  node_users["User profiles<br/>[Program.cs]"]
  node_products["Product catalog<br/>[Program.cs]"]
  node_cart["Shopping cart<br/>[Program.cs]"]
end

subgraph group_workflow["Order workflow"]
  node_ordering["Order submission<br/>[Program.cs]"]
  node_saga["Order saga"]
  node_projection["Order read model"]
  node_payments["Payments<br/>[Program.cs]"]
  node_shipping["Shipping<br/>[Program.cs]"]
end

subgraph group_platform["Messaging and state"]
  node_kafka["Kafka"]
  node_postgres[("Postgres")]
  node_mongo[("MongoDB")]
  node_redis[("Redis")]
end

node_shopper(("Shopper"))

node_shopper -->|"uses"| node_web
node_web -->|"REST requests"| node_gateway
node_gateway -->|"forwards auth"| node_identity
node_gateway -->|"forwards profiles"| node_users
node_gateway -->|"forwards catalog"| node_products
node_gateway -->|"forwards cart"| node_cart
node_gateway -->|"forwards orders"| node_ordering
node_gateway -->|"forwards decisions"| node_payments
node_gateway -->|"forwards shipments"| node_shipping
node_ordering -->|"gRPC lookup"| node_products
node_identity -->|"publishes registration"| node_kafka
node_kafka -->|"registration event"| node_users
node_ordering -->|"publishes submission"| node_kafka
node_kafka -->|"submission event"| node_saga
node_saga -->|"payment command"| node_kafka
node_kafka -->|"payment command"| node_payments
node_payments -->|"payment result"| node_kafka
node_kafka -->|"payment result"| node_saga
node_saga -->|"shipment command"| node_kafka
node_kafka -->|"shipment command"| node_shipping
node_shipping -->|"shipment result"| node_kafka
node_kafka -->|"shipment result"| node_saga
node_ordering -->|"projects orders"| node_projection
node_web -->|"queries via API"| node_projection
node_identity -->|"persists credentials"| node_postgres
node_users -->|"persists profiles"| node_postgres
node_products -->|"persists catalog"| node_postgres
node_payments -->|"persists payments"| node_postgres
node_shipping -->|"persists shipments"| node_postgres
node_ordering -->|"stores events and saga state"| node_postgres
node_ordering -->|"projects read model"| node_mongo
node_cart -->|"persists snapshots"| node_mongo
node_cart -->|"serves fast basket"| node_redis

click node_web "https://github.com/raees21/microcommerce/blob/main/frontend/web/src/App.jsx"
click node_gateway "https://github.com/raees21/microcommerce/blob/main/src/Gateway/MicroCommerce.ApiGateway/Program.cs"
click node_identity "https://github.com/raees21/microcommerce/blob/main/src/Services/Identity/MicroCommerce.Identity.Api/Program.cs"
click node_users "https://github.com/raees21/microcommerce/blob/main/src/Services/Users/MicroCommerce.Users.Api/Program.cs"
click node_products "https://github.com/raees21/microcommerce/blob/main/src/Services/Products/MicroCommerce.Products.Api/Program.cs"
click node_cart "https://github.com/raees21/microcommerce/blob/main/src/Services/Cart/MicroCommerce.Cart.Api/Program.cs"
click node_ordering "https://github.com/raees21/microcommerce/blob/main/src/Services/Ordering/MicroCommerce.Ordering.Api/Program.cs"
click node_saga "https://github.com/raees21/microcommerce/blob/main/src/Services/Ordering/MicroCommerce.Ordering.Api/Services/PaymentAndShippingConsumers.cs"
click node_projection "https://github.com/raees21/microcommerce/blob/main/src/Services/Ordering/MicroCommerce.Ordering.Api/Services/OrderProjectionStore.cs"
click node_payments "https://github.com/raees21/microcommerce/blob/main/src/Services/Payments/MicroCommerce.Payments.Api/Program.cs"
click node_shipping "https://github.com/raees21/microcommerce/blob/main/src/Services/Shipping/MicroCommerce.Shipping.Api/Program.cs"
click node_kafka "https://github.com/raees21/microcommerce/blob/main/src/BuildingBlocks/MicroCommerce.Infrastructure/Messaging/KafkaEventPublisher.cs"

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_web,node_gateway toneBlue
class node_identity,node_users,node_products,node_cart toneAmber
class node_ordering,node_saga,node_projection,node_payments,node_shipping toneMint
class node_kafka,node_postgres,node_mongo,node_redis toneRose
class node_shopper toneIndigo
```

## Components

### Client entry

- [React frontend](https://github.com/raees21/microcommerce/blob/main/frontend/web/src/App.jsx): `frontend/web/src/App.jsx`
- [API gateway](https://github.com/raees21/microcommerce/blob/main/src/Gateway/MicroCommerce.ApiGateway/Program.cs): `src/Gateway/MicroCommerce.ApiGateway/Program.cs`

### Commerce services

- [Identity service](https://github.com/raees21/microcommerce/blob/main/src/Services/Identity/MicroCommerce.Identity.Api/Program.cs): `src/Services/Identity/MicroCommerce.Identity.Api/Program.cs`
- [User profiles](https://github.com/raees21/microcommerce/blob/main/src/Services/Users/MicroCommerce.Users.Api/Program.cs): `src/Services/Users/MicroCommerce.Users.Api/Program.cs`
- [Product catalog](https://github.com/raees21/microcommerce/blob/main/src/Services/Products/MicroCommerce.Products.Api/Program.cs): `src/Services/Products/MicroCommerce.Products.Api/Program.cs`
- [Shopping cart](https://github.com/raees21/microcommerce/blob/main/src/Services/Cart/MicroCommerce.Cart.Api/Program.cs): `src/Services/Cart/MicroCommerce.Cart.Api/Program.cs`

### Order workflow

- [Order submission](https://github.com/raees21/microcommerce/blob/main/src/Services/Ordering/MicroCommerce.Ordering.Api/Program.cs): `src/Services/Ordering/MicroCommerce.Ordering.Api/Program.cs`
- [Order saga](https://github.com/raees21/microcommerce/blob/main/src/Services/Ordering/MicroCommerce.Ordering.Api/Services/PaymentAndShippingConsumers.cs): `src/Services/Ordering/MicroCommerce.Ordering.Api/Services/PaymentAndShippingConsumers.cs`
- [Order read model](https://github.com/raees21/microcommerce/blob/main/src/Services/Ordering/MicroCommerce.Ordering.Api/Services/OrderProjectionStore.cs): `src/Services/Ordering/MicroCommerce.Ordering.Api/Services/OrderProjectionStore.cs`
- [Payments](https://github.com/raees21/microcommerce/blob/main/src/Services/Payments/MicroCommerce.Payments.Api/Program.cs): `src/Services/Payments/MicroCommerce.Payments.Api/Program.cs`
- [Shipping](https://github.com/raees21/microcommerce/blob/main/src/Services/Shipping/MicroCommerce.Shipping.Api/Program.cs): `src/Services/Shipping/MicroCommerce.Shipping.Api/Program.cs`

### Messaging and state

- [Kafka](https://github.com/raees21/microcommerce/blob/main/src/BuildingBlocks/MicroCommerce.Infrastructure/Messaging/KafkaEventPublisher.cs): `src/BuildingBlocks/MicroCommerce.Infrastructure/Messaging/KafkaEventPublisher.cs`
- **Postgres**
- **MongoDB**
- **Redis**

### Other components

- **Shopper**

## Connections

- Shopper → React frontend: uses
- React frontend → API gateway: REST requests
- API gateway → Identity service: forwards auth
- API gateway → User profiles: forwards profiles
- API gateway → Product catalog: forwards catalog
- API gateway → Shopping cart: forwards cart
- API gateway → Order submission: forwards orders
- API gateway → Payments: forwards decisions
- API gateway → Shipping: forwards shipments
- Order submission → Product catalog: gRPC lookup
- Identity service → Kafka: publishes registration
- Kafka → User profiles: registration event
- Order submission → Kafka: publishes submission
- Kafka → Order saga: submission event
- Order saga → Kafka: payment command
- Kafka → Payments: payment command
- Payments → Kafka: payment result
- Kafka → Order saga: payment result
- Order saga → Kafka: shipment command
- Kafka → Shipping: shipment command
- Shipping → Kafka: shipment result
- Kafka → Order saga: shipment result
- Order submission → Order read model: projects orders
- React frontend → Order read model: queries via API
- Identity service → Postgres: persists credentials
- User profiles → Postgres: persists profiles
- Product catalog → Postgres: persists catalog
- Payments → Postgres: persists payments
- Shipping → Postgres: persists shipments
- Order submission → Postgres: stores events and saga state
- Order submission → MongoDB: projects read model
- Shopping cart → MongoDB: persists snapshots
- Shopping cart → Redis: serves fast basket
