# wangshai123/g3-web architecture

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

- Interactive diagram: https://gitdiagram.com/wangshai123/g3-web
- Repository: https://github.com/wangshai123/g3-web

## Overview

G3-Web is a WordPress plugin that extends sites with REST APIs, configurable components and business features. A representative request flow is a WordPress client calling a REST route: the router discovers and registers routes, applies middleware, invokes a controller, which delegates to services and returns a response. The plugin also provides independently useful queues, user/authentication, commerce and WeChat capabilities. Edges reflect README statements and source-index references or shown calls; unsampled feature internals are represented at their exact directories, and uncertain wiring is omitted.

Main entry points: [`src/Core/Router/Router.php`](https://github.com/wangshai123/g3-web/blob/main/src/Core/Router/Router.php) (REST Router), [`src/Core/Queue/Queue.php`](https://github.com/wangshai123/g3-web/blob/main/src/Core/Queue/Queue.php) (Queue Coordinator), [`src/Components/User/User.php`](https://github.com/wangshai123/g3-web/blob/main/src/Components/User/User.php) (User Features), [`src/Services/AuthService.php`](https://github.com/wangshai123/g3-web/blob/main/src/Services/AuthService.php) (Authentication)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Plugin Runtime"]
  node_plugin["Plugin Components<br/>[Components.php]"]
  node_component_manager["Component Loader"]
  node_container["Dependency Container<br/>[Container.php]"]
end

subgraph group_api["REST API"]
  node_router["REST Router<br/>[Router.php]"]
  node_controller["API Controllers"]
  node_middleware["API Middleware"]
end

subgraph group_accounts["Users and Auth"]
  node_auth_controller["Auth Endpoints<br/>[AuthController.php]"]
  node_auth_service["Authentication<br/>[AuthService.php]"]
  node_user_component["User Features<br/>[User.php]"]
  node_user_service["User Service<br/>[UserService.php]"]
  node_session_tokens["Session Tokens<br/>[SessionTokens.php]"]
end

subgraph group_business["Business Features"]
  node_content["Content Features"]
  node_commerce["Commerce Features"]
  node_orders["Order Features"]
  node_payments["Payment Services<br/>[PaymentService.php]"]
  node_wechat["WeChat Integration"]
  node_wechat_service["WeChat Service"]
end

subgraph group_async["Async Processing"]
  node_queue["Queue Coordinator<br/>[Queue.php]"]
  node_queue_interface["Queue Contract<br/>[QueueInterface.php]"]
  node_database_queue[("Database Queue<br/>[DatabaseQueue.php]")]
  node_redis_queue[("Redis Queue<br/>[RedisQueue.php]")]
  node_worker["Queue Worker<br/>[queue-worker.php]"]
  node_queue_jobs["Background Jobs"]
end

node_wp(("WordPress Client"))
node_wp_store[("WordPress Data")]

node_wp -->|"requests routes"| node_router
node_router -->|"resolves controllers"| node_container
node_router -->|"runs permissions"| node_middleware
node_router -->|"dispatches routes"| node_controller
node_controller -->|"resolves services"| node_container
node_auth_controller -->|"uses auth"| node_auth_service
node_auth_controller -->|"uses users"| node_user_service
node_auth_service -->|"checks WeChat"| node_wechat_service
node_user_component -->|"loads user data"| node_user_service
node_user_component -->|"uses auth"| node_auth_service
node_user_component -->|"references tokens"| node_session_tokens
node_user_service -->|"reads and writes"| node_wp_store
node_plugin -->|"resolves services"| node_container
node_component_manager -->|"manages components"| node_plugin
node_content -.->|"manages content"| node_wp_store
node_commerce -.->|"supports orders"| node_orders
node_orders -.->|"supports payments"| node_payments
node_wechat -.->|"integrates account"| node_wechat_service
node_queue -->|"implements contract"| node_queue_interface
node_queue -->|"selects backend"| node_database_queue
node_queue -->|"selects backend"| node_redis_queue
node_worker -->|"processes tasks"| node_queue
node_worker -.->|"executes jobs"| node_queue_jobs

click node_plugin "https://github.com/wangshai123/g3-web/blob/main/src/Components/Components.php"
click node_component_manager "https://github.com/wangshai123/g3-web/blob/main/src/Components/ComponentManager.php"
click node_container "https://github.com/wangshai123/g3-web/blob/main/src/Core/Container/Container.php"
click node_router "https://github.com/wangshai123/g3-web/blob/main/src/Core/Router/Router.php"
click node_controller "https://github.com/wangshai123/g3-web/tree/main/src/Controllers"
click node_middleware "https://github.com/wangshai123/g3-web/tree/main/src/Middleware"
click node_auth_controller "https://github.com/wangshai123/g3-web/blob/main/src/Controllers/AuthController.php"
click node_auth_service "https://github.com/wangshai123/g3-web/blob/main/src/Services/AuthService.php"
click node_user_component "https://github.com/wangshai123/g3-web/blob/main/src/Components/User/User.php"
click node_user_service "https://github.com/wangshai123/g3-web/blob/main/src/Services/UserService.php"
click node_session_tokens "https://github.com/wangshai123/g3-web/blob/main/src/Cache/SessionTokens.php"
click node_content "https://github.com/wangshai123/g3-web/tree/main/src/Components/Post"
click node_commerce "https://github.com/wangshai123/g3-web/tree/main/src/Components/Product"
click node_orders "https://github.com/wangshai123/g3-web/tree/main/src/Components/Orders"
click node_payments "https://github.com/wangshai123/g3-web/blob/main/src/Services/PaymentService.php"
click node_wechat "https://github.com/wangshai123/g3-web/tree/main/src/Components/WechatOA"
click node_queue "https://github.com/wangshai123/g3-web/blob/main/src/Core/Queue/Queue.php"
click node_queue_interface "https://github.com/wangshai123/g3-web/blob/main/src/Core/Queue/QueueInterface.php"
click node_database_queue "https://github.com/wangshai123/g3-web/blob/main/src/Core/Queue/DatabaseQueue.php"
click node_redis_queue "https://github.com/wangshai123/g3-web/blob/main/src/Core/Queue/RedisQueue.php"
click node_worker "https://github.com/wangshai123/g3-web/blob/main/bin/queue-worker.php"
click node_queue_jobs "https://github.com/wangshai123/g3-web/tree/main/src/Jobs"
click node_wechat_service "https://github.com/wangshai123/g3-web/blob/main/src/Services/WechatOAService.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_plugin,node_component_manager,node_container,node_wp toneBlue
class node_router,node_controller,node_middleware,node_wp_store toneAmber
class node_auth_controller,node_auth_service,node_user_component,node_user_service,node_session_tokens toneMint
class node_content,node_commerce,node_orders,node_payments,node_wechat,node_wechat_service toneRose
class node_queue,node_queue_interface,node_database_queue,node_redis_queue,node_worker,node_queue_jobs toneIndigo
```

## Components

### Plugin Runtime

- [Plugin Components](https://github.com/wangshai123/g3-web/blob/main/src/Components/Components.php): `src/Components/Components.php`
- [Component Loader](https://github.com/wangshai123/g3-web/blob/main/src/Components/ComponentManager.php): `src/Components/ComponentManager.php`
- [Dependency Container](https://github.com/wangshai123/g3-web/blob/main/src/Core/Container/Container.php): `src/Core/Container/Container.php`

### REST API

- [REST Router](https://github.com/wangshai123/g3-web/blob/main/src/Core/Router/Router.php): `src/Core/Router/Router.php`
- [API Controllers](https://github.com/wangshai123/g3-web/tree/main/src/Controllers): `src/Controllers`
- [API Middleware](https://github.com/wangshai123/g3-web/tree/main/src/Middleware): `src/Middleware`

### Users and Auth

- [Auth Endpoints](https://github.com/wangshai123/g3-web/blob/main/src/Controllers/AuthController.php): `src/Controllers/AuthController.php`
- [Authentication](https://github.com/wangshai123/g3-web/blob/main/src/Services/AuthService.php): `src/Services/AuthService.php`
- [User Features](https://github.com/wangshai123/g3-web/blob/main/src/Components/User/User.php): `src/Components/User/User.php`
- [User Service](https://github.com/wangshai123/g3-web/blob/main/src/Services/UserService.php): `src/Services/UserService.php`
- [Session Tokens](https://github.com/wangshai123/g3-web/blob/main/src/Cache/SessionTokens.php): `src/Cache/SessionTokens.php`

### Business Features

- [Content Features](https://github.com/wangshai123/g3-web/tree/main/src/Components/Post): `src/Components/Post`
- [Commerce Features](https://github.com/wangshai123/g3-web/tree/main/src/Components/Product): `src/Components/Product`
- [Order Features](https://github.com/wangshai123/g3-web/tree/main/src/Components/Orders): `src/Components/Orders`
- [Payment Services](https://github.com/wangshai123/g3-web/blob/main/src/Services/PaymentService.php): `src/Services/PaymentService.php`
- [WeChat Integration](https://github.com/wangshai123/g3-web/tree/main/src/Components/WechatOA): `src/Components/WechatOA`
- [WeChat Service](https://github.com/wangshai123/g3-web/blob/main/src/Services/WechatOAService.php): `src/Services/WechatOAService.php`

### Async Processing

- [Queue Coordinator](https://github.com/wangshai123/g3-web/blob/main/src/Core/Queue/Queue.php): `src/Core/Queue/Queue.php`
- [Queue Contract](https://github.com/wangshai123/g3-web/blob/main/src/Core/Queue/QueueInterface.php): `src/Core/Queue/QueueInterface.php`
- [Database Queue](https://github.com/wangshai123/g3-web/blob/main/src/Core/Queue/DatabaseQueue.php): `src/Core/Queue/DatabaseQueue.php`
- [Redis Queue](https://github.com/wangshai123/g3-web/blob/main/src/Core/Queue/RedisQueue.php): `src/Core/Queue/RedisQueue.php`
- [Queue Worker](https://github.com/wangshai123/g3-web/blob/main/bin/queue-worker.php): `bin/queue-worker.php`
- [Background Jobs](https://github.com/wangshai123/g3-web/tree/main/src/Jobs): `src/Jobs`

### Other components

- **WordPress Client**
- **WordPress Data**

## Connections

- WordPress Client → REST Router: requests routes (evidence: `README.md`)
- REST Router → Dependency Container: resolves controllers (evidence: `src/Core/Router/Router.php`)
- REST Router → API Middleware: runs permissions (evidence: `src/Core/Router/Router.php`)
- REST Router → API Controllers: dispatches routes (evidence: `src/Core/Router/Router.php`)
- API Controllers → Dependency Container: resolves services
- Auth Endpoints → Authentication: uses auth (evidence: `src/Controllers/AuthController.php`)
- Auth Endpoints → User Service: uses users (evidence: `src/Controllers/AuthController.php`)
- Authentication → WeChat Service: checks WeChat (evidence: `src/Services/AuthService.php`)
- User Features → User Service: loads user data (evidence: `src/Components/User/User.php`)
- User Features → Authentication: uses auth (evidence: `src/Components/User/User.php`)
- User Features → Session Tokens: references tokens (evidence: `src/Components/User/User.php`)
- User Service → WordPress Data: reads and writes (evidence: `src/Services/UserService.php`)
- Plugin Components → Dependency Container: resolves services (evidence: `src/Components/Components.php`)
- Component Loader → Plugin Components: manages components (evidence: `src/Components/ComponentManager.php`)
- Content Features → WordPress Data: manages content (evidence: `README.md`)
- Commerce Features → Order Features: supports orders (evidence: `README.md`)
- Order Features → Payment Services: supports payments (evidence: `README.md`)
- WeChat Integration → WeChat Service: integrates account (evidence: `README.md`)
- Queue Coordinator → Queue Contract: implements contract (evidence: `src/Core/Queue/Queue.php`)
- Queue Coordinator → Database Queue: selects backend (evidence: `src/Core/Queue/Queue.php`)
- Queue Coordinator → Redis Queue: selects backend (evidence: `src/Core/Queue/Queue.php`)
- Queue Worker → Queue Coordinator: processes tasks (evidence: `bin/queue-worker.php`)
- Queue Worker → Background Jobs: executes jobs
