# medusajs/b2b-starter-medusa architecture

> Architecture diagram of the GitHub repository medusajs/b2b-starter-medusa, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/medusajs/b2b-starter-medusa
- Repository: https://github.com/medusajs/b2b-starter-medusa

## Overview

This is a Medusa B2B commerce starter: shoppers and company employees browse and purchase, while company admins and merchants manage organizations, approvals, and quotes. The graph follows the storefront-to-backend API shape and includes the backend workflow and domain layers. README capabilities are retained where the tree supports them; storefront request wiring and several feature implementations were not sampled, so those connections are shown at subsystem level rather than as detailed call chains.

Main entry points: [`backend/src/api/store`](https://github.com/medusajs/b2b-starter-medusa/tree/main/backend/src/api/store) (Store API), [`backend/src/api/admin`](https://github.com/medusajs/b2b-starter-medusa/tree/main/backend/src/api/admin) (Admin API), [`storefront/src/modules`](https://github.com/medusajs/b2b-starter-medusa/tree/main/storefront/src/modules) (Storefront Features), [`storefront/src/app/[countryCode]/(checkout)`](https://github.com/medusajs/b2b-starter-medusa/tree/main/storefront/src/app/%5BcountryCode%5D/(checkout)) (Cart & Checkout)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_storefront["Storefront"]
  node_store_pages["Commerce Pages"]
  node_store_account["Account Pages"]
  node_store_cart_checkout["Cart &amp; Checkout"]
  node_store_modules["Storefront Features"]
  node_store_data["Storefront Data"]
end

subgraph group_admin["Merchant Admin"]
  node_admin_routes["Management Screens"]
  node_admin_hooks["Admin API Hooks"]
  node_admin_client["Admin Client<br/>[client.ts]"]
end

subgraph group_api["Backend API"]
  node_store_api["Store API"]
  node_admin_api["Admin API"]
end

subgraph group_domain["Backend Domain"]
  node_company_workflows["Company Workflows"]
  node_employee_workflows["Employee Workflows"]
  node_approval_workflows["Approval Workflows"]
  node_quote_workflows["Quote Workflows"]
  node_cart_hooks["Cart Validation Hooks"]
  node_company_module[("Company Module")]
  node_approval_module[("Approval Module")]
  node_quote_module[("Quote Module")]
end

node_shopper(("Shopper / Employee"))
node_merchant(("Merchant"))
node_medusa_core["Medusa Commerce"]
node_payment_shipping["Payment &amp; Shipping"]

node_shopper -->|"browses"| node_store_pages
node_shopper -->|"manages account"| node_store_account
node_shopper -->|"purchases"| node_store_cart_checkout
node_merchant -->|"manages commerce"| node_admin_routes
node_store_pages -->|"renders features"| node_store_modules
node_store_account -->|"renders features"| node_store_modules
node_store_cart_checkout -->|"renders features"| node_store_modules
node_store_modules -->|"loads and mutates"| node_store_data
node_store_data -->|"requests"| node_store_api
node_admin_routes -->|"uses data hooks"| node_admin_hooks
node_admin_hooks -->|"uses client"| node_admin_client
node_admin_client -->|"requests"| node_admin_api
node_store_api -->|"runs company ops"| node_company_workflows
node_store_api -->|"runs approval ops"| node_approval_workflows
node_store_api -->|"runs quote ops"| node_quote_workflows
node_store_api -->|"validates carts"| node_cart_hooks
node_admin_api -->|"runs company ops"| node_company_workflows
node_admin_api -->|"runs approval ops"| node_approval_workflows
node_admin_api -->|"runs quote ops"| node_quote_workflows
node_company_workflows -->|"updates domain"| node_company_module
node_employee_workflows -->|"updates domain"| node_company_module
node_approval_workflows -->|"updates domain"| node_approval_module
node_quote_workflows -->|"updates domain"| node_quote_module
node_cart_hooks -->|"checks approval state"| node_approval_module
node_store_api -->|"queries commerce"| node_medusa_core
node_store_api -->|"lists shipping"| node_payment_shipping
node_store_cart_checkout -.->|"uses checkout services"| node_payment_shipping
node_store_api -->|"supports cart and orders"| node_medusa_core

click node_store_pages "https://github.com/medusajs/b2b-starter-medusa/tree/main/storefront/src/app/%5BcountryCode%5D/(main)"
click node_store_account "https://github.com/medusajs/b2b-starter-medusa/tree/main/storefront/src/app/%5BcountryCode%5D/(main)/account"
click node_store_cart_checkout "https://github.com/medusajs/b2b-starter-medusa/tree/main/storefront/src/app/%5BcountryCode%5D/(checkout)"
click node_store_modules "https://github.com/medusajs/b2b-starter-medusa/tree/main/storefront/src/modules"
click node_store_data "https://github.com/medusajs/b2b-starter-medusa/tree/main/storefront/src/lib/data"
click node_admin_routes "https://github.com/medusajs/b2b-starter-medusa/tree/main/backend/src/admin/routes"
click node_admin_hooks "https://github.com/medusajs/b2b-starter-medusa/tree/main/backend/src/admin/hooks/api"
click node_admin_client "https://github.com/medusajs/b2b-starter-medusa/blob/main/backend/src/admin/lib/client.ts"
click node_store_api "https://github.com/medusajs/b2b-starter-medusa/tree/main/backend/src/api/store"
click node_admin_api "https://github.com/medusajs/b2b-starter-medusa/tree/main/backend/src/api/admin"
click node_company_workflows "https://github.com/medusajs/b2b-starter-medusa/tree/main/backend/src/workflows/company/workflows"
click node_employee_workflows "https://github.com/medusajs/b2b-starter-medusa/tree/main/backend/src/workflows/employee/workflows"
click node_approval_workflows "https://github.com/medusajs/b2b-starter-medusa/tree/main/backend/src/workflows/approval/workflows"
click node_quote_workflows "https://github.com/medusajs/b2b-starter-medusa/tree/main/backend/src/workflows/quote/workflows"
click node_cart_hooks "https://github.com/medusajs/b2b-starter-medusa/tree/main/backend/src/workflows/hooks"
click node_company_module "https://github.com/medusajs/b2b-starter-medusa/tree/main/backend/src/modules/company"
click node_approval_module "https://github.com/medusajs/b2b-starter-medusa/tree/main/backend/src/modules/approval"
click node_quote_module "https://github.com/medusajs/b2b-starter-medusa/tree/main/backend/src/modules/quote"

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_store_pages,node_store_account,node_store_cart_checkout,node_store_modules,node_store_data toneBlue
class node_admin_routes,node_admin_hooks,node_admin_client toneAmber
class node_store_api,node_admin_api toneMint
class node_company_workflows,node_employee_workflows,node_approval_workflows,node_quote_workflows,node_cart_hooks,node_company_module,node_approval_module,node_quote_module toneRose
class node_shopper,node_merchant,node_medusa_core,node_payment_shipping toneIndigo
```

## Components

### Storefront

- [Commerce Pages](https://github.com/medusajs/b2b-starter-medusa/tree/main/storefront/src/app/%5BcountryCode%5D/(main)): `storefront/src/app/[countryCode]/(main)`
- [Account Pages](https://github.com/medusajs/b2b-starter-medusa/tree/main/storefront/src/app/%5BcountryCode%5D/(main)/account): `storefront/src/app/[countryCode]/(main)/account`
- [Cart & Checkout](https://github.com/medusajs/b2b-starter-medusa/tree/main/storefront/src/app/%5BcountryCode%5D/(checkout)): `storefront/src/app/[countryCode]/(checkout)`
- [Storefront Features](https://github.com/medusajs/b2b-starter-medusa/tree/main/storefront/src/modules): `storefront/src/modules`
- [Storefront Data](https://github.com/medusajs/b2b-starter-medusa/tree/main/storefront/src/lib/data): `storefront/src/lib/data`

### Merchant Admin

- [Management Screens](https://github.com/medusajs/b2b-starter-medusa/tree/main/backend/src/admin/routes): `backend/src/admin/routes`
- [Admin API Hooks](https://github.com/medusajs/b2b-starter-medusa/tree/main/backend/src/admin/hooks/api): `backend/src/admin/hooks/api`
- [Admin Client](https://github.com/medusajs/b2b-starter-medusa/blob/main/backend/src/admin/lib/client.ts): `backend/src/admin/lib/client.ts`

### Backend API

- [Store API](https://github.com/medusajs/b2b-starter-medusa/tree/main/backend/src/api/store): `backend/src/api/store`
- [Admin API](https://github.com/medusajs/b2b-starter-medusa/tree/main/backend/src/api/admin): `backend/src/api/admin`

### Backend Domain

- [Company Workflows](https://github.com/medusajs/b2b-starter-medusa/tree/main/backend/src/workflows/company/workflows): `backend/src/workflows/company/workflows`
- [Employee Workflows](https://github.com/medusajs/b2b-starter-medusa/tree/main/backend/src/workflows/employee/workflows): `backend/src/workflows/employee/workflows`
- [Approval Workflows](https://github.com/medusajs/b2b-starter-medusa/tree/main/backend/src/workflows/approval/workflows): `backend/src/workflows/approval/workflows`
- [Quote Workflows](https://github.com/medusajs/b2b-starter-medusa/tree/main/backend/src/workflows/quote/workflows): `backend/src/workflows/quote/workflows`
- [Cart Validation Hooks](https://github.com/medusajs/b2b-starter-medusa/tree/main/backend/src/workflows/hooks): `backend/src/workflows/hooks`
- [Company Module](https://github.com/medusajs/b2b-starter-medusa/tree/main/backend/src/modules/company): `backend/src/modules/company`
- [Approval Module](https://github.com/medusajs/b2b-starter-medusa/tree/main/backend/src/modules/approval): `backend/src/modules/approval`
- [Quote Module](https://github.com/medusajs/b2b-starter-medusa/tree/main/backend/src/modules/quote): `backend/src/modules/quote`

### Other components

- **Shopper / Employee**
- **Merchant**
- **Medusa Commerce**
- **Payment & Shipping**

## Connections

- Shopper / Employee → Commerce Pages: browses
- Shopper / Employee → Account Pages: manages account
- Shopper / Employee → Cart & Checkout: purchases
- Merchant → Management Screens: manages commerce
- Commerce Pages → Storefront Features: renders features
- Account Pages → Storefront Features: renders features
- Cart & Checkout → Storefront Features: renders features
- Storefront Features → Storefront Data: loads and mutates
- Storefront Data → Store API: requests
- Management Screens → Admin API Hooks: uses data hooks
- Admin API Hooks → Admin Client: uses client
- Admin Client → Admin API: requests
- Store API → Company Workflows: runs company ops
- Store API → Approval Workflows: runs approval ops
- Store API → Quote Workflows: runs quote ops
- Store API → Cart Validation Hooks: validates carts
- Admin API → Company Workflows: runs company ops
- Admin API → Approval Workflows: runs approval ops
- Admin API → Quote Workflows: runs quote ops
- Company Workflows → Company Module: updates domain
- Employee Workflows → Company Module: updates domain
- Approval Workflows → Approval Module: updates domain
- Quote Workflows → Quote Module: updates domain
- Cart Validation Hooks → Approval Module: checks approval state
- Store API → Medusa Commerce: queries commerce
- Store API → Payment & Shipping: lists shipping
- Cart & Checkout → Payment & Shipping: uses checkout services
- Store API → Medusa Commerce: supports cart and orders
