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
| Module | Core responsibility | Key classes |
|---|---|---|
| Frontend portal apigo-web | Product visualization and interaction orchestration | API Hub, Workbench, Service management, System management, AI query |
| Config center apigo-admin | Manage API definitions and rules, distribute configuration | LoadingData, ApiRuntimeCacheService, RedisRouteService |
| Execution service apigo-api | Open API HTTP adaptation and authentication | ApiServiceController, AuthInterceptor, McpSkillController |
| Execution core apigo-core | Generic execution engine and driver encapsulation | ApiRuntimeService, ApiModeExecutorRouter, SqlModeExecutor, ProxyModeExecutor, LayoutModeExecutor |
| Data source SPI apigo-db-spi | Data source driver interface definitions | DataSourceDriver, DataSourceManager |
| Data source plugins apigo-plugin | Data source driver implementations | JdbcDataSourceDriver, DefaultDataSourceDriver |
| Gateway apigo-gateway | Traffic admission and runtime governance | ApiRouteDefinitionRepository, 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:
| Executor | Handled types | Description |
|---|---|---|
SqlModeExecutor | SQL / TABLE / SCRIPT | Executes SQL scripts with transaction, pagination and parameter binding support |
ProxyModeExecutor | PROXY | HTTP proxy forwarding with raw byte stream passthrough |
LayoutModeExecutor | LAYOUT | Graph-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
| Order | Filter | Responsibility |
|---|---|---|
| -100 | LogFilter | Request logging, traceId generation, response body capture |
| -100 | MockFilter | Mock isolation /mock/{envCode}/** |
| -40 | WafFilter | SQL injection / XSS / path traversal detection |
| -20 | AuthFilter | Open API authentication (strategy pattern) |
| -19 | JwtCredentialStripFilter | Strips credentials and spoofable identity headers after JWT authentication to prevent token passthrough |
| -10 | IPFilter | IP blacklist / whitelist |
| -1 | CacheFilter | Return directly on a cache hit |
| 1 | ErrorFilter | Fallback for forwarding exceptions |
Authentication strategies are collected automatically through Map<String, AuthService> injection:
| Strategy | Bean name | Description |
|---|---|---|
AppKeyAuthService | app_key | Compares the X-AppKey header with the API's authorized app list |
AppSecretAuthService | app_secret | HMAC signature authentication (SM3 / HmacSHA256) with Redis SETNX replay protection |
OAuth2AuthService | oauth2 | OAuth2 client credentials; verifies the Bearer token and resolves the app from its claims |
JwtBearerAuthService | jwt | Enterprise 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:
- Loads all route definitions from Redis at startup
- Loads Sentinel flow control (
GatewayFlowRule) and circuit breaking (DegradeRule) rules at the same time - Listens for configuration changes through Redis Pub/Sub and incrementally refreshes routes and rules
- A periodic reconciliation task ensures that Redis stays consistent with the database
Shared components
| Component | Purpose |
|---|---|
| apigo-common-auth | ApiThreadLocal, ApiDetails, AppDetails authentication context |
| apigo-common-log | BLog, BLogAspect log model and aspect |
| apigo-common-redis | RedisService, RedisConfig cache utilities |
| apigo-common-base | Base utilities and constants |