# anant3008/serviceeats architecture

> Architecture diagram of the GitHub repository anant3008/serviceeats, 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/anant3008/serviceeats
- Repository: https://github.com/anant3008/serviceeats

## Overview

ServiceEats is a customer-facing food delivery platform: users browse restaurants, manage a cart, place and pay for orders, then follow delivery and notifications. The Next.js frontend sends requests through an API gateway to independently scoped backend services. Checkout creates an order and publishes an event; payment success then drives the documented asynchronous order, delivery, and notification workflow. MongoDB provides service-owned persistence. The README documents the overall routing and event flow; sampled code confirms checkout publishing and payment webhook behavior, but not every gateway or Kafka consumer connection.

Main entry points: [`services/gateway/src/index.js`](https://github.com/anant3008/serviceeats/blob/main/services/gateway/src/index.js) (API gateway), [`services/order-service/src`](https://github.com/anant3008/serviceeats/tree/main/services/order-service/src) (Cart and orders), [`services/payment-service/src`](https://github.com/anant3008/serviceeats/tree/main/services/payment-service/src) (Payments), [`frontend/app`](https://github.com/anant3008/serviceeats/tree/main/frontend/app) (Next.js app)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Customer app"]
  node_frontend["Next.js app"]
  node_location["Location and weather<br/>[route.js]"]
  node_trending["Trending food message<br/>[route.js]"]
end

subgraph group_business["Core services"]
  node_gateway["API gateway<br/>[index.js]"]
  node_users["User and profile"]
  node_restaurants["Restaurant catalog"]
end

subgraph group_fulfillment["Order fulfillment"]
  node_orders["Cart and orders"]
  node_payments["Payments"]
  node_delivery["Delivery"]
  node_notifications["Notifications"]
end

subgraph group_infrastructure["Data and events"]
  node_kafka["Kafka events"]
  node_userdb[("User MongoDB<br/>[db.js]")]
  node_restaurantdb[("Restaurant MongoDB<br/>[db.js]")]
  node_orderdb[("Order MongoDB<br/>[db.js]")]
  node_paymentdb[("Payment MongoDB<br/>[db.js]")]
  node_deliverydb[("Delivery MongoDB<br/>[db.js]")]
  node_notificationdb[("Notification MongoDB<br/>[db.js]")]
end

node_customer(("Customer"))
node_stripe{{"Stripe"}}

node_customer -->|"uses"| node_frontend
node_frontend -->|"requests"| node_gateway
node_frontend -->|"fetches location"| node_location
node_frontend -->|"requests message"| node_trending
node_location -->|"returns location"| node_customer
node_trending -->|"returns message"| node_customer
node_gateway -->|"routes requests"| node_users
node_gateway -->|"routes requests"| node_restaurants
node_gateway -->|"routes requests"| node_orders
node_gateway -->|"routes requests"| node_payments
node_gateway -->|"routes requests"| node_delivery
node_gateway -->|"routes requests"| node_notifications
node_users -->|"reads and writes"| node_userdb
node_restaurants -->|"reads and writes"| node_restaurantdb
node_orders -->|"reads and writes"| node_orderdb
node_payments -->|"reads and writes"| node_paymentdb
node_delivery -->|"persists delivery"| node_deliverydb
node_notifications -->|"reads and writes"| node_notificationdb
node_orders -->|"publishes order"| node_kafka
node_payments -->|"creates payment"| node_stripe
node_stripe -->|"sends webhook"| node_payments
node_payments -->|"publishes payment result"| node_kafka
node_kafka -->|"dispatches events"| node_orders
node_kafka -->|"dispatches events"| node_delivery
node_kafka -->|"dispatches events"| node_notifications
node_orders -.->|"updates rating"| node_restaurants

click node_frontend "https://github.com/anant3008/serviceeats/tree/main/frontend/app"
click node_location "https://github.com/anant3008/serviceeats/blob/main/frontend/app/api/geo/route.js"
click node_trending "https://github.com/anant3008/serviceeats/blob/main/frontend/app/api/trending-message/route.js"
click node_gateway "https://github.com/anant3008/serviceeats/blob/main/services/gateway/src/index.js"
click node_users "https://github.com/anant3008/serviceeats/tree/main/services/user-service/src"
click node_restaurants "https://github.com/anant3008/serviceeats/tree/main/services/restaurant-service/src"
click node_orders "https://github.com/anant3008/serviceeats/tree/main/services/order-service/src"
click node_payments "https://github.com/anant3008/serviceeats/tree/main/services/payment-service/src"
click node_delivery "https://github.com/anant3008/serviceeats/tree/main/services/delivery-service/src"
click node_notifications "https://github.com/anant3008/serviceeats/tree/main/services/notification-service/src"
click node_userdb "https://github.com/anant3008/serviceeats/blob/main/services/user-service/src/config/db.js"
click node_restaurantdb "https://github.com/anant3008/serviceeats/blob/main/services/restaurant-service/src/config/db.js"
click node_orderdb "https://github.com/anant3008/serviceeats/blob/main/services/order-service/src/config/db.js"
click node_paymentdb "https://github.com/anant3008/serviceeats/blob/main/services/payment-service/src/config/db.js"
click node_deliverydb "https://github.com/anant3008/serviceeats/blob/main/services/delivery-service/src/config/db.js"
click node_notificationdb "https://github.com/anant3008/serviceeats/blob/main/services/notification-service/src/config/db.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_frontend,node_location,node_trending toneBlue
class node_gateway,node_users,node_restaurants toneAmber
class node_orders,node_payments,node_delivery,node_notifications toneMint
class node_kafka,node_userdb,node_restaurantdb,node_orderdb,node_paymentdb,node_deliverydb,node_notificationdb toneRose
class node_customer,node_stripe toneIndigo
```

## Components

### Customer app

- [Next.js app](https://github.com/anant3008/serviceeats/tree/main/frontend/app): `frontend/app`
- [Location and weather](https://github.com/anant3008/serviceeats/blob/main/frontend/app/api/geo/route.js): `frontend/app/api/geo/route.js`
- [Trending food message](https://github.com/anant3008/serviceeats/blob/main/frontend/app/api/trending-message/route.js): `frontend/app/api/trending-message/route.js`

### Core services

- [API gateway](https://github.com/anant3008/serviceeats/blob/main/services/gateway/src/index.js): `services/gateway/src/index.js`
- [User and profile](https://github.com/anant3008/serviceeats/tree/main/services/user-service/src): `services/user-service/src`
- [Restaurant catalog](https://github.com/anant3008/serviceeats/tree/main/services/restaurant-service/src): `services/restaurant-service/src`

### Order fulfillment

- [Cart and orders](https://github.com/anant3008/serviceeats/tree/main/services/order-service/src): `services/order-service/src`
- [Payments](https://github.com/anant3008/serviceeats/tree/main/services/payment-service/src): `services/payment-service/src`
- [Delivery](https://github.com/anant3008/serviceeats/tree/main/services/delivery-service/src): `services/delivery-service/src`
- [Notifications](https://github.com/anant3008/serviceeats/tree/main/services/notification-service/src): `services/notification-service/src`

### Data and events

- **Kafka events**
- [User MongoDB](https://github.com/anant3008/serviceeats/blob/main/services/user-service/src/config/db.js): `services/user-service/src/config/db.js`
- [Restaurant MongoDB](https://github.com/anant3008/serviceeats/blob/main/services/restaurant-service/src/config/db.js): `services/restaurant-service/src/config/db.js`
- [Order MongoDB](https://github.com/anant3008/serviceeats/blob/main/services/order-service/src/config/db.js): `services/order-service/src/config/db.js`
- [Payment MongoDB](https://github.com/anant3008/serviceeats/blob/main/services/payment-service/src/config/db.js): `services/payment-service/src/config/db.js`
- [Delivery MongoDB](https://github.com/anant3008/serviceeats/blob/main/services/delivery-service/src/config/db.js): `services/delivery-service/src/config/db.js`
- [Notification MongoDB](https://github.com/anant3008/serviceeats/blob/main/services/notification-service/src/config/db.js): `services/notification-service/src/config/db.js`

### Other components

- **Customer**
- **Stripe**

## Connections

- Customer → Next.js app: uses
- Next.js app → API gateway: requests
- Next.js app → Location and weather: fetches location
- Next.js app → Trending food message: requests message
- Location and weather → Customer: returns location
- Trending food message → Customer: returns message
- API gateway → User and profile: routes requests
- API gateway → Restaurant catalog: routes requests
- API gateway → Cart and orders: routes requests
- API gateway → Payments: routes requests
- API gateway → Delivery: routes requests
- API gateway → Notifications: routes requests
- User and profile → User MongoDB: reads and writes
- Restaurant catalog → Restaurant MongoDB: reads and writes
- Cart and orders → Order MongoDB: reads and writes
- Payments → Payment MongoDB: reads and writes
- Delivery → Delivery MongoDB: persists delivery
- Notifications → Notification MongoDB: reads and writes
- Cart and orders → Kafka events: publishes order
- Payments → Stripe: creates payment
- Stripe → Payments: sends webhook
- Payments → Kafka events: publishes payment result
- Kafka events → Cart and orders: dispatches events
- Kafka events → Delivery: dispatches events
- Kafka events → Notifications: dispatches events
- Cart and orders → Restaurant catalog: updates rating
