Skip to main content

Modules & execution engine

Project overview​

apigo-cloud/
├── apigo-boot/ # Business modules parent project
│ ├── apigo-admin/ # Management and config module (port 9377)
│ ├── apigo-api/ # API execution module (open API entry)
│ ├── apigo-core/ # Execution engine core
│ ├── apigo-db-spi/ # Data source driver SPI
│ └── apigo-plugin/ # Data source extension plugins
├── apigo-gateway/ # Gateway service (port 9600)
├── apigo-common/ # Shared components
│ ├── apigo-common-auth/ # Authentication context and permission model
│ ├── apigo-common-log/ # Logging components
│ ├── apigo-common-redis/ # Redis cache components
│ └── apigo-common-base/ # Base utilities and constants
├── apigo-web/ # Frontend portal (port 7001)
└── db/ # Database scripts

Module responsibilities​

ModuleCore responsibilityKey classes
Frontend portal apigo-webProduct visualization and interaction orchestrationAPI Hub, Workbench, Service management, System management, AI query
Config center apigo-adminManage API definitions and rules, distribute configurationLoadingData, ApiRuntimeCacheService, RedisRouteService
Execution service apigo-apiOpen API HTTP adaptation and authenticationApiServiceController, AuthInterceptor, McpSkillController
Execution core apigo-coreGeneric execution engine and driver encapsulationApiRuntimeService, ApiModeExecutorRouter, SqlModeExecutor, ProxyModeExecutor, LayoutModeExecutor
Data source SPI apigo-db-spiData source driver interface definitionsDataSourceDriver, DataSourceManager
Data source plugins apigo-pluginData source driver implementationsJdbcDataSourceDriver, DefaultDataSourceDriver
Gateway apigo-gatewayTraffic admission and runtime governanceApiRouteDefinitionRepository, AuthFilter, CacheFilter, IPFilter, LogFilter, MockFilter, WafFilter

Execution engine: strategy pattern + router​

// Executor interface
public interface ApiModeExecutor {
boolean supports(ApiDetails apiDetails); // Whether the API type is supported
ApiRuntimeResult execute(ApiRuntimeContext context); // Execute the API
}

Three built-in executors:

ExecutorHandled typesDescription
SqlModeExecutorSQL / TABLE / SCRIPTExecutes SQL scripts with transaction, pagination and parameter binding support
ProxyModeExecutorPROXYHTTP proxy forwarding with raw byte stream passthrough
LayoutModeExecutorLAYOUTGraph-based orchestration (DAG), with multi-node serial, parallel and conditional execution

Unified runtime pipeline:

Key designs:

  • ThreadLocal context switching — when embedded API nodes in an orchestration are called recursively, the execution context is temporarily switched and restored after execution
  • Depth limit — prevents stack overflow caused by circular orchestration calls
  • rawBody passthrough — binary proxy responses skip JSON serialization and are written directly to the output stream

To add a new API type, simply implement ApiModeExecutor and register it as a Spring Bean; the router discovers it automatically.

Gateway filter chain​

OrderFilterResponsibility
-100LogFilterRequest logging, traceId generation, response body capture
-100MockFilterMock isolation /mock/{envCode}/**
-40WafFilterSQL injection / XSS / path traversal detection
-20AuthFilterOpen API authentication (strategy pattern)
-19JwtCredentialStripFilterStrips credentials and spoofable identity headers after JWT authentication to prevent token passthrough
-10IPFilterIP blacklist / whitelist
-1CacheFilterReturn directly on a cache hit
1ErrorFilterFallback for forwarding exceptions

Authentication strategies are collected automatically through Map<String, AuthService> injection:

StrategyBean nameDescription
AppKeyAuthServiceapp_keyCompares the X-AppKey header with the API's authorized app list
AppSecretAuthServiceapp_secretHMAC signature authentication (SM3 / HmacSHA256) with Redis SETNX replay protection
OAuth2AuthServiceoauth2OAuth2 client credentials; verifies the Bearer token and resolves the app from its claims
JwtBearerAuthServicejwtEnterprise IdP JWT: JWKS signature and claims validation, resolves the app by (jwtIdp, subject), and uses standard 401/403/503

Dynamic routing​

ApiRouteDefinitionRepository extends Spring Cloud Gateway's native Redis route repository:

  1. Loads all route definitions from Redis at startup
  2. Loads Sentinel flow control (GatewayFlowRule) and circuit breaking (DegradeRule) rules at the same time
  3. Listens for configuration changes through Redis Pub/Sub and incrementally refreshes routes and rules
  4. A periodic reconciliation task ensures that Redis stays consistent with the database

Shared components​

ComponentPurpose
apigo-common-authApiThreadLocal, ApiDetails, AppDetails authentication context
apigo-common-logBLog, BLogAspect log model and aspect
apigo-common-redisRedisService, RedisConfig cache utilities
apigo-common-baseBase utilities and constants