# nathan-alweendo/assignment-2 architecture

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

- Interactive diagram: https://gitdiagram.com/nathan-alweendo/assignment-2
- Repository: https://github.com/nathan-alweendo/assignment-2

## Overview

This is a Ballerina-based food-delivery platform with a browser checkout and tracking interface, an order-service orchestrator, and independent services for payment, restaurants, delivery, customer profiles, notifications, and administration. The documented customer workflow submits an order to the order API and proceeds to a tracking view; backend lifecycle stages are described as event-driven. The excerpts show frontend requests and local tracking simulation, but backend source was not sampled, so backend relationships below rely on README statements rather than inspected calls.

Main entry points: [`order-service`](https://github.com/nathan-alweendo/assignment-2/tree/main/order-service) (Order orchestration), [`delivery-service`](https://github.com/nathan-alweendo/assignment-2/tree/main/delivery-service) (Delivery dispatch), [`payment-service`](https://github.com/nathan-alweendo/assignment-2/tree/main/payment-service) (Payment processing), [`restaurant-service`](https://github.com/nathan-alweendo/assignment-2/tree/main/restaurant-service) (Restaurant inventory)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Web experience"]
  node_checkout["Checkout UI<br/>[app.js]"]
  node_tracking["Tracking UI<br/>[tracking.js]"]
  node_adminui["Metrics UI<br/>[admin.js]"]
end

subgraph group_fulfillment["Order fulfillment"]
  node_orders["Order orchestration"]
  node_payments["Payment processing"]
  node_restaurant["Restaurant inventory"]
  node_delivery["Delivery dispatch"]
end

subgraph group_platform["Platform services"]
  node_customers["Customer profiles"]
  node_notifications["Event notifications"]
  node_kafka["Kafka event stream"]
end

subgraph group_analytics["Administration"]
  node_admin["Business metrics"]
end

subgraph group_persistence["Service databases"]
  node_orderdb[("Order database<br/>[db.bal]")]
  node_admindb[("Admin database<br/>[db.bal]")]
  node_customerdb[("Customer database<br/>[db.bal]")]
  node_paymentdb[("Payment database")]
  node_restaurantdb[("Restaurant database")]
  node_deliverydb[("Delivery database")]
end

node_customer(("Customer"))
node_adminuser(("Admin user"))

node_customer -->|"places order"| node_checkout
node_checkout -->|"POSTs order"| node_orders
node_orders -->|"returns order data"| node_tracking
node_tracking -->|"reads cached result"| node_orders
node_orders -->|"initiates payment"| node_payments
node_orders -->|"routes order"| node_restaurant
node_orders -->|"drives lifecycle"| node_delivery
node_orders -->|"publishes events"| node_kafka
node_payments -->|"emits payment events"| node_kafka
node_restaurant -->|"emits ticket events"| node_kafka
node_delivery -->|"emits tracking updates"| node_kafka
node_customers -->|"hooks dispatch stream"| node_delivery
node_kafka -->|"consumes alerts"| node_notifications
node_kafka -->|"supplies transactional logs"| node_admin
node_adminuser -->|"views metrics"| node_adminui
node_adminui -->|"fetches metrics"| node_admin
node_orders -->|"owns data"| node_orderdb
node_admin -->|"owns data"| node_admindb
node_customers -->|"owns data"| node_customerdb
node_payments -->|"owns data"| node_paymentdb
node_restaurant -->|"owns data"| node_restaurantdb
node_delivery -->|"owns data"| node_deliverydb

click node_checkout "https://github.com/nathan-alweendo/assignment-2/blob/main/frontend/app.js"
click node_tracking "https://github.com/nathan-alweendo/assignment-2/blob/main/frontend/tracking.js"
click node_adminui "https://github.com/nathan-alweendo/assignment-2/blob/main/frontend/admin.js"
click node_orders "https://github.com/nathan-alweendo/assignment-2/tree/main/order-service"
click node_payments "https://github.com/nathan-alweendo/assignment-2/tree/main/payment-service"
click node_restaurant "https://github.com/nathan-alweendo/assignment-2/tree/main/restaurant-service"
click node_delivery "https://github.com/nathan-alweendo/assignment-2/tree/main/delivery-service"
click node_customers "https://github.com/nathan-alweendo/assignment-2/tree/main/customer-service"
click node_notifications "https://github.com/nathan-alweendo/assignment-2/tree/main/notification-service"
click node_admin "https://github.com/nathan-alweendo/assignment-2/tree/main/admin-service"
click node_orderdb "https://github.com/nathan-alweendo/assignment-2/blob/main/order-service/db.bal"
click node_admindb "https://github.com/nathan-alweendo/assignment-2/blob/main/admin-service/db.bal"
click node_customerdb "https://github.com/nathan-alweendo/assignment-2/blob/main/customer-service/db.bal"
click node_paymentdb "https://github.com/nathan-alweendo/assignment-2/tree/main/payment-service"
click node_restaurantdb "https://github.com/nathan-alweendo/assignment-2/tree/main/restaurant-service"
click node_deliverydb "https://github.com/nathan-alweendo/assignment-2/tree/main/delivery-service"

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_checkout,node_tracking,node_adminui,node_adminuser toneBlue
class node_orders,node_payments,node_restaurant,node_delivery toneAmber
class node_customers,node_notifications,node_kafka toneMint
class node_admin toneRose
class node_orderdb,node_admindb,node_customerdb,node_paymentdb,node_restaurantdb,node_deliverydb,node_customer toneIndigo
```

## Components

### Web experience

- [Checkout UI](https://github.com/nathan-alweendo/assignment-2/blob/main/frontend/app.js): `frontend/app.js`
- [Tracking UI](https://github.com/nathan-alweendo/assignment-2/blob/main/frontend/tracking.js): `frontend/tracking.js`
- [Metrics UI](https://github.com/nathan-alweendo/assignment-2/blob/main/frontend/admin.js): `frontend/admin.js`

### Order fulfillment

- [Order orchestration](https://github.com/nathan-alweendo/assignment-2/tree/main/order-service): `order-service`
- [Payment processing](https://github.com/nathan-alweendo/assignment-2/tree/main/payment-service): `payment-service`
- [Restaurant inventory](https://github.com/nathan-alweendo/assignment-2/tree/main/restaurant-service): `restaurant-service`
- [Delivery dispatch](https://github.com/nathan-alweendo/assignment-2/tree/main/delivery-service): `delivery-service`

### Platform services

- [Customer profiles](https://github.com/nathan-alweendo/assignment-2/tree/main/customer-service): `customer-service`
- [Event notifications](https://github.com/nathan-alweendo/assignment-2/tree/main/notification-service): `notification-service`
- **Kafka event stream**

### Administration

- [Business metrics](https://github.com/nathan-alweendo/assignment-2/tree/main/admin-service): `admin-service`

### Service databases

- [Order database](https://github.com/nathan-alweendo/assignment-2/blob/main/order-service/db.bal): `order-service/db.bal`
- [Admin database](https://github.com/nathan-alweendo/assignment-2/blob/main/admin-service/db.bal): `admin-service/db.bal`
- [Customer database](https://github.com/nathan-alweendo/assignment-2/blob/main/customer-service/db.bal): `customer-service/db.bal`
- [Payment database](https://github.com/nathan-alweendo/assignment-2/tree/main/payment-service): `payment-service`
- [Restaurant database](https://github.com/nathan-alweendo/assignment-2/tree/main/restaurant-service): `restaurant-service`
- [Delivery database](https://github.com/nathan-alweendo/assignment-2/tree/main/delivery-service): `delivery-service`

### Other components

- **Customer**
- **Admin user**

## Connections

- Customer → Checkout UI: places order (evidence: `README.md`)
- Checkout UI → Order orchestration: POSTs order (evidence: `frontend/app.js`)
- Order orchestration → Tracking UI: returns order data
- Tracking UI → Order orchestration: reads cached result (evidence: `frontend/tracking.js`)
- Order orchestration → Payment processing: initiates payment (evidence: `README.md`)
- Order orchestration → Restaurant inventory: routes order (evidence: `README.md`)
- Order orchestration → Delivery dispatch: drives lifecycle (evidence: `README.md`)
- Order orchestration → Kafka event stream: publishes events (evidence: `README.md`)
- Payment processing → Kafka event stream: emits payment events (evidence: `README.md`)
- Restaurant inventory → Kafka event stream: emits ticket events (evidence: `README.md`)
- Delivery dispatch → Kafka event stream: emits tracking updates (evidence: `README.md`)
- Customer profiles → Delivery dispatch: hooks dispatch stream (evidence: `README.md`)
- Kafka event stream → Event notifications: consumes alerts (evidence: `README.md`)
- Kafka event stream → Business metrics: supplies transactional logs (evidence: `README.md`)
- Admin user → Metrics UI: views metrics (evidence: `README.md`)
- Metrics UI → Business metrics: fetches metrics (evidence: `frontend/admin.js`)
- Order orchestration → Order database: owns data (evidence: `README.md`)
- Business metrics → Admin database: owns data (evidence: `README.md`)
- Customer profiles → Customer database: owns data (evidence: `README.md`)
- Payment processing → Payment database: owns data (evidence: `README.md`)
- Restaurant inventory → Restaurant database: owns data (evidence: `README.md`)
- Delivery dispatch → Delivery database: owns data (evidence: `README.md`)
