Data Builder v2.5.0 is the first production Perfex CRM module to ship a zero-coupling IgniteCore Dual-Mode layer inside modules/data_builder/ignite/. By adding a PSR-4 Modules\DataBuilder\Ignite namespace alongside its existing CodeIgniter 3 REST API v1, GraphQL, and MCP controllers, Data Builder delivers five CodeIgniter 4.7.6 endpoints with timing-safe SHA-256 Bearer auth, optional same-site Admin SSO, and a 1-click Strangler Fig switch while keeping 100% compatibility for sites without IgniteCore.
Side-by-Side Architecture: CI3 API v1 vs. CI4 Dual-Mode Layer
In standard Perfex CRM execution, every incoming API request to modules/data_builder/controllers/Db_resources.php passes through Perfex's root CodeIgniter 3.1.11 bootstrap. That bootstrap initializes 47 autoloaded helpers, 10 core libraries, 4 models, and all active third-party module hooks before Db_api_base::_init_api() loads 13 files across libraries/api/ and app_object_cache.
By contrast, modules/data_builder/ignite/ runs only when IgniteCore's Pre-Boot Front-Dispatcher matches one of its registered routes in route_manifest.php:
modules/data_builder/
├── config/
│ └── my_routes.php # Existing CI3 v1, GraphQL, MCP, Batch, Embed & Admin routes
├── controllers/
│ ├── Db_api_base.php # CI3 6-stage API middleware pipeline
│ └── Db_resources.php # CI3 REST API v1 handler (including auth_test())
└── ignite/ # Zero-coupling Dual-Mode CI4 layer
├── manifest.php # Declares 5 toggleable route_entries (v2 + opt-in v1)
├── Config/
│ └── Routes.php # CI4 RouteCollection mapped to ApiV2Controller
├── Controllers/
│ └── ApiV2Controller.php # Extends IgniteCore\Controllers\BaseApiController
├── Filters/
│ └── DataBuilderTokenFilter.php# Hybrid SHA-256 Bearer + Same-Site Admin SSO filter
└── Support/
└── DataBuilderAuthContext.php# Request-scoped token & authMode holder
If IgniteCore is not installed, deactivated, or switched to Safe Mode, Perfex CRM never loads modules/data_builder/ignite/. All existing api/v1/*, GraphQL, MCP, Batch, and reporting endpoints continue running natively on CodeIgniter 3.
The 5 Dual-Mode Routes in modules/data_builder/ignite/manifest.php
Data Builder exposes four net-new /api/v2/data_builder/* endpoints enabled by default plus one opt-in Strangler Fig accelerator over its legacy /api/v1/auth/test route:
| Route Key | HTTP & URI | Type | Priority | Default | Filter & Handler |
|---|---|---|---|---|---|
api_v2_status |
GET /api/v2/data_builder/status |
exact |
50 |
true |
apiAuth -> ApiV2Controller::status |
api_v2_auth_test |
GET /api/v2/data_builder/auth/test |
exact |
55 |
true |
[DataBuilderTokenFilter::class, 'apiAuth'] -> ApiV2Controller::authTest |
api_v2_resources |
GET /api/v2/data_builder/resources |
exact |
60 |
true |
[DataBuilderTokenFilter::class, 'apiAuth'] -> ApiV2Controller::resources |
api_v2_reports |
GET /api/v2/data_builder/reports |
exact |
65 |
true |
[DataBuilderTokenFilter::class, 'apiAuth'] -> ApiV2Controller::reports |
api_v1_auth_test_accel |
GET /api/v1/auth/test |
exact |
70 |
false |
[DataBuilderTokenFilter::class, 'apiAuth'] -> ApiV2Controller::authTest |
Each response from ApiV2Controller uses BaseApiController::apiSuccess() wrapped in respondData(), appending X-DataBuilder-Engine: IgniteCore-CI4, X-IgniteCore-Kernel: CI4-4.7.6, execution_ms, and ci_version telemetry.
What Each Endpoint Delivers
GET /api/v2/data_builder/status: Uses the statelessapiAuthfilter (closing any PHP session immediately) and queriesDatabase::connect()to verifypolydb_viewsanddata_builder_api_tokenstable readiness alongsideresources_count(13core resources).GET /api/v2/data_builder/auth/test: Returnsauthenticated: true,auth_mode(bearer_tokenoradmin_session),token_name,scopes, andtables_countfor instant connection validation in automation tools.GET /api/v2/data_builder/resources: Filters Data Builder's 13CORE_RESOURCES(clients,invoices,leads,projects,tasks,estimates,proposals,expenses,contracts,tickets,staff,payments,credit_notes) againstPerfexConfigBridge::dbPrefix()and the token'sallowed_tablesallowlist.GET /api/v2/data_builder/reports: Queries published reports (status = 1) frompolydb_viewsand enforces integerallowed_viewsscoping when restricted on the API token.
Hybrid Authentication: DataBuilderTokenFilter & DataBuilderAuthContext
To keep CI4 endpoints 100% consistent with Data Builder's existing token rules in data_builder_api_tokens and in-app API Explorer testing, Modules\DataBuilder\Ignite\Filters\DataBuilderTokenFilter implements a two-path verification flow and stores the resolved identity in DataBuilderAuthContext (resetting state at the top of before()):
DataBuilderAuthContext::reset();
$rawToken = $this->extractBearerToken();
if ($rawToken !== '') {
$tokenRow = $this->validateBearerToken($rawToken);
if ($tokenRow === null) {
return $this->problem(401, 'invalid-token', 'Unauthorized', 'Token is invalid, expired, or revoked.');
}
if (!$this->isIpAllowed($tokenRow, (string) ($_SERVER['REMOTE_ADDR'] ?? ''))) {
return $this->problem(403, 'ip-not-allowed', 'Forbidden', 'Client IP address is not in the token IP allowlist.');
}
$this->touchToken((int) $tokenRow->id);
DataBuilderAuthContext::set($tokenRow, 'bearer_token');
return null;
}
Path 1: Timing-Safe SHA-256 Bearer Token Validation
- Multi-SAPI header extraction: Reads
Authorization: Bearer {token}fromHTTP_AUTHORIZATION,REDIRECT_HTTP_AUTHORIZATION(Apache CGI/FastCGI), orgetallheaders(). - SHA-256 lookup +
hash_equals(): Computeshash('sha256', $rawToken), queriesdata_builder_api_tokensbytoken_hash, and confirms parity with timing-safehash_equals(). - Lifecycle, IP, and JSON scope decoding: Verifies
is_active === 1, checksexpires_at, enforcesip_whitelistagainstREMOTE_ADDR, decodesscopes,allowed_tables,allowed_views,ip_whitelist, anddomain_whitelist, and recordslast_used_at.
Path 2: Same-Site Admin Staff SSO Fallback
When no Bearer token is supplied, DataBuilderTokenFilter checks service('perfexOptions')->get('data_builder_settings', '') via isAdminSessionAllowed() for an enabled admin_session setting. If enabled, it calls service('perfexAuth')->staff(), closes the PHP session lock immediately (session_write_close()), and verifies both $staff->admin === 1 and isSameSiteRequest() (matching HTTP_REFERER, HTTP_ORIGIN, XMLHttpRequest, or Sec-Fetch-Site against PerfexConfigBridge::baseUrl()).
When verified, DataBuilderAuthContext::set() grants full read scopes (['tables', 'views', 'graphql', 'read']) under auth_mode = 'admin_session'. Any failed request returns an RFC 9457 application/problem+json response (urn:data-builder:problem:missing-token, invalid-token, or ip-not-allowed) with X-DataBuilder-Engine: IgniteCore-CI4 and no-store cache headers.
1-Click Strangler Fig Acceleration on /api/v1/auth/test
In modules/data_builder/config/my_routes.php, Data Builder defines its legacy connection check:
$route['api/v1/auth/test'] = 'data_builder/db_resources/auth_test';
In modules/data_builder/ignite/manifest.php, the api_v1_auth_test_accel entry declares the exact same URI with 'default' => false:
[
'key' => 'api_v1_auth_test_accel',
'methods' => ['GET'],
'type' => 'exact',
'match' => 'api/v1/auth/test',
'default' => false,
'priority' => 70,
'label' => 'Optional CI4 Accelerator for Legacy /api/v1/auth/test',
],
When IgniteCore compiles the manifest, Ignite_core_manifest_builder::detectLegacyRouteOverlaps() detects that api/v1/auth/test overlaps data_builder/config/my_routes.php and flags the notice cleanly in Setup > IgniteCore > Modules & Routes. Because default is false, GET /api/v1/auth/test stays on CI3 Db_resources::auth_test() until an administrator flips the toggle switch ON. Once flipped, IgniteCore updates tblignite_core_route_toggles, invalidates OPcache on route_manifest.php, and serves /api/v1/auth/test directly through ApiV2Controller::authTest() on CodeIgniter 4.7.6 - and can revert to CI3 with one click if needed.
Live Benchmarking and Why Zero Coupling Matters
Inside Setup > IgniteCore > Diagnostics & Guard, Ignite_core_diagnostics_suite enables live apples-to-apples comparisons between Perfex CI3 and IgniteCore CI4 on the site's actual PHP and MySQL stack:
- Kernel micro-benchmark: Runs the identical workload (DB
SELECT 1,companynameoption lookup, active Staff resolution, and 50-record SHA-256 JSON serialization) across CI3 (/admin/ignite_core/bench_ci3) and CI4 (/admin/ignite_core/bench_ci4), measuringserver_exec_ms,db_query_ms,memory_usage_mb,memory_peak_mb,loaded_files_count, and OPcache status. - Dynamic module endpoint targets: Automatically discovers
GET /api/v2/data_builder/statusalongside any module-declaredbenchmark_ci3_targetsinignite/manifest.php. - Self-reported API latency: Every
ApiV2Controllerresponse includesmeta.execution_ms(ordata.execution_mson/statusand/auth/test) and avoids loading CI3's 47 global helpers and session locks on stateless API requests.
Most importantly, Data Builder's architecture proves that Dual-Mode adoption never splits a product codebase into two incompatible editions. One single data_builder.zip serves customers running pure CI3 and customers running IgniteCore CI4 side by side.
Frequently Asked Questions
Does enabling api_v1_auth_test_accel break existing Zapier, Make.com, or n8n integrations?
No. ApiV2Controller::authTest() accepts the exact same Authorization: Bearer {token} credentials from data_builder_api_tokens, enforces IP allowlists and expiration dates identically, and returns authenticated, token_name, scopes, tables_count, and server_time in the JSON data envelope.
How does DataBuilderTokenFilter protect against timing attacks and session locking?
Token hashes are stored as SHA-256 digests and verified with PHP's constant-time hash_equals(). For Bearer token requests, PHP sessions are never opened; when using same-site Admin SSO, DataBuilderTokenFilter calls session_write_close() right after reading service('perfexAuth')->staff().
Can I restrict a token's access on the CI4 /api/v2/data_builder/* endpoints?
Yes. ApiV2Controller::resources() checks each table against allowed_tables (prefixed with PerfexConfigBridge::dbPrefix()), and ApiV2Controller::reports() filters polydb_views rows using the token's allowed_views ID array.
What happens if a customer installs Data Builder without IgniteCore?
Data Builder operates 100% natively on Perfex CRM's CodeIgniter 3 runtime. The modules/data_builder/ignite/ directory sits inert on disk with zero runtime overhead until IgniteCore is installed and activated.
Related Guides
- IgniteCore for Perfex CRM - Product Overview - Explore the Pre-Boot Front-Dispatcher, 5-layer Circuit Breaker, and Compatibility Guard.
- Data Builder for Perfex CRM - Visual Reporting, REST API & GraphQL - Full documentation for Data Builder REST API v1, GraphQL, MCP Server, and Embed Reports.
- Build Dual-Mode CodeIgniter 4 Modules for Perfex CRM with IgniteCore SDK - Step-by-step developer guide covering
manifest.phpschema v1, Base Controllers, Shared Bridges, Filters, and Spark CLI.
Need a Custom Perfex CRM Module, Bug Fix, or CodeIgniter 4 Upgrade?
Avoid broken updates, PHP 8.2-8.4 errors, and risky core edits. HeadRandom provides custom Perfex CRM module development, upgrade, and bug-fixing services for any third-party or custom module on your Perfex CRM installation, plus upgrading Perfex CRM from CodeIgniter 3 to CodeIgniter 4 via IgniteCore for Perfex CRM.
Develop new custom modules from scratch, patch bugs or hook conflicts on existing client modules, and update legacy code for clean PHP 8.2-8.4 compatibility with zero core file hacks. View Perfex CRM module development scope.
Migrate your Perfex CRM runtime to CodeIgniter 4 (4.7.6) using IgniteCore for Perfex CRM (independent module by HeadRandom) with Dual-Mode CI3 fallback, 32% to 75% lower latency, 50% less RAM, and custom CI4 porting for third-party modules. See CI3 to CI4 upgrade options.
Combine 2+ HeadRandom services (Custom Module, IgniteCore CI4 Upgrade, or Website Care) to save 30% automatically.