# ec-cube/eccube-api4 architecture

> Architecture diagram of the GitHub repository ec-cube/eccube-api4, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-04). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ec-cube/eccube-api4
- Repository: https://github.com/ec-cube/eccube-api4

## Overview

This EC-CUBE plugin provides a GraphQL Web API for external services, plus OAuth client administration and event-driven webhooks. The main request flow is an API consumer sending a query to the API controller, which applies scope validation and executes it against the schema; query and mutation implementations resolve domain data or operations. Separate admin flows configure OAuth clients and webhooks. Webhook events collect entity changes and can invoke registered triggers. Some domain modules are represented by their exact tree paths where source excerpts were not available; arrows are limited to relationships shown in excerpts, the SOURCE INDEX, or the README.

Main entry points: [`GraphQL/Query/SearchFormQuery.php`](https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Query/SearchFormQuery.php) (Search Queries), [`DependencyInjection/Compiler/ApiCompilerPass.php`](https://github.com/ec-cube/eccube-api4/blob/4.2/DependencyInjection/Compiler/ApiCompilerPass.php) (Service Registration), [`GraphQL/Schema.php`](https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Schema.php) (GraphQL Schema), [`Controller/Admin/WebHookController.php`](https://github.com/ec-cube/eccube-api4/blob/4.2/Controller/Admin/WebHookController.php) (Webhook Admin)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_api["GraphQL API"]
  node_api_controller["API Controller<br/>[ApiController.php]"]
  node_schema["GraphQL Schema<br/>[Schema.php]"]
  node_query_registry["Query Registry<br/>[Query.php]"]
  node_search_queries["Search Queries"]
  node_catalog_queries["Catalog Queries<br/>[ProductsQuery.php]"]
  node_order_queries["Order Queries<br/>[OrdersQuery.php]"]
  node_customer_queries["Customer Queries<br/>[CustomersQuery.php]"]
  node_single_queries["Single Queries"]
  node_mutation_registry["Mutation Registry<br/>[Mutation.php]"]
  node_stock_mutation["Stock Mutation"]
  node_shipping_mutation["Shipping Mutation"]
  node_types["Entity Types<br/>[Types.php]"]
  node_allowlist["Field Allow List<br/>[AllowList.php]"]
  node_connection["Connections<br/>[ConnectionType.php]"]
  node_datetime["DateTime Scalar<br/>[DateTimeType.php]"]
  node_scope_rule["Scope Validation"]
end

subgraph group_auth["OAuth Access"]
  node_oauth_admin["OAuth Admin"]
  node_client_form["Client Form<br/>[ClientType.php]"]
  node_authorization_listener["Authorization Resolver"]
  node_user_listener["User Resolver"]
end

subgraph group_hooks["Webhooks"]
  node_webhook_admin["Webhook Admin"]
  node_webhook_form["Webhook Form<br/>[WebHookType.php]"]
  node_webhook_entity[("Webhook Record<br/>[WebHook.php]")]
  node_webhook_repo["Webhook Repository"]
  node_webhook_service["Webhook Service<br/>[WebHookService.php]"]
  node_webhook_events["Entity Events<br/>[WebHookEvents.php]"]
  node_webhook_trigger["Webhook Triggers<br/>[WebHookTrigger.php]"]
  node_entity_listener["Entity Listener<br/>[EntityListener.php]"]
end

subgraph group_setup["Plugin Wiring"]
  node_compiler_pass["Service Registration"]
end

node_consumer(("API Consumer"))
node_admin(("Store Administrator"))

node_consumer -->|"sends query"| node_api_controller
node_api_controller -->|"executes against"| node_schema
node_api_controller -->|"validates scopes"| node_scope_rule
node_schema -->|"uses queries"| node_query_registry
node_schema -->|"uses mutations"| node_mutation_registry
node_schema -->|"uses types"| node_types
node_query_registry -->|"implements contract"| node_search_queries
node_catalog_queries -->|"extends"| node_search_queries
node_order_queries -->|"extends"| node_search_queries
node_customer_queries -->|"extends"| node_search_queries
node_single_queries -->|"implements contract"| node_query_registry
node_mutation_registry -->|"implements contract"| node_stock_mutation
node_mutation_registry -->|"implements contract"| node_shipping_mutation
node_search_queries -->|"returns connection"| node_connection
node_search_queries -->|"uses entity types"| node_types
node_types -->|"filters fields"| node_allowlist
node_types -->|"maps date fields"| node_datetime
node_compiler_pass -->|"registers queries"| node_query_registry
node_compiler_pass -->|"registers mutations"| node_mutation_registry
node_compiler_pass -->|"registers allow lists"| node_allowlist
node_admin -->|"manages clients"| node_oauth_admin
node_oauth_admin -->|"builds form"| node_client_form
node_authorization_listener -.->|"resolves request"| node_authorization_listener
node_admin -->|"manages hooks"| node_webhook_admin
node_webhook_admin -->|"builds form"| node_webhook_form
node_webhook_admin -->|"uses repository"| node_webhook_repo
node_webhook_admin -->|"uses record"| node_webhook_entity
node_webhook_service -->|"uses repository"| node_webhook_repo
node_webhook_service -->|"uses record"| node_webhook_entity
node_webhook_service -->|"uses events"| node_webhook_events
node_entity_listener -->|"notifies events"| node_webhook_events
node_webhook_events -->|"dispatches triggers"| node_webhook_trigger
node_compiler_pass -->|"registers triggers"| node_webhook_events
node_compiler_pass -->|"discovers implementations"| node_webhook_trigger

click node_api_controller "https://github.com/ec-cube/eccube-api4/blob/4.2/Controller/ApiController.php"
click node_schema "https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Schema.php"
click node_query_registry "https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Query.php"
click node_search_queries "https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Query/SearchFormQuery.php"
click node_catalog_queries "https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Query/ProductsQuery.php"
click node_order_queries "https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Query/OrdersQuery.php"
click node_customer_queries "https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Query/CustomersQuery.php"
click node_single_queries "https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Query/SingleResultQuery.php"
click node_mutation_registry "https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Mutation.php"
click node_stock_mutation "https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Mutation/UpdateProductStockMutation.php"
click node_shipping_mutation "https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Mutation/UpdateShippedMutation.php"
click node_types "https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Types.php"
click node_allowlist "https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/AllowList.php"
click node_connection "https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Type/ConnectionType.php"
click node_datetime "https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Type/Definition/DateTimeType.php"
click node_scope_rule "https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/ScopeValidationRule.php"
click node_oauth_admin "https://github.com/ec-cube/eccube-api4/blob/4.2/Controller/Admin/OAuthController.php"
click node_client_form "https://github.com/ec-cube/eccube-api4/blob/4.2/Form/Type/Admin/ClientType.php"
click node_authorization_listener "https://github.com/ec-cube/eccube-api4/blob/4.2/EventListener/AuthorizationRequestResolveListener.php"
click node_user_listener "https://github.com/ec-cube/eccube-api4/blob/4.2/EventListener/UserResolveListener.php"
click node_webhook_admin "https://github.com/ec-cube/eccube-api4/blob/4.2/Controller/Admin/WebHookController.php"
click node_webhook_form "https://github.com/ec-cube/eccube-api4/blob/4.2/Form/Type/Admin/WebHookType.php"
click node_webhook_entity "https://github.com/ec-cube/eccube-api4/blob/4.2/Entity/WebHook.php"
click node_webhook_repo "https://github.com/ec-cube/eccube-api4/blob/4.2/Repository/WebHookRepository.php"
click node_webhook_service "https://github.com/ec-cube/eccube-api4/blob/4.2/Service/WebHookService.php"
click node_webhook_events "https://github.com/ec-cube/eccube-api4/blob/4.2/Service/WebHookEvents.php"
click node_webhook_trigger "https://github.com/ec-cube/eccube-api4/blob/4.2/Service/WebHookTrigger.php"
click node_entity_listener "https://github.com/ec-cube/eccube-api4/blob/4.2/Doctrine/EventSubscriber/EntityListener.php"
click node_compiler_pass "https://github.com/ec-cube/eccube-api4/blob/4.2/DependencyInjection/Compiler/ApiCompilerPass.php"

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_api_controller,node_schema,node_query_registry,node_search_queries,node_catalog_queries,node_order_queries,node_customer_queries,node_single_queries,node_mutation_registry,node_stock_mutation,node_shipping_mutation,node_types,node_allowlist,node_connection,node_datetime,node_scope_rule toneBlue
class node_oauth_admin,node_client_form,node_authorization_listener,node_user_listener toneAmber
class node_webhook_admin,node_webhook_form,node_webhook_entity,node_webhook_repo,node_webhook_service,node_webhook_events,node_webhook_trigger,node_entity_listener,node_consumer toneMint
class node_compiler_pass toneRose
class node_admin toneIndigo
```

## Components

### GraphQL API

- [API Controller](https://github.com/ec-cube/eccube-api4/blob/4.2/Controller/ApiController.php): `Controller/ApiController.php`
- [GraphQL Schema](https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Schema.php): `GraphQL/Schema.php`
- [Query Registry](https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Query.php): `GraphQL/Query.php`
- [Search Queries](https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Query/SearchFormQuery.php): `GraphQL/Query/SearchFormQuery.php`
- [Catalog Queries](https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Query/ProductsQuery.php): `GraphQL/Query/ProductsQuery.php`
- [Order Queries](https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Query/OrdersQuery.php): `GraphQL/Query/OrdersQuery.php`
- [Customer Queries](https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Query/CustomersQuery.php): `GraphQL/Query/CustomersQuery.php`
- [Single Queries](https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Query/SingleResultQuery.php): `GraphQL/Query/SingleResultQuery.php`
- [Mutation Registry](https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Mutation.php): `GraphQL/Mutation.php`
- [Stock Mutation](https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Mutation/UpdateProductStockMutation.php): `GraphQL/Mutation/UpdateProductStockMutation.php`
- [Shipping Mutation](https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Mutation/UpdateShippedMutation.php): `GraphQL/Mutation/UpdateShippedMutation.php`
- [Entity Types](https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Types.php): `GraphQL/Types.php`
- [Field Allow List](https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/AllowList.php): `GraphQL/AllowList.php`
- [Connections](https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Type/ConnectionType.php): `GraphQL/Type/ConnectionType.php`
- [DateTime Scalar](https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/Type/Definition/DateTimeType.php): `GraphQL/Type/Definition/DateTimeType.php`
- [Scope Validation](https://github.com/ec-cube/eccube-api4/blob/4.2/GraphQL/ScopeValidationRule.php): `GraphQL/ScopeValidationRule.php`

### OAuth Access

- [OAuth Admin](https://github.com/ec-cube/eccube-api4/blob/4.2/Controller/Admin/OAuthController.php): `Controller/Admin/OAuthController.php`
- [Client Form](https://github.com/ec-cube/eccube-api4/blob/4.2/Form/Type/Admin/ClientType.php): `Form/Type/Admin/ClientType.php`
- [Authorization Resolver](https://github.com/ec-cube/eccube-api4/blob/4.2/EventListener/AuthorizationRequestResolveListener.php): `EventListener/AuthorizationRequestResolveListener.php`
- [User Resolver](https://github.com/ec-cube/eccube-api4/blob/4.2/EventListener/UserResolveListener.php): `EventListener/UserResolveListener.php`

### Webhooks

- [Webhook Admin](https://github.com/ec-cube/eccube-api4/blob/4.2/Controller/Admin/WebHookController.php): `Controller/Admin/WebHookController.php`
- [Webhook Form](https://github.com/ec-cube/eccube-api4/blob/4.2/Form/Type/Admin/WebHookType.php): `Form/Type/Admin/WebHookType.php`
- [Webhook Record](https://github.com/ec-cube/eccube-api4/blob/4.2/Entity/WebHook.php): `Entity/WebHook.php`
- [Webhook Repository](https://github.com/ec-cube/eccube-api4/blob/4.2/Repository/WebHookRepository.php): `Repository/WebHookRepository.php`
- [Webhook Service](https://github.com/ec-cube/eccube-api4/blob/4.2/Service/WebHookService.php): `Service/WebHookService.php`
- [Entity Events](https://github.com/ec-cube/eccube-api4/blob/4.2/Service/WebHookEvents.php): `Service/WebHookEvents.php`
- [Webhook Triggers](https://github.com/ec-cube/eccube-api4/blob/4.2/Service/WebHookTrigger.php): `Service/WebHookTrigger.php`
- [Entity Listener](https://github.com/ec-cube/eccube-api4/blob/4.2/Doctrine/EventSubscriber/EntityListener.php): `Doctrine/EventSubscriber/EntityListener.php`

### Plugin Wiring

- [Service Registration](https://github.com/ec-cube/eccube-api4/blob/4.2/DependencyInjection/Compiler/ApiCompilerPass.php): `DependencyInjection/Compiler/ApiCompilerPass.php`

### Other components

- **API Consumer**
- **Store Administrator**

## Connections

- API Consumer → API Controller: sends query
- API Controller → GraphQL Schema: executes against (evidence: `Controller/ApiController.php`)
- API Controller → Scope Validation: validates scopes (evidence: `Controller/ApiController.php`)
- GraphQL Schema → Query Registry: uses queries (evidence: `GraphQL/Schema.php`)
- GraphQL Schema → Mutation Registry: uses mutations (evidence: `GraphQL/Schema.php`)
- GraphQL Schema → Entity Types: uses types (evidence: `GraphQL/Schema.php`)
- Query Registry → Search Queries: implements contract (evidence: `GraphQL/Query/SearchFormQuery.php`)
- Catalog Queries → Search Queries: extends (evidence: `GraphQL/Query/ProductsQuery.php`)
- Order Queries → Search Queries: extends (evidence: `GraphQL/Query/OrdersQuery.php`)
- Customer Queries → Search Queries: extends (evidence: `GraphQL/Query/CustomersQuery.php`)
- Single Queries → Query Registry: implements contract (evidence: `GraphQL/Query/SingleResultQuery.php`)
- Mutation Registry → Stock Mutation: implements contract (evidence: `GraphQL/Mutation/UpdateProductStockMutation.php`)
- Mutation Registry → Shipping Mutation: implements contract (evidence: `GraphQL/Mutation/UpdateShippedMutation.php`)
- Search Queries → Connections: returns connection (evidence: `GraphQL/Query/SearchFormQuery.php`)
- Search Queries → Entity Types: uses entity types (evidence: `GraphQL/Query/SearchFormQuery.php`)
- Entity Types → Field Allow List: filters fields (evidence: `GraphQL/Types.php`)
- Entity Types → DateTime Scalar: maps date fields (evidence: `GraphQL/Types.php`)
- Service Registration → Query Registry: registers queries (evidence: `DependencyInjection/Compiler/ApiCompilerPass.php`)
- Service Registration → Mutation Registry: registers mutations (evidence: `DependencyInjection/Compiler/ApiCompilerPass.php`)
- Service Registration → Field Allow List: registers allow lists (evidence: `DependencyInjection/Compiler/ApiCompilerPass.php`)
- Store Administrator → OAuth Admin: manages clients (evidence: `Controller/Admin/OAuthController.php`)
- OAuth Admin → Client Form: builds form (evidence: `Controller/Admin/OAuthController.php`)
- Authorization Resolver → Authorization Resolver: resolves request (evidence: `EventListener/AuthorizationRequestResolveListener.php`)
- Store Administrator → Webhook Admin: manages hooks (evidence: `Controller/Admin/WebHookController.php`)
- Webhook Admin → Webhook Form: builds form (evidence: `Controller/Admin/WebHookController.php`)
- Webhook Admin → Webhook Repository: uses repository (evidence: `Controller/Admin/WebHookController.php`)
- Webhook Admin → Webhook Record: uses record (evidence: `Controller/Admin/WebHookController.php`)
- Webhook Service → Webhook Repository: uses repository (evidence: `Service/WebHookService.php`)
- Webhook Service → Webhook Record: uses record (evidence: `Service/WebHookService.php`)
- Webhook Service → Entity Events: uses events (evidence: `Service/WebHookService.php`)
- Entity Listener → Entity Events: notifies events (evidence: `Doctrine/EventSubscriber/EntityListener.php`)
- Entity Events → Webhook Triggers: dispatches triggers (evidence: `Service/WebHookEvents.php`)
- Service Registration → Entity Events: registers triggers (evidence: `DependencyInjection/Compiler/ApiCompilerPass.php`)
- Service Registration → Webhook Triggers: discovers implementations (evidence: `DependencyInjection/Compiler/ApiCompilerPass.php`)
