# openfoodfoundation/openfoodnetwork architecture

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

- Interactive diagram: https://gitdiagram.com/openfoodfoundation/openfoodnetwork
- Repository: https://github.com/openfoodfoundation/openfoodnetwork

## Overview

Open Food Network is a multi-store marketplace connecting local food producers and hubs with buyers. The principal customer journey is discovering a shop and its products, adding items to a cart, and checking out through a payment option. The repository also has distinct enterprise administration, APIs, reporting, and connected-app/webhook capabilities. The tree and sampled routes support the customer and payment entry points; unsampled subsystems are included where their paths identify meaningful product areas, without asserting unverified call relationships.

Main entry points: [`app/controllers/admin/enterprises_controller.rb`](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/controllers/admin/enterprises_controller.rb) (Enterprise admin), [`app/controllers/shop_controller.rb`](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/controllers/shop_controller.rb) (Shopfront), [`app/models/connected_app.rb`](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/models/connected_app.rb) (Connected apps), [`app/controllers/products_controller.rb`](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/controllers/products_controller.rb) (Product catalog)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_commerce["Customer commerce"]
  node_shopfront["Shopfront<br/>[shop_controller.rb]"]
  node_catalog["Product catalog"]
  node_cart["Cart endpoint"]
  node_cart_service["Cart operations<br/>[cart_service.rb]"]
  node_checkout["Checkout"]
  node_order["Order lifecycle<br/>[order.rb]"]
end

subgraph group_operations["Marketplace operations"]
  node_order_cycles["Order cycles<br/>[order_cycle.rb]"]
  node_enterprise_admin["Enterprise admin"]
  node_inventory["Inventory<br/>[inventory_item.rb]"]
  node_reports["Reporting"]
end

subgraph group_interfaces["Platform interfaces"]
  node_api["Public API<br/>[base_controller.rb]"]
end

subgraph group_integrations["Payments and integrations"]
  node_payments["Payment gateways"]
  node_webhooks["Webhook delivery"]
  node_connected_apps["Connected apps<br/>[connected_app.rb]"]
end

node_buyer(("Buyer"))

node_buyer -.->|"browses shops"| node_shopfront
node_shopfront -.->|"opens products"| node_catalog
node_buyer -->|"opens cart"| node_cart
node_buyer -->|"starts checkout"| node_checkout
node_buyer -->|"returns to payment"| node_payments
node_buyer -->|"views token order"| node_order
node_enterprise_admin -.->|"manages cycles"| node_order_cycles
node_enterprise_admin -.->|"manages stock"| node_inventory
node_connected_apps -.->|"delivers events"| node_webhooks

click node_shopfront "https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/controllers/shop_controller.rb"
click node_catalog "https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/controllers/products_controller.rb"
click node_cart "https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/controllers/spree/orders_controller.rb"
click node_cart_service "https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/services/cart_service.rb"
click node_checkout "https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/controllers/checkout_controller.rb"
click node_order "https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/models/spree/order.rb"
click node_order_cycles "https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/models/order_cycle.rb"
click node_enterprise_admin "https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/controllers/admin/enterprises_controller.rb"
click node_inventory "https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/models/inventory_item.rb"
click node_reports "https://github.com/openfoodfoundation/openfoodnetwork/blob/master/lib/reporting/report_query_template.rb"
click node_api "https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/controllers/api/v0/base_controller.rb"
click node_payments "https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/controllers/payment_gateways/stripe_controller.rb"
click node_webhooks "https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/jobs/webhook_delivery_job.rb"
click node_connected_apps "https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/models/connected_app.rb"

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_shopfront,node_catalog,node_cart,node_cart_service,node_checkout,node_order toneBlue
class node_order_cycles,node_enterprise_admin,node_inventory,node_reports toneAmber
class node_api toneMint
class node_payments,node_webhooks,node_connected_apps toneRose
class node_buyer toneIndigo
```

## Components

### Customer commerce

- [Shopfront](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/controllers/shop_controller.rb): `app/controllers/shop_controller.rb`
- [Product catalog](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/controllers/products_controller.rb): `app/controllers/products_controller.rb`
- [Cart endpoint](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/controllers/spree/orders_controller.rb): `app/controllers/spree/orders_controller.rb`
- [Cart operations](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/services/cart_service.rb): `app/services/cart_service.rb`
- [Checkout](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/controllers/checkout_controller.rb): `app/controllers/checkout_controller.rb`
- [Order lifecycle](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/models/spree/order.rb): `app/models/spree/order.rb`

### Marketplace operations

- [Order cycles](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/models/order_cycle.rb): `app/models/order_cycle.rb`
- [Enterprise admin](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/controllers/admin/enterprises_controller.rb): `app/controllers/admin/enterprises_controller.rb`
- [Inventory](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/models/inventory_item.rb): `app/models/inventory_item.rb`
- [Reporting](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/lib/reporting/report_query_template.rb): `lib/reporting/report_query_template.rb`

### Platform interfaces

- [Public API](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/controllers/api/v0/base_controller.rb): `app/controllers/api/v0/base_controller.rb`

### Payments and integrations

- [Payment gateways](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/controllers/payment_gateways/stripe_controller.rb): `app/controllers/payment_gateways/stripe_controller.rb`
- [Webhook delivery](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/jobs/webhook_delivery_job.rb): `app/jobs/webhook_delivery_job.rb`
- [Connected apps](https://github.com/openfoodfoundation/openfoodnetwork/blob/master/app/models/connected_app.rb): `app/models/connected_app.rb`

### Other components

- **Buyer**

## Connections

- Buyer → Shopfront: browses shops
- Shopfront → Product catalog: opens products
- Buyer → Cart endpoint: opens cart
- Buyer → Checkout: starts checkout
- Buyer → Payment gateways: returns to payment
- Buyer → Order lifecycle: views token order
- Enterprise admin → Order cycles: manages cycles
- Enterprise admin → Inventory: manages stock
- Connected apps → Webhook delivery: delivers events
