# openagrinet/network-adapter architecture

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

- Interactive diagram: https://gitdiagram.com/openagrinet/network-adapter
- Repository: https://github.com/openagrinet/network-adapter

## Overview

Beckn-ONIX is a plugin-based Beckn protocol middleware adapter between buyer and provider platforms. Its main workflow receives HTTP transactions, runs configured processing steps and plugins for validation, routing, security and transformation, then forwards requests or returns responses. Separate catalog publishing and crawling endpoints support catalog distribution and registry synchronization. The README documents several plugin capabilities whose implementations were not sampled; those branches are represented at the documented subsystem level, and their edges cite the README rather than implying source inspection.

Main entry points: [`core/module/handler/step.go`](https://github.com/openagrinet/network-adapter/blob/main/core/module/handler/step.go) (Processing steps), [`cmd/adapter/main.go`](https://github.com/openagrinet/network-adapter/blob/main/cmd/adapter/main.go) (Adapter startup), [`core/module/handler/stdHandler.go`](https://github.com/openagrinet/network-adapter/blob/main/core/module/handler/stdHandler.go) (HTTP handler), [`core/module/module.go`](https://github.com/openagrinet/network-adapter/blob/main/core/module/module.go) (Transaction modules)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Adapter runtime"]
  node_adapter["Adapter startup<br/>[main.go]"]
  node_modules["Transaction modules<br/>[module.go]"]
end

subgraph group_pipeline["Transaction pipeline"]
  node_http_handler["HTTP handler<br/>[stdHandler.go]"]
  node_steps["Processing steps<br/>[step.go]"]
  node_response_steps["Response steps<br/>[responsestep.go]"]
end

subgraph group_plugins["Protocol plugins"]
  node_plugin_manager["Plugin manager<br/>[manager.go]"]
  node_router["Request router<br/>[router.go]"]
  node_validation["Schema validation"]
  node_signatures["Sign and verify"]
  node_key_manager["Key management<br/>[keymanager.go]"]
  node_request_tools["Request processing"]
  node_cache["Response cache<br/>[cache.go]"]
  node_publisher["Async publisher<br/>[publisher.go]"]
  node_registry["Participant registry<br/>[sunbirdRegistry.go]"]
  node_policy["Policy enforcement<br/>[enforcer.go]"]
  node_manifest["Network manifest<br/>[manifestloader.go]"]
end

subgraph group_catalog["Catalog services"]
  node_catalog_publisher["Catalog publishing<br/>[handler.go]"]
  node_catalog_crawler["Catalog crawling<br/>[handler.go]"]
  node_catalog_store[("Catalog storage")]
end

subgraph group_operations["Security and observability"]
  node_telemetry["Telemetry and audit<br/>[otelsetup.go]"]
  node_logs["Structured logging<br/>[log.go]"]
end

node_platforms(("BAP / BPP"))
node_vault[("HashiCorp Vault")]
node_redis[("Redis")]
node_rabbitmq["RabbitMQ"]
node_protocol_services(("External services"))

node_platforms -->|"send HTTP"| node_adapter
node_adapter -->|"loads plugins"| node_plugin_manager
node_adapter -->|"registers modules"| node_modules
node_modules -->|"routes requests"| node_http_handler
node_http_handler -->|"runs steps"| node_steps
node_http_handler -->|"runs responses"| node_response_steps
node_http_handler -->|"forwards requests"| node_protocol_services
node_steps -->|"validates schema"| node_validation
node_steps -->|"determines route"| node_router
node_steps -->|"validates signatures"| node_signatures
node_steps -->|"preprocesses requests"| node_request_tools
node_steps -->|"caches responses"| node_cache
node_steps -->|"publishes messages"| node_publisher
node_plugin_manager -->|"constructs plugins"| node_key_manager
node_key_manager -->|"stores keysets"| node_vault
node_steps -->|"checks policy"| node_policy
node_policy -.->|"loads policy manifest"| node_manifest
node_steps -->|"looks up participants"| node_registry
node_cache -->|"uses cache store"| node_redis
node_publisher -->|"publishes messages"| node_rabbitmq
node_modules -->|"registers endpoint"| node_catalog_publisher
node_adapter -->|"registers crawler"| node_catalog_crawler
node_catalog_publisher -.->|"stores catalogs"| node_catalog_store
node_catalog_publisher -->|"uses registry"| node_registry
node_catalog_crawler -.->|"crawls registry"| node_registry
node_http_handler -->|"instruments requests"| node_telemetry
node_adapter -->|"logs startup"| node_logs

click node_adapter "https://github.com/openagrinet/network-adapter/blob/main/cmd/adapter/main.go"
click node_modules "https://github.com/openagrinet/network-adapter/blob/main/core/module/module.go"
click node_http_handler "https://github.com/openagrinet/network-adapter/blob/main/core/module/handler/stdHandler.go"
click node_steps "https://github.com/openagrinet/network-adapter/blob/main/core/module/handler/step.go"
click node_response_steps "https://github.com/openagrinet/network-adapter/blob/main/core/module/handler/responsestep.go"
click node_plugin_manager "https://github.com/openagrinet/network-adapter/blob/main/pkg/plugin/manager.go"
click node_router "https://github.com/openagrinet/network-adapter/blob/main/pkg/plugin/implementation/router/router.go"
click node_validation "https://github.com/openagrinet/network-adapter/tree/main/pkg/plugin/implementation/schemavalidator"
click node_signatures "https://github.com/openagrinet/network-adapter/tree/main/pkg/plugin/implementation/signvalidator"
click node_key_manager "https://github.com/openagrinet/network-adapter/blob/main/pkg/plugin/implementation/keymanager/keymanager.go"
click node_request_tools "https://github.com/openagrinet/network-adapter/tree/main/pkg/plugin/implementation/reqpreprocessor"
click node_cache "https://github.com/openagrinet/network-adapter/blob/main/pkg/plugin/implementation/cache/cache.go"
click node_publisher "https://github.com/openagrinet/network-adapter/blob/main/pkg/plugin/implementation/publisher/publisher.go"
click node_catalog_publisher "https://github.com/openagrinet/network-adapter/blob/main/pkg/plugin/implementation/catalogpublisher/handler.go"
click node_catalog_crawler "https://github.com/openagrinet/network-adapter/blob/main/pkg/plugin/implementation/catalogcrawler/handler.go"
click node_catalog_store "https://github.com/openagrinet/network-adapter/blob/main/pkg/plugin/implementation/localcatalogblobstore/localcatalogblobstore.go"
click node_registry "https://github.com/openagrinet/network-adapter/blob/main/pkg/plugin/implementation/sunbirdRegistry/sunbirdRegistry.go"
click node_policy "https://github.com/openagrinet/network-adapter/blob/main/pkg/plugin/implementation/opapolicychecker/enforcer.go"
click node_manifest "https://github.com/openagrinet/network-adapter/blob/main/pkg/plugin/implementation/manifestloader/manifestloader.go"
click node_telemetry "https://github.com/openagrinet/network-adapter/blob/main/pkg/plugin/implementation/otelsetup/otelsetup.go"
click node_logs "https://github.com/openagrinet/network-adapter/blob/main/pkg/log/log.go"

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_adapter,node_modules toneBlue
class node_http_handler,node_steps,node_response_steps,node_vault,node_redis toneAmber
class node_plugin_manager,node_router,node_validation,node_signatures,node_key_manager,node_request_tools,node_cache,node_publisher,node_registry,node_policy,node_manifest toneMint
class node_catalog_publisher,node_catalog_crawler,node_catalog_store toneRose
class node_telemetry,node_logs,node_platforms,node_rabbitmq,node_protocol_services toneIndigo
```

## Components

### Adapter runtime

- [Adapter startup](https://github.com/openagrinet/network-adapter/blob/main/cmd/adapter/main.go): `cmd/adapter/main.go`
- [Transaction modules](https://github.com/openagrinet/network-adapter/blob/main/core/module/module.go): `core/module/module.go`

### Transaction pipeline

- [HTTP handler](https://github.com/openagrinet/network-adapter/blob/main/core/module/handler/stdHandler.go): `core/module/handler/stdHandler.go`
- [Processing steps](https://github.com/openagrinet/network-adapter/blob/main/core/module/handler/step.go): `core/module/handler/step.go`
- [Response steps](https://github.com/openagrinet/network-adapter/blob/main/core/module/handler/responsestep.go): `core/module/handler/responsestep.go`

### Protocol plugins

- [Plugin manager](https://github.com/openagrinet/network-adapter/blob/main/pkg/plugin/manager.go): `pkg/plugin/manager.go`
- [Request router](https://github.com/openagrinet/network-adapter/blob/main/pkg/plugin/implementation/router/router.go): `pkg/plugin/implementation/router/router.go`
- [Schema validation](https://github.com/openagrinet/network-adapter/tree/main/pkg/plugin/implementation/schemavalidator): `pkg/plugin/implementation/schemavalidator`
- [Sign and verify](https://github.com/openagrinet/network-adapter/tree/main/pkg/plugin/implementation/signvalidator): `pkg/plugin/implementation/signvalidator`
- [Key management](https://github.com/openagrinet/network-adapter/blob/main/pkg/plugin/implementation/keymanager/keymanager.go): `pkg/plugin/implementation/keymanager/keymanager.go`
- [Request processing](https://github.com/openagrinet/network-adapter/tree/main/pkg/plugin/implementation/reqpreprocessor): `pkg/plugin/implementation/reqpreprocessor`
- [Response cache](https://github.com/openagrinet/network-adapter/blob/main/pkg/plugin/implementation/cache/cache.go): `pkg/plugin/implementation/cache/cache.go`
- [Async publisher](https://github.com/openagrinet/network-adapter/blob/main/pkg/plugin/implementation/publisher/publisher.go): `pkg/plugin/implementation/publisher/publisher.go`
- [Participant registry](https://github.com/openagrinet/network-adapter/blob/main/pkg/plugin/implementation/sunbirdRegistry/sunbirdRegistry.go): `pkg/plugin/implementation/sunbirdRegistry/sunbirdRegistry.go`
- [Policy enforcement](https://github.com/openagrinet/network-adapter/blob/main/pkg/plugin/implementation/opapolicychecker/enforcer.go): `pkg/plugin/implementation/opapolicychecker/enforcer.go`
- [Network manifest](https://github.com/openagrinet/network-adapter/blob/main/pkg/plugin/implementation/manifestloader/manifestloader.go): `pkg/plugin/implementation/manifestloader/manifestloader.go`

### Catalog services

- [Catalog publishing](https://github.com/openagrinet/network-adapter/blob/main/pkg/plugin/implementation/catalogpublisher/handler.go): `pkg/plugin/implementation/catalogpublisher/handler.go`
- [Catalog crawling](https://github.com/openagrinet/network-adapter/blob/main/pkg/plugin/implementation/catalogcrawler/handler.go): `pkg/plugin/implementation/catalogcrawler/handler.go`
- [Catalog storage](https://github.com/openagrinet/network-adapter/blob/main/pkg/plugin/implementation/localcatalogblobstore/localcatalogblobstore.go): `pkg/plugin/implementation/localcatalogblobstore/localcatalogblobstore.go`

### Security and observability

- [Telemetry and audit](https://github.com/openagrinet/network-adapter/blob/main/pkg/plugin/implementation/otelsetup/otelsetup.go): `pkg/plugin/implementation/otelsetup/otelsetup.go`
- [Structured logging](https://github.com/openagrinet/network-adapter/blob/main/pkg/log/log.go): `pkg/log/log.go`

### Other components

- **BAP / BPP**
- **HashiCorp Vault**
- **Redis**
- **RabbitMQ**
- **External services**

## Connections

- BAP / BPP → Adapter startup: send HTTP
- Adapter startup → Plugin manager: loads plugins (evidence: `cmd/adapter/main.go`)
- Adapter startup → Transaction modules: registers modules (evidence: `cmd/adapter/main.go`)
- Transaction modules → HTTP handler: routes requests
- HTTP handler → Processing steps: runs steps
- HTTP handler → Response steps: runs responses (evidence: `core/module/handler/stdHandler.go`)
- HTTP handler → External services: forwards requests (evidence: `core/module/handler/stdHandler.go`)
- Processing steps → Schema validation: validates schema
- Processing steps → Request router: determines route
- Processing steps → Sign and verify: validates signatures
- Processing steps → Request processing: preprocesses requests
- Processing steps → Response cache: caches responses
- Processing steps → Async publisher: publishes messages
- Plugin manager → Key management: constructs plugins (evidence: `pkg/plugin/manager.go`)
- Key management → HashiCorp Vault: stores keysets (evidence: `pkg/plugin/implementation/keymanager/keymanager.go`)
- Processing steps → Policy enforcement: checks policy
- Policy enforcement → Network manifest: loads policy manifest
- Processing steps → Participant registry: looks up participants
- Response cache → Redis: uses cache store
- Async publisher → RabbitMQ: publishes messages
- Transaction modules → Catalog publishing: registers endpoint (evidence: `pkg/plugin/implementation/catalogpublisher/handler.go`)
- Adapter startup → Catalog crawling: registers crawler (evidence: `cmd/adapter/main.go`)
- Catalog publishing → Catalog storage: stores catalogs (evidence: `pkg/plugin/implementation/catalogpublisher/handler.go`)
- Catalog publishing → Participant registry: uses registry (evidence: `pkg/plugin/implementation/catalogpublisher/handler.go`)
- Catalog crawling → Participant registry: crawls registry
- HTTP handler → Telemetry and audit: instruments requests (evidence: `core/module/handler/stdHandler.go`)
- Adapter startup → Structured logging: logs startup (evidence: `cmd/adapter/main.go`)
