# rsingh230105/ecommerce-order-service architecture

> Architecture diagram of the GitHub repository rsingh230105/ecommerce-order-service, 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/rsingh230105/ecommerce-order-service
- Repository: https://github.com/rsingh230105/ecommerce-order-service

## Overview

Order Service accepts order CRUD requests, obtains current product pricing during order creation, calculates totals, and stores orders in PostgreSQL. Creation also writes an ORDER_CREATED event to the transactional outbox in the same transaction. A separate publisher claims pending events, sends them to SNS, and records success or retryable failure; SNS fans out to Inventory’s SQS queue. The graph reflects the shown API and publisher code plus README-documented integrations; migration and deployment mechanics are excluded.

Main entry points: [`app/main.py`](https://github.com/rsingh230105/ecommerce-order-service/blob/dev/app/main.py) (Order API), [`app/database.py`](https://github.com/rsingh230105/ecommerce-order-service/blob/dev/app/database.py) (DB Session Setup), [`app/outbox_publisher.py`](https://github.com/rsingh230105/ecommerce-order-service/blob/dev/app/outbox_publisher.py) (Outbox Publisher), [`app/models.py`](https://github.com/rsingh230105/ecommerce-order-service/blob/dev/app/models.py) (Order Models)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_orders["Order API"]
  node_api["Order API<br/>[main.py]"]
  node_schemas["Order Schemas<br/>[schemas.py]"]
  node_product_lookup["Product Lookup<br/>[main.py]"]
end

subgraph group_storage["Persistence"]
  node_db_session["DB Session Setup<br/>[database.py]"]
  node_order_models["Order Models<br/>[models.py]"]
  node_postgres[("PostgreSQL")]
end

subgraph group_events["Event Publishing"]
  node_outbox_publisher["Outbox Publisher"]
  node_sns["SNS Topic"]
end

node_client(("Order Client"))
node_product_service["Product Service"]
node_inventory_queue["Inventory SQS Queue"]

node_client -->|"requests"| node_api
node_api -->|"validates and returns"| node_schemas
node_api -->|"calls"| node_product_lookup
node_product_lookup -->|"gets product price"| node_product_service
node_api -->|"opens session"| node_db_session
node_api -->|"queries and writes"| node_order_models
node_order_models -->|"uses declarative base"| node_db_session
node_db_session -->|"connects"| node_postgres
node_api -->|"commits order and outbox"| node_postgres
node_outbox_publisher -->|"opens sessions"| node_db_session
node_outbox_publisher -->|"claims and updates events"| node_order_models
node_outbox_publisher -->|"publishes events"| node_sns
node_sns -->|"fans out"| node_inventory_queue

click node_api "https://github.com/rsingh230105/ecommerce-order-service/blob/dev/app/main.py"
click node_schemas "https://github.com/rsingh230105/ecommerce-order-service/blob/dev/app/schemas.py"
click node_product_lookup "https://github.com/rsingh230105/ecommerce-order-service/blob/dev/app/main.py"
click node_db_session "https://github.com/rsingh230105/ecommerce-order-service/blob/dev/app/database.py"
click node_order_models "https://github.com/rsingh230105/ecommerce-order-service/blob/dev/app/models.py"
click node_outbox_publisher "https://github.com/rsingh230105/ecommerce-order-service/blob/dev/app/outbox_publisher.py"

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_api,node_schemas,node_product_lookup,node_client toneBlue
class node_db_session,node_order_models,node_postgres toneAmber
class node_outbox_publisher,node_sns toneMint
class node_product_service toneIndigo
class node_inventory_queue toneRose
```

## Components

### Order API

- [Order API](https://github.com/rsingh230105/ecommerce-order-service/blob/dev/app/main.py): `app/main.py`
- [Order Schemas](https://github.com/rsingh230105/ecommerce-order-service/blob/dev/app/schemas.py): `app/schemas.py`
- [Product Lookup](https://github.com/rsingh230105/ecommerce-order-service/blob/dev/app/main.py): `app/main.py`

### Persistence

- [DB Session Setup](https://github.com/rsingh230105/ecommerce-order-service/blob/dev/app/database.py): `app/database.py`
- [Order Models](https://github.com/rsingh230105/ecommerce-order-service/blob/dev/app/models.py): `app/models.py`
- **PostgreSQL**

### Event Publishing

- [Outbox Publisher](https://github.com/rsingh230105/ecommerce-order-service/blob/dev/app/outbox_publisher.py): `app/outbox_publisher.py`
- **SNS Topic**

### Other components

- **Order Client**
- **Product Service**
- **Inventory SQS Queue**

## Connections

- Order Client → Order API: requests (evidence: `README.md`)
- Order API → Order Schemas: validates and returns (evidence: `app/main.py`)
- Order API → Product Lookup: calls (evidence: `app/main.py`)
- Product Lookup → Product Service: gets product price (evidence: `app/main.py`)
- Order API → DB Session Setup: opens session (evidence: `app/main.py`)
- Order API → Order Models: queries and writes (evidence: `app/main.py`)
- Order Models → DB Session Setup: uses declarative base (evidence: `app/models.py`)
- DB Session Setup → PostgreSQL: connects (evidence: `README.md`)
- Order API → PostgreSQL: commits order and outbox (evidence: `app/main.py`)
- Outbox Publisher → DB Session Setup: opens sessions (evidence: `app/outbox_publisher.py`)
- Outbox Publisher → Order Models: claims and updates events (evidence: `app/outbox_publisher.py`)
- Outbox Publisher → SNS Topic: publishes events (evidence: `README.md`)
- SNS Topic → Inventory SQS Queue: fans out (evidence: `README.md`)
