# nexez-ai/nexez architecture

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

- Interactive diagram: https://gitdiagram.com/nexez-ai/nexez
- Repository: https://github.com/nexez-ai/nexez

## Overview

#### Purpose and entry points
Nexez is a multi-surface commerce platform that turns seller offers into public pages, agent-readable artifacts, and approval-gated transaction workflows. The primary runtime is a Next.js App Router application: public listings at `app/[slug]/page.tsx`, seller operations under `app/dashboard/page.tsx`, and HTTP/protocol endpoints under `app/api`. A separate Expo seller app begins at `apps/seller-mobile/app/_layout.tsx`.

#### Public publishing and discovery
Published listings are rendered for people and projected into scoped machine artifacts: `app/[slug]/agent.json/route.ts`, `app/[slug]/mcp/route.ts`, and `app/[slug]/openapi.json/route.ts`. Platform-wide discovery is exposed through `app/.well-known/agent.json/route.ts`, `app/agent-pages.json/route.ts`, and `app/api/agent-search/route.ts`. This is a deliberate public boundary: only publishable projections should cross it; drafts, credentials, and private seller state remain server/data-layer concerns.

#### Seller authoring and operational control
The dashboard manages pages, offers, templates, integrations, analytics, billing, negotiations, and orders, centered on `app/dashboard/[id]/page.tsx`, `app/dashboard/[id]/EditorClient.tsx`, and `components/editor/usePageEditor.ts`. Domain logic separates offer configuration and business rules from UI in `lib/configured-offer.ts`, `lib/offer-configuration.ts`, and `lib/offer-rules.ts`. Admin-only operations are isolated under `app/admin/layout.tsx` and `app/api/admin`.

#### Agent protocols and Nexxi execution
Agent-facing access includes REST, MCP, A2A, ACP, and UCP. Core protocol implementations are `lib/mcp-server.ts`, `lib/a2a/v1/runtime.ts`, and `lib/acp/wire.ts`; routes include `app/api/v1/a2a/route.ts`, `app/mcp/route.ts`, and `app/api/acp/checkout_sessions/route.ts`. Nexxi is the stateful buyer-agent surface, with streaming, task, memory, preferences, and approval recovery logic in `lib/agents/nexxi.ts`, `lib/agents/nexxi-stream.ts`, and `lib/agents/nexxi-commerce.ts`. A2A has a durable task/event ledger rather than relying on request-local execution.

#### Commerce lifecycle and safety boundary
Checkout, negotiation, orders, reservations, agreements, and staged settlement are distinct consequential-action flows. Route entry points include `app/api/checkout/route.ts`, `app/api/negotiations/route.ts`, and `app/api/orders/[id]/fulfillment/route.ts`; core services include `lib/checkout.ts`, `lib/negotiation.service.ts`, and `lib/settlement.ts`. Approval binding, idempotency, request hashing, money constraints, and dry-run validation form the mutation boundary. Stripe webhooks and reconciliation close the loop through `app/api/webhooks/stripe/route.ts`, `app/api/cron/reconcile-billing/route.ts`, and `lib/server/checkout-session-store.ts`.

#### Data, identity, integrations, and async work
Supabase provides Auth, PostgreSQL, Storage, RLS, private secrets, and durable operational ledgers; schema and security contracts live in `supabase/migrations`, notably `supabase/migrations/20260901030000_a2a_v1_durable_ledger.sql`. Server access and authorization are concentrated in `utils/supabase/server.ts`, `lib/server/request-auth.ts`, and `lib/server/require-page-access.ts`. Stripe Connect/Billing, Shopify, Calendly, Acuity, Square, Google Calendar, Twilio, Vercel domains, and LLM providers are external boundaries. OAuth/import/sync routes are under `app/api/integrations`, webhooks under `app/api/webhooks`, and Inngest-backed async functions under `lib/inngest/functions`.

#### Secondary distribution surfaces and delivery
The Expo mobile seller client uses shared backend contracts via `apps/seller-mobile/src/lib/api.ts` and `apps/seller-mobile/src/lib/supabase.ts`. Buyer integrations are distributed as TypeScript/Python SDKs in `sdk/typescript/src/index.ts` and `sdk/python/src/nexez_agent_sdk/__init__.py`, plus OpenClaw, Shopify, and WordPress plugins in `plugins`. Deployment targets Vercel with cron endpoints; GitHub Actions includes CI, protocol interoperability, migration, canary, and release-certification workflows under `.github/workflows`.

