# ondc-official/biap-client-node-js architecture

> Architecture diagram of the GitHub repository ondc-official/biap-client-node-js, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-05). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ondc-official/biap-client-node-js
- Repository: https://github.com/ondc-official/biap-client-node-js

## Overview

This is an Express REST API between a browser-based React application and the ONDC protocol layer. The principal journey is discovery/search, followed by order selection and lifecycle actions, with protocol callbacks delivered to the browser through SSE. The repository also exposes accounts, fulfillment tracking, support, ratings, uploads, and payment integrations. The graph emphasizes documented routes and sampled calls; unsampled feature implementations are represented at their exact tree paths, and their internal links are omitted where evidence is unavailable.

Main entry points: [`src/utils/protocolApis/index.js`](https://github.com/ondc-official/biap-client-node-js/blob/master/src/utils/protocolApis/index.js) (Protocol service), [`src/discovery/v2/search.service.js`](https://github.com/ondc-official/biap-client-node-js/blob/master/src/discovery/v2/search.service.js) (Catalog search), [`src/order/v2/order.routes.js`](https://github.com/ondc-official/biap-client-node-js/blob/master/src/order/v2/order.routes.js) (Order routes v2), [`src/sse/v2/sse.controller.js`](https://github.com/ondc-official/biap-client-node-js/blob/master/src/sse/v2/sse.controller.js) (SSE callbacks)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["API entry and access"]
  node_app["Express application<br/>[app.js]"]
  node_router["API router<br/>[router.js]"]
  node_middleware["Access middleware<br/>[index.js]"]
end

subgraph group_discovery["Discovery"]
  node_discovery_routes["Discovery routes<br/>[search.routes.js]"]
  node_search_controller["Search controller"]
  node_search_service["Catalog search<br/>[search.service.js]"]
  node_bpp_search["BPP search"]
  node_context["Protocol context<br/>[ContextFactory.js]"]
  node_protocol_api["Protocol API client<br/>[index.js]"]
end

subgraph group_commerce["Orders and fulfillment"]
  node_protocol_service["Protocol service<br/>[index.js]"]
  node_order_routes["Order routes v2<br/>[order.routes.js]"]
  node_order_select["Order selection"]
  node_order_init["Order initialization"]
  node_order_confirm["Order confirmation"]
  node_order_lifecycle["Order lifecycle"]
  node_order_upload["Order uploads"]
  node_track["Fulfillment tracking"]
  node_support["Support cases"]
  node_rating["Order ratings"]
end

subgraph group_realtime["Protocol callbacks"]
  node_sse_controller["SSE callbacks<br/>[sse.controller.js]"]
  node_sse_protocol["SSE protocol handler"]
  node_sse_connection["SSE connections<br/>[sse.js]"]
end

subgraph group_accounts_payments["Accounts and payments"]
  node_accounts["Account endpoints<br/>[accounts.routes.js]"]
  node_billing["Billing details<br/>[billing.service.js]"]
  node_delivery["Delivery addresses"]
  node_juspay["Juspay payments"]
  node_razorpay["Razorpay payments"]
end

node_browser(("React browser"))
node_protocol{{"ONDC protocol service"}}
node_elasticsearch[("Elasticsearch catalog")]
node_payment_provider{{"Payment providers"}}

node_browser -->|"sends requests"| node_app
node_app -->|"mounts routes"| node_router
node_router -.->|"applies access"| node_middleware
node_router -.->|"routes search"| node_discovery_routes
node_discovery_routes -->|"routes requests"| node_search_controller
node_search_controller -->|"calls search"| node_search_service
node_search_service -.->|"delegates search"| node_bpp_search
node_search_service -.->|"builds context"| node_context
node_search_service -.->|"requests protocol data"| node_protocol_api
node_search_service -->|"queries catalog"| node_elasticsearch
node_search_service -.->|"returns results"| node_browser
node_order_routes -->|"routes selection"| node_order_select
node_order_routes -.->|"routes initialization"| node_order_init
node_order_routes -.->|"routes confirmation"| node_order_confirm
node_order_routes -->|"routes actions"| node_order_lifecycle
node_order_routes -->|"routes uploads"| node_order_upload
node_order_select -.->|"requests selection"| node_protocol_service
node_order_init -.->|"requests initialization"| node_protocol_service
node_order_confirm -.->|"requests confirmation"| node_protocol_service
node_protocol_api -->|"sends protocol calls"| node_protocol
node_protocol_service -->|"sends protocol calls"| node_protocol
node_browser -.->|"manages orders"| node_order_routes
node_track -.->|"requests tracking"| node_protocol_service
node_support -.->|"requests support"| node_protocol_service
node_rating -.->|"requests rating"| node_protocol_service
node_sse_controller -->|"handles callbacks"| node_sse_protocol
node_sse_controller -->|"opens stream"| node_sse_connection
node_protocol -.->|"posts callbacks"| node_sse_controller
node_sse_controller -->|"streams events"| node_browser
node_accounts -.->|"routes billing"| node_billing
node_accounts -.->|"routes addresses"| node_delivery
node_browser -.->|"manages account"| node_accounts
node_browser -.->|"initiates payment"| node_juspay
node_browser -.->|"initiates payment"| node_razorpay
node_juspay -.->|"integrates Juspay"| node_payment_provider
node_razorpay -.->|"integrates provider"| node_payment_provider

click node_app "https://github.com/ondc-official/biap-client-node-js/blob/master/src/app.js"
click node_router "https://github.com/ondc-official/biap-client-node-js/blob/master/src/utils/router.js"
click node_middleware "https://github.com/ondc-official/biap-client-node-js/blob/master/src/middlewares/index.js"
click node_discovery_routes "https://github.com/ondc-official/biap-client-node-js/blob/master/src/discovery/v2/search.routes.js"
click node_search_controller "https://github.com/ondc-official/biap-client-node-js/blob/master/src/discovery/v2/search.controller.js"
click node_search_service "https://github.com/ondc-official/biap-client-node-js/blob/master/src/discovery/v2/search.service.js"
click node_bpp_search "https://github.com/ondc-official/biap-client-node-js/blob/master/src/discovery/v2/bppSearch.service.js"
click node_context "https://github.com/ondc-official/biap-client-node-js/blob/master/src/factories/ContextFactory.js"
click node_protocol_api "https://github.com/ondc-official/biap-client-node-js/blob/master/src/utils/protocolApis/index.js"
click node_protocol_service "https://github.com/ondc-official/biap-client-node-js/blob/master/src/utils/protocolApis/index.js"
click node_order_routes "https://github.com/ondc-official/biap-client-node-js/blob/master/src/order/v2/order.routes.js"
click node_order_select "https://github.com/ondc-official/biap-client-node-js/blob/master/src/order/v2/select/selectOrder.controller.js"
click node_order_init "https://github.com/ondc-official/biap-client-node-js/blob/master/src/order/v2/init/initOrder.service.js"
click node_order_confirm "https://github.com/ondc-official/biap-client-node-js/blob/master/src/order/v2/confirm/confirmOrder.service.js"
click node_order_lifecycle "https://github.com/ondc-official/biap-client-node-js/tree/master/src/order/v2"
click node_order_upload "https://github.com/ondc-official/biap-client-node-js/blob/master/src/order/upload/upload.controller.js"
click node_track "https://github.com/ondc-official/biap-client-node-js/blob/master/src/fulfillment/v2/track.controller.js"
click node_support "https://github.com/ondc-official/biap-client-node-js/blob/master/src/support/v2/support.controller.js"
click node_rating "https://github.com/ondc-official/biap-client-node-js/blob/master/src/order/v2/rating/ratingcontroller.js"
click node_sse_controller "https://github.com/ondc-official/biap-client-node-js/blob/master/src/sse/v2/sse.controller.js"
click node_sse_protocol "https://github.com/ondc-official/biap-client-node-js/blob/master/src/sse/v2/sseProtocol.service.js"
click node_sse_connection "https://github.com/ondc-official/biap-client-node-js/blob/master/src/utils/sse.js"
click node_accounts "https://github.com/ondc-official/biap-client-node-js/blob/master/src/accounts/accounts.routes.js"
click node_billing "https://github.com/ondc-official/biap-client-node-js/blob/master/src/accounts/billings/billing.service.js"
click node_delivery "https://github.com/ondc-official/biap-client-node-js/blob/master/src/accounts/deliveryAddress/deliveryAddress.service.js"
click node_juspay "https://github.com/ondc-official/biap-client-node-js/blob/master/src/payment/payment.controller.js"
click node_razorpay "https://github.com/ondc-official/biap-client-node-js/blob/master/src/razorPay/razorPay.controller.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_app,node_router,node_middleware,node_browser toneBlue
class node_discovery_routes,node_search_controller,node_search_service,node_bpp_search,node_context,node_protocol_api,node_elasticsearch toneAmber
class node_protocol_service,node_order_routes,node_order_select,node_order_init,node_order_confirm,node_order_lifecycle,node_order_upload,node_track,node_support,node_rating toneMint
class node_sse_controller,node_sse_protocol,node_sse_connection toneRose
class node_accounts,node_billing,node_delivery,node_juspay,node_razorpay,node_protocol,node_payment_provider toneIndigo
```

## Components

### API entry and access

- [Express application](https://github.com/ondc-official/biap-client-node-js/blob/master/src/app.js): `src/app.js`
- [API router](https://github.com/ondc-official/biap-client-node-js/blob/master/src/utils/router.js): `src/utils/router.js`
- [Access middleware](https://github.com/ondc-official/biap-client-node-js/blob/master/src/middlewares/index.js): `src/middlewares/index.js`

### Discovery

- [Discovery routes](https://github.com/ondc-official/biap-client-node-js/blob/master/src/discovery/v2/search.routes.js): `src/discovery/v2/search.routes.js`
- [Search controller](https://github.com/ondc-official/biap-client-node-js/blob/master/src/discovery/v2/search.controller.js): `src/discovery/v2/search.controller.js`
- [Catalog search](https://github.com/ondc-official/biap-client-node-js/blob/master/src/discovery/v2/search.service.js): `src/discovery/v2/search.service.js`
- [BPP search](https://github.com/ondc-official/biap-client-node-js/blob/master/src/discovery/v2/bppSearch.service.js): `src/discovery/v2/bppSearch.service.js`
- [Protocol context](https://github.com/ondc-official/biap-client-node-js/blob/master/src/factories/ContextFactory.js): `src/factories/ContextFactory.js`
- [Protocol API client](https://github.com/ondc-official/biap-client-node-js/blob/master/src/utils/protocolApis/index.js): `src/utils/protocolApis/index.js`

### Orders and fulfillment

- [Protocol service](https://github.com/ondc-official/biap-client-node-js/blob/master/src/utils/protocolApis/index.js): `src/utils/protocolApis/index.js`
- [Order routes v2](https://github.com/ondc-official/biap-client-node-js/blob/master/src/order/v2/order.routes.js): `src/order/v2/order.routes.js`
- [Order selection](https://github.com/ondc-official/biap-client-node-js/blob/master/src/order/v2/select/selectOrder.controller.js): `src/order/v2/select/selectOrder.controller.js`
- [Order initialization](https://github.com/ondc-official/biap-client-node-js/blob/master/src/order/v2/init/initOrder.service.js): `src/order/v2/init/initOrder.service.js`
- [Order confirmation](https://github.com/ondc-official/biap-client-node-js/blob/master/src/order/v2/confirm/confirmOrder.service.js): `src/order/v2/confirm/confirmOrder.service.js`
- [Order lifecycle](https://github.com/ondc-official/biap-client-node-js/tree/master/src/order/v2): `src/order/v2`
- [Order uploads](https://github.com/ondc-official/biap-client-node-js/blob/master/src/order/upload/upload.controller.js): `src/order/upload/upload.controller.js`
- [Fulfillment tracking](https://github.com/ondc-official/biap-client-node-js/blob/master/src/fulfillment/v2/track.controller.js): `src/fulfillment/v2/track.controller.js`
- [Support cases](https://github.com/ondc-official/biap-client-node-js/blob/master/src/support/v2/support.controller.js): `src/support/v2/support.controller.js`
- [Order ratings](https://github.com/ondc-official/biap-client-node-js/blob/master/src/order/v2/rating/ratingcontroller.js): `src/order/v2/rating/ratingcontroller.js`

### Protocol callbacks

- [SSE callbacks](https://github.com/ondc-official/biap-client-node-js/blob/master/src/sse/v2/sse.controller.js): `src/sse/v2/sse.controller.js`
- [SSE protocol handler](https://github.com/ondc-official/biap-client-node-js/blob/master/src/sse/v2/sseProtocol.service.js): `src/sse/v2/sseProtocol.service.js`
- [SSE connections](https://github.com/ondc-official/biap-client-node-js/blob/master/src/utils/sse.js): `src/utils/sse.js`

### Accounts and payments

- [Account endpoints](https://github.com/ondc-official/biap-client-node-js/blob/master/src/accounts/accounts.routes.js): `src/accounts/accounts.routes.js`
- [Billing details](https://github.com/ondc-official/biap-client-node-js/blob/master/src/accounts/billings/billing.service.js): `src/accounts/billings/billing.service.js`
- [Delivery addresses](https://github.com/ondc-official/biap-client-node-js/blob/master/src/accounts/deliveryAddress/deliveryAddress.service.js): `src/accounts/deliveryAddress/deliveryAddress.service.js`
- [Juspay payments](https://github.com/ondc-official/biap-client-node-js/blob/master/src/payment/payment.controller.js): `src/payment/payment.controller.js`
- [Razorpay payments](https://github.com/ondc-official/biap-client-node-js/blob/master/src/razorPay/razorPay.controller.js): `src/razorPay/razorPay.controller.js`

### Other components

- **React browser**
- **ONDC protocol service**
- **Elasticsearch catalog**
- **Payment providers**

## Connections

- React browser → Express application: sends requests
- Express application → API router: mounts routes (evidence: `src/app.js`)
- API router → Access middleware: applies access
- API router → Discovery routes: routes search
- Discovery routes → Search controller: routes requests
- Search controller → Catalog search: calls search (evidence: `src/discovery/v2/search.controller.js`)
- Catalog search → BPP search: delegates search (evidence: `src/discovery/v2/search.service.js`)
- Catalog search → Protocol context: builds context (evidence: `src/discovery/v2/search.service.js`)
- Catalog search → Protocol API client: requests protocol data (evidence: `src/discovery/v2/search.service.js`)
- Catalog search → Elasticsearch catalog: queries catalog (evidence: `src/discovery/v2/search.service.js`)
- Catalog search → React browser: returns results
- Order routes v2 → Order selection: routes selection (evidence: `src/order/v2/order.routes.js`)
- Order routes v2 → Order initialization: routes initialization (evidence: `src/order/v2/order.routes.js`)
- Order routes v2 → Order confirmation: routes confirmation (evidence: `src/order/v2/order.routes.js`)
- Order routes v2 → Order lifecycle: routes actions (evidence: `src/order/v2/order.routes.js`)
- Order routes v2 → Order uploads: routes uploads (evidence: `src/order/v2/order.routes.js`)
- Order selection → Protocol service: requests selection
- Order initialization → Protocol service: requests initialization
- Order confirmation → Protocol service: requests confirmation
- Protocol API client → ONDC protocol service: sends protocol calls (evidence: `src/utils/protocolApis/index.js`)
- Protocol service → ONDC protocol service: sends protocol calls (evidence: `src/utils/protocolApis/index.js`)
- React browser → Order routes v2: manages orders
- Fulfillment tracking → Protocol service: requests tracking
- Support cases → Protocol service: requests support
- Order ratings → Protocol service: requests rating
- SSE callbacks → SSE protocol handler: handles callbacks (evidence: `src/sse/v2/sse.controller.js`)
- SSE callbacks → SSE connections: opens stream (evidence: `src/sse/v2/sse.controller.js`)
- ONDC protocol service → SSE callbacks: posts callbacks
- SSE callbacks → React browser: streams events
- Account endpoints → Billing details: routes billing (evidence: `src/accounts/accounts.routes.js`)
- Account endpoints → Delivery addresses: routes addresses (evidence: `src/accounts/accounts.routes.js`)
- React browser → Account endpoints: manages account
- React browser → Juspay payments: initiates payment
- React browser → Razorpay payments: initiates payment
- Juspay payments → Payment providers: integrates Juspay
- Razorpay payments → Payment providers: integrates provider
