# safak/microservices-kafka architecture

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

- Interactive diagram: https://gitdiagram.com/safak/microservices-kafka
- Repository: https://github.com/safak/microservices-kafka

## Overview

This repository compares three versions of a cart-checkout demo: a single Express backend, then service-based versions using Kafka. The visible user workflow is cart page → checkout request; in the microservice clients, checkout posts to the payment-service endpoint. The monolith route invokes authentication and then payment, analytics, order creation, and email helpers. Service implementations and Kafka consumers are represented as distinct components, but their event links are not shown by the available excerpts or SOURCE INDEX. The README is empty, so capability coverage is based on the source tree and index.

Main entry points: [`1-without-microservices/backend/index.js`](https://github.com/safak/microservices-kafka/blob/main/1-without-microservices/backend/index.js) (Order API), [`1-without-microservices/frontend/src/app/page.jsx`](https://github.com/safak/microservices-kafka/blob/main/1-without-microservices/frontend/src/app/page.jsx) (Cart Page), [`2-microservices-single-kafka-server/services/client/src/app/page.jsx`](https://github.com/safak/microservices-kafka/blob/main/2-microservices-single-kafka-server/services/client/src/app/page.jsx) (Cart Page), [`2-microservices-single-kafka-server/services/client/src/components/Pay.jsx`](https://github.com/safak/microservices-kafka/blob/main/2-microservices-single-kafka-server/services/client/src/components/Pay.jsx) (Checkout UI)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_monolith["Monolith Version"]
  node_cart1["Cart Page<br/>[page.jsx]"]
  node_checkout1["Checkout UI<br/>[Pay.jsx]"]
  node_api1["Order API<br/>[index.js]"]
  node_auth1["Auth Middleware<br/>[auth.js]"]
  node_domain1["Order Operations<br/>[db.js]"]
end

subgraph group_single["Single Kafka Version"]
  node_cart2["Cart Page<br/>[page.jsx]"]
  node_checkout2["Checkout UI<br/>[Pay.jsx]"]
  node_payment2["Payment Service<br/>[index.js]"]
  node_order2["Order Service<br/>[index.js]"]
  node_email2["Email Service<br/>[index.js]"]
  node_analytics2["Analytics Service<br/>[index.js]"]
  node_admin2["Topic Admin<br/>[admin.js]"]
  node_broker2["Kafka Broker"]
end

subgraph group_cluster["Kafka Cluster Version"]
  node_cart3["Cart Page<br/>[page.jsx]"]
  node_checkout3["Checkout UI<br/>[Pay.jsx]"]
  node_payment3["Payment Service<br/>[index.js]"]
  node_order3["Order Service<br/>[index.js]"]
  node_email3["Email Service<br/>[index.js]"]
  node_analytics3["Analytics Service<br/>[index.js]"]
  node_admin3["Topic Admin<br/>[admin.js]"]
  node_broker3["Kafka Broker"]
end

node_shopper(("Shopper"))

node_shopper -.->|"views"| node_cart1
node_cart1 -->|"renders"| node_checkout1
node_api1 -->|"authenticates"| node_auth1
node_api1 -->|"invokes operations"| node_domain1
node_shopper -.->|"views"| node_cart2
node_cart2 -.->|"renders"| node_checkout2
node_checkout2 -->|"posts cart"| node_payment2
node_admin2 -->|"creates topics"| node_broker2
node_shopper -.->|"views"| node_cart3
node_cart3 -.->|"renders"| node_checkout3
node_checkout3 -->|"posts cart"| node_payment3
node_admin3 -->|"creates topics"| node_broker3

click node_cart1 "https://github.com/safak/microservices-kafka/blob/main/1-without-microservices/frontend/src/app/page.jsx"
click node_checkout1 "https://github.com/safak/microservices-kafka/blob/main/1-without-microservices/frontend/src/components/Pay.jsx"
click node_api1 "https://github.com/safak/microservices-kafka/blob/main/1-without-microservices/backend/index.js"
click node_auth1 "https://github.com/safak/microservices-kafka/blob/main/1-without-microservices/backend/middleware/auth.js"
click node_domain1 "https://github.com/safak/microservices-kafka/blob/main/1-without-microservices/backend/db.js"
click node_cart2 "https://github.com/safak/microservices-kafka/blob/main/2-microservices-single-kafka-server/services/client/src/app/page.jsx"
click node_checkout2 "https://github.com/safak/microservices-kafka/blob/main/2-microservices-single-kafka-server/services/client/src/components/Pay.jsx"
click node_payment2 "https://github.com/safak/microservices-kafka/blob/main/2-microservices-single-kafka-server/services/payment-service/index.js"
click node_order2 "https://github.com/safak/microservices-kafka/blob/main/2-microservices-single-kafka-server/services/order-service/index.js"
click node_email2 "https://github.com/safak/microservices-kafka/blob/main/2-microservices-single-kafka-server/services/email-service/index.js"
click node_analytics2 "https://github.com/safak/microservices-kafka/blob/main/2-microservices-single-kafka-server/services/analytic-service/index.js"
click node_admin2 "https://github.com/safak/microservices-kafka/blob/main/2-microservices-single-kafka-server/services/kafka/admin.js"
click node_cart3 "https://github.com/safak/microservices-kafka/blob/main/3-microservices-kafka-cluster/services/client/src/app/page.jsx"
click node_checkout3 "https://github.com/safak/microservices-kafka/blob/main/3-microservices-kafka-cluster/services/client/src/components/Pay.jsx"
click node_payment3 "https://github.com/safak/microservices-kafka/blob/main/3-microservices-kafka-cluster/services/payment-service/index.js"
click node_order3 "https://github.com/safak/microservices-kafka/blob/main/3-microservices-kafka-cluster/services/order-service/index.js"
click node_email3 "https://github.com/safak/microservices-kafka/blob/main/3-microservices-kafka-cluster/services/email-service/index.js"
click node_analytics3 "https://github.com/safak/microservices-kafka/blob/main/3-microservices-kafka-cluster/services/analytic-service/index.js"
click node_admin3 "https://github.com/safak/microservices-kafka/blob/main/3-microservices-kafka-cluster/services/kafka/admin.js"

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_cart1,node_checkout1,node_api1,node_auth1,node_domain1 toneBlue
class node_cart2,node_checkout2,node_payment2,node_order2,node_email2,node_analytics2,node_admin2,node_broker2 toneAmber
class node_cart3,node_checkout3,node_payment3,node_order3,node_email3,node_analytics3,node_admin3,node_broker3 toneMint
class node_shopper toneIndigo
```

## Components

### Monolith Version

- [Cart Page](https://github.com/safak/microservices-kafka/blob/main/1-without-microservices/frontend/src/app/page.jsx): `1-without-microservices/frontend/src/app/page.jsx`
- [Checkout UI](https://github.com/safak/microservices-kafka/blob/main/1-without-microservices/frontend/src/components/Pay.jsx): `1-without-microservices/frontend/src/components/Pay.jsx`
- [Order API](https://github.com/safak/microservices-kafka/blob/main/1-without-microservices/backend/index.js): `1-without-microservices/backend/index.js`
- [Auth Middleware](https://github.com/safak/microservices-kafka/blob/main/1-without-microservices/backend/middleware/auth.js): `1-without-microservices/backend/middleware/auth.js`
- [Order Operations](https://github.com/safak/microservices-kafka/blob/main/1-without-microservices/backend/db.js): `1-without-microservices/backend/db.js`

### Single Kafka Version

- [Cart Page](https://github.com/safak/microservices-kafka/blob/main/2-microservices-single-kafka-server/services/client/src/app/page.jsx): `2-microservices-single-kafka-server/services/client/src/app/page.jsx`
- [Checkout UI](https://github.com/safak/microservices-kafka/blob/main/2-microservices-single-kafka-server/services/client/src/components/Pay.jsx): `2-microservices-single-kafka-server/services/client/src/components/Pay.jsx`
- [Payment Service](https://github.com/safak/microservices-kafka/blob/main/2-microservices-single-kafka-server/services/payment-service/index.js): `2-microservices-single-kafka-server/services/payment-service/index.js`
- [Order Service](https://github.com/safak/microservices-kafka/blob/main/2-microservices-single-kafka-server/services/order-service/index.js): `2-microservices-single-kafka-server/services/order-service/index.js`
- [Email Service](https://github.com/safak/microservices-kafka/blob/main/2-microservices-single-kafka-server/services/email-service/index.js): `2-microservices-single-kafka-server/services/email-service/index.js`
- [Analytics Service](https://github.com/safak/microservices-kafka/blob/main/2-microservices-single-kafka-server/services/analytic-service/index.js): `2-microservices-single-kafka-server/services/analytic-service/index.js`
- [Topic Admin](https://github.com/safak/microservices-kafka/blob/main/2-microservices-single-kafka-server/services/kafka/admin.js): `2-microservices-single-kafka-server/services/kafka/admin.js`
- **Kafka Broker**

### Kafka Cluster Version

- [Cart Page](https://github.com/safak/microservices-kafka/blob/main/3-microservices-kafka-cluster/services/client/src/app/page.jsx): `3-microservices-kafka-cluster/services/client/src/app/page.jsx`
- [Checkout UI](https://github.com/safak/microservices-kafka/blob/main/3-microservices-kafka-cluster/services/client/src/components/Pay.jsx): `3-microservices-kafka-cluster/services/client/src/components/Pay.jsx`
- [Payment Service](https://github.com/safak/microservices-kafka/blob/main/3-microservices-kafka-cluster/services/payment-service/index.js): `3-microservices-kafka-cluster/services/payment-service/index.js`
- [Order Service](https://github.com/safak/microservices-kafka/blob/main/3-microservices-kafka-cluster/services/order-service/index.js): `3-microservices-kafka-cluster/services/order-service/index.js`
- [Email Service](https://github.com/safak/microservices-kafka/blob/main/3-microservices-kafka-cluster/services/email-service/index.js): `3-microservices-kafka-cluster/services/email-service/index.js`
- [Analytics Service](https://github.com/safak/microservices-kafka/blob/main/3-microservices-kafka-cluster/services/analytic-service/index.js): `3-microservices-kafka-cluster/services/analytic-service/index.js`
- [Topic Admin](https://github.com/safak/microservices-kafka/blob/main/3-microservices-kafka-cluster/services/kafka/admin.js): `3-microservices-kafka-cluster/services/kafka/admin.js`
- **Kafka Broker**

### Other components

- **Shopper**

## Connections

- Shopper → Cart Page: views
- Cart Page → Checkout UI: renders (evidence: `1-without-microservices/frontend/src/app/page.jsx`)
- Order API → Auth Middleware: authenticates (evidence: `1-without-microservices/backend/index.js`)
- Order API → Order Operations: invokes operations (evidence: `1-without-microservices/backend/index.js`)
- Shopper → Cart Page: views
- Cart Page → Checkout UI: renders
- Checkout UI → Payment Service: posts cart (evidence: `2-microservices-single-kafka-server/services/client/src/components/Pay.jsx`)
- Topic Admin → Kafka Broker: creates topics (evidence: `2-microservices-single-kafka-server/services/kafka/admin.js`)
- Shopper → Cart Page: views
- Cart Page → Checkout UI: renders
- Checkout UI → Payment Service: posts cart (evidence: `3-microservices-kafka-cluster/services/client/src/components/Pay.jsx`)
- Topic Admin → Kafka Broker: creates topics (evidence: `3-microservices-kafka-cluster/services/kafka/admin.js`)