Main entry points: [`supabase/migrations`](https://github.com/nexez-ai/nexez/tree/main/supabase/migrations) (Supabase), [`lib/configured-offer.ts`](https://github.com/nexez-ai/nexez/blob/main/lib/configured-offer.ts) (Offer Domain Rules), [`lib/mcp-server.ts`](https://github.com/nexez-ai/nexez/blob/main/lib/mcp-server.ts) (Protocol Runtime), [`lib/checkout.ts`](https://github.com/nexez-ai/nexez/blob/main/lib/checkout.ts) (Mutation Safety Boundary)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_surfaces["User &amp; Public Surfaces"]
  node_public_pages["Public Listings<br/>Next.js pages<br/>[page.tsx]"]
  node_public_artifacts["Published Agent Artifacts<br/>Next.js routes<br/>[route.ts]"]
  node_discovery["Platform Discovery<br/>Next.js routes<br/>[route.ts]"]
  node_seller_dashboard["Seller Dashboard<br/>Next.js App Router<br/>[page.tsx]"]
  node_page_editor["Page Editor<br/>React client<br/>[EditorClient.tsx]"]
  node_admin["Admin Operations<br/>Next.js admin<br/>[layout.tsx]"]
end

subgraph group_protocols["Agent Protocols"]
  node_agent_protocols{{"Protocol Runtime<br/>[mcp-server.ts]"}}
  node_a2a_ledger[("A2A Durable Ledger<br/>task/event ledger")]
  node_nexxi{{"Nexxi Buyer Agent<br/>stateful agent<br/>[nexxi.ts]"}}
end

subgraph group_commerce["Commerce Control Plane"]
  node_offer_domain{{"Offer Domain Rules<br/>domain logic"}}
  node_commerce_routes["Commerce APIs<br/>Next.js routes<br/>[route.ts]"]
  node_mutation_guard{{"Mutation Safety Boundary<br/>approval &amp; validation<br/>[checkout.ts]"}}
  node_settlement{{"Settlement Service<br/>commerce service<br/>[settlement.ts]"}}
end

subgraph group_platform["Data &amp; Operations"]
  node_auth_access{{"Server Auth &amp; Access<br/>authorization<br/>[request-auth.ts]"}}
  node_supabase[("Supabase")]
  node_integrations["Integration Sync"]
  node_stripe_ops["Stripe Reconciliation<br/>webhook &amp; cron<br/>[route.ts]"]
  node_async_work["Async Workflows<br/>Inngest functions"]
end

subgraph group_distribution["Distribution"]
  node_mobile["Seller Mobile App<br/>Expo client<br/>[_layout.tsx]"]
  node_sdks_plugins["SDKs &amp; Plugins<br/>integration distribution<br/>[index.ts]"]
  node_delivery["Deployment &amp; Certification<br/>Vercel / GitHub Actions<br/>[workflows]"]
end

node_seller_dashboard -->|"edits"| node_page_editor
node_page_editor -->|"configures"| node_offer_domain
node_seller_dashboard -->|"authorizes through"| node_auth_access
node_auth_access -->|"uses"| node_supabase
node_offer_domain -->|"persists offers"| node_supabase
node_offer_domain -->|"publishes"| node_public_pages
node_offer_domain -->|"projects"| node_public_artifacts
node_public_artifacts -->|"listed by"| node_discovery
node_agent_protocols -->|"serves protocol views"| node_public_artifacts
node_agent_protocols -->|"records A2A tasks"| node_a2a_ledger
node_a2a_ledger -->|"stored in"| node_supabase
node_nexxi -->|"executes via"| node_agent_protocols
node_nexxi -->|"initiates actions"| node_commerce_routes
node_commerce_routes -->|"guards mutations"| node_mutation_guard
node_mutation_guard -->|"authorizes settlement"| node_settlement
node_mutation_guard -->|"records lifecycle"| node_supabase
node_stripe_ops -->|"reconciles"| node_settlement
node_integrations -->|"schedules sync"| node_async_work
node_async_work -->|"updates"| node_supabase
node_mobile -->|"uses backend contracts"| node_auth_access
node_sdks_plugins -->|"consume"| node_agent_protocols
node_delivery -.->|"runs scheduled work"| node_async_work

click node_public_pages "https://github.com/nexez-ai/nexez/blob/main/app/%5Bslug%5D/page.tsx"
click node_public_artifacts "https://github.com/nexez-ai/nexez/blob/main/app/%5Bslug%5D/agent.json/route.ts"
click node_discovery "https://github.com/nexez-ai/nexez/blob/main/app/.well-known/agent.json/route.ts"
click node_seller_dashboard "https://github.com/nexez-ai/nexez/blob/main/app/dashboard/%5Bid%5D/page.tsx"
click node_page_editor "https://github.com/nexez-ai/nexez/blob/main/app/dashboard/%5Bid%5D/EditorClient.tsx"
click node_offer_domain "https://github.com/nexez-ai/nexez/blob/main/lib/configured-offer.ts"
click node_admin "https://github.com/nexez-ai/nexez/blob/main/app/admin/layout.tsx"
click node_agent_protocols "https://github.com/nexez-ai/nexez/blob/main/lib/mcp-server.ts"
click node_a2a_ledger "https://github.com/nexez-ai/nexez/blob/main/supabase/migrations/20260901030000_a2a_v1_durable_ledger.sql"
click node_nexxi "https://github.com/nexez-ai/nexez/blob/main/lib/agents/nexxi.ts"
click node_commerce_routes "https://github.com/nexez-ai/nexez/blob/main/app/api/checkout/route.ts"
click node_mutation_guard "https://github.com/nexez-ai/nexez/blob/main/lib/checkout.ts"
click node_settlement "https://github.com/nexez-ai/nexez/blob/main/lib/settlement.ts"
click node_auth_access "https://github.com/nexez-ai/nexez/blob/main/lib/server/request-auth.ts"
click node_supabase "https://github.com/nexez-ai/nexez/tree/main/supabase/migrations"
click node_integrations "https://github.com/nexez-ai/nexez/tree/main/app/api/integrations"
click node_stripe_ops "https://github.com/nexez-ai/nexez/blob/main/app/api/webhooks/stripe/route.ts"
click node_async_work "https://github.com/nexez-ai/nexez/tree/main/lib/inngest/functions"
click node_mobile "https://github.com/nexez-ai/nexez/blob/main/apps/seller-mobile/app/_layout.tsx"
click node_sdks_plugins "https://github.com/nexez-ai/nexez/blob/main/sdk/typescript/src/index.ts"
click node_delivery "https://github.com/nexez-ai/nexez/tree/main/.github/workflows"

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_public_pages,node_public_artifacts,node_discovery,node_seller_dashboard,node_page_editor,node_admin toneBlue
class node_agent_protocols,node_a2a_ledger,node_nexxi toneAmber
class node_offer_domain,node_commerce_routes,node_mutation_guard,node_settlement toneMint
class node_auth_access,node_supabase,node_integrations,node_stripe_ops,node_async_work toneRose
class node_mobile,node_sdks_plugins,node_delivery toneIndigo
```

## Components

### User & Public Surfaces

- [Public Listings](https://github.com/nexez-ai/nexez/blob/main/app/%5Bslug%5D/page.tsx): Next.js pages · Human-facing published seller offers. · `app/[slug]/page.tsx`
- [Published Agent Artifacts](https://github.com/nexez-ai/nexez/blob/main/app/%5Bslug%5D/agent.json/route.ts): Next.js routes · Scoped machine-readable projections of publishable listings. · `app/[slug]/agent.json/route.ts`
- [Platform Discovery](https://github.com/nexez-ai/nexez/blob/main/app/.well-known/agent.json/route.ts): Next.js routes · Platform-wide agent discovery and search boundary. · `app/.well-known/agent.json/route.ts`
- [Seller Dashboard](https://github.com/nexez-ai/nexez/blob/main/app/dashboard/%5Bid%5D/page.tsx): Next.js App Router · Seller operations for pages, offers, orders, and integrations. · `app/dashboard/[id]/page.tsx`
- [Page Editor](https://github.com/nexez-ai/nexez/blob/main/app/dashboard/%5Bid%5D/EditorClient.tsx): React client · `app/dashboard/[id]/EditorClient.tsx`
- [Admin Operations](https://github.com/nexez-ai/nexez/blob/main/app/admin/layout.tsx): Next.js admin · Isolated administrative surface. · `app/admin/layout.tsx`

### Agent Protocols

- [Protocol Runtime](https://github.com/nexez-ai/nexez/blob/main/lib/mcp-server.ts): MCP / A2A / ACP · Shared implementation of agent-facing protocols. · `lib/mcp-server.ts`
- [A2A Durable Ledger](https://github.com/nexez-ai/nexez/blob/main/supabase/migrations/20260901030000_a2a_v1_durable_ledger.sql): task/event ledger · Durable A2A task and event execution state. · `supabase/migrations/20260901030000_a2a_v1_durable_ledger.sql`
- [Nexxi Buyer Agent](https://github.com/nexez-ai/nexez/blob/main/lib/agents/nexxi.ts): stateful agent · Streaming buyer-agent execution with memory and approval recovery. · `lib/agents/nexxi.ts`

### Commerce Control Plane

- [Offer Domain Rules](https://github.com/nexez-ai/nexez/blob/main/lib/configured-offer.ts): domain logic · Offer configuration and business-rule boundary. · `lib/configured-offer.ts`
- [Commerce APIs](https://github.com/nexez-ai/nexez/blob/main/app/api/checkout/route.ts): Next.js routes · Checkout, negotiation, and fulfillment entry points. · `app/api/checkout/route.ts`
- [Mutation Safety Boundary](https://github.com/nexez-ai/nexez/blob/main/lib/checkout.ts): approval & validation · Binds approvals and enforces idempotency, hashes, money constraints, and dry runs. · `lib/checkout.ts`
- [Settlement Service](https://github.com/nexez-ai/nexez/blob/main/lib/settlement.ts): commerce service · Staged settlement and reconciliation lifecycle. · `lib/settlement.ts`

### Data & Operations

- [Server Auth & Access](https://github.com/nexez-ai/nexez/blob/main/lib/server/request-auth.ts): authorization · Server identity and page-access enforcement. · `lib/server/request-auth.ts`
- [Supabase](https://github.com/nexez-ai/nexez/tree/main/supabase/migrations): Auth / Postgres / Storage · RLS-protected system of record, secrets, and operational ledgers. · `supabase/migrations`
- [Integration Sync](https://github.com/nexez-ai/nexez/tree/main/app/api/integrations): OAuth / webhooks / sync · Third-party commerce and calendar integration boundary. · `app/api/integrations`
- [Stripe Reconciliation](https://github.com/nexez-ai/nexez/blob/main/app/api/webhooks/stripe/route.ts): webhook & cron · Closes billing state through webhooks and reconciliation. · `app/api/webhooks/stripe/route.ts`
- [Async Workflows](https://github.com/nexez-ai/nexez/tree/main/lib/inngest/functions): Inngest functions · Background processing for durable operations and sync. · `lib/inngest/functions`

### Distribution

- [Seller Mobile App](https://github.com/nexez-ai/nexez/blob/main/apps/seller-mobile/app/_layout.tsx): Expo client · Mobile seller surface using shared backend contracts. · `apps/seller-mobile/app/_layout.tsx`
- [SDKs & Plugins](https://github.com/nexez-ai/nexez/blob/main/sdk/typescript/src/index.ts): integration distribution · Buyer integrations distributed to external ecosystems. · `sdk/typescript/src/index.ts`
- [Deployment & Certification](https://github.com/nexez-ai/nexez/tree/main/.github/workflows): Vercel / GitHub Actions · Deployment, cron, interoperability, migration, and release workflows. · `.github/workflows`

## Connections

- Seller Dashboard → Page Editor: edits
- Page Editor → Offer Domain Rules: configures
- Seller Dashboard → Server Auth & Access: authorizes through
- Server Auth & Access → Supabase: uses
- Offer Domain Rules → Supabase: persists offers
- Offer Domain Rules → Public Listings: publishes
- Offer Domain Rules → Published Agent Artifacts: projects
- Published Agent Artifacts → Platform Discovery: listed by
- Protocol Runtime → Published Agent Artifacts: serves protocol views
- Protocol Runtime → A2A Durable Ledger: records A2A tasks
- A2A Durable Ledger → Supabase: stored in
- Nexxi Buyer Agent → Protocol Runtime: executes via
- Nexxi Buyer Agent → Commerce APIs: initiates actions
- Commerce APIs → Mutation Safety Boundary: guards mutations
- Mutation Safety Boundary → Settlement Service: authorizes settlement
- Mutation Safety Boundary → Supabase: records lifecycle
- Stripe Reconciliation → Settlement Service: reconciles
- Integration Sync → Async Workflows: schedules sync
- Async Workflows → Supabase: updates
- Seller Mobile App → Server Auth & Access: uses backend contracts
- SDKs & Plugins → Protocol Runtime: consume
- Deployment & Certification → Async Workflows: runs scheduled work
