JekCMS is commercially licensed software, but several of its components are published under open-source licenses. The core routing engine, database abstraction layer, and template tag system are available on GitHub under the MIT license. The admin panel, theme marketplace, and licensing system are proprietary.
The routing engine (src/Router/) handles URL matching, parameter extraction, middleware chaining, and route compilation. It uses a compiled route cache stored in cache/routes.php to avoid regex matching on every request — on a site with 50 registered routes, this reduces routing overhead from approximately 0.8ms to under 0.1ms per request. The source is published at github.com/jekcms/router under the MIT license and accepts external contributions.
Database Abstraction: Close to PDO by Design
The database abstraction layer (src/Database/) is a thin wrapper around PDO. It adds named parameter binding, a query log for debugging, connection pool management, and a transaction helper. It does not attempt to be an ORM — queries are written in SQL. The design decision to stay close to PDO rather than adding an abstraction layer was intentional: SQL is readable, debuggable, and does not require learning a query builder syntax. The source is at github.com/jekcms/database.
Template Tag System: ~60 Functions, Stable API
The template tag system (src/TemplateTags/) provides the functions used in theme templates: get_post(), the_title(), get_categories(), get_partial(), and approximately 60 others. The function signatures and return types are documented in the public API reference and are guaranteed stable within a major version. Breaking changes to template tags require a new major version and a minimum six-month deprecation period. The source is at github.com/jekcms/template-tags.
What Remains Proprietary and Why
The admin panel, theme marketplace connector, and licensing system are proprietary and closed-source. Modifications to these components require a commercial agreement. The distinction is practical: the open-source components are the plumbing that any developer can build on; the proprietary components are the finished product that JekCMS sells. You can use the open-source components in your own projects under the MIT license without purchasing a JekCMS license.
Router: Architecture and Performance
The routing engine compiles registered routes into a single PHP file at cache/routes.php. This compiled file is a switch-case tree that avoids regex matching entirely for static routes. For dynamic routes with parameters (like /post/{slug}), the compiler generates optimized regex patterns grouped by HTTP procedure. On a site with 50 routes, the compiled router resolves a URL in under 0.1ms. Without compilation, the same resolution takes 0.8ms due to sequential regex matching.
Middleware Chaining
Middleware functions execute in order before the route handler. JekCMS's router supports both global middleware (applied to all routes) and route-specific middleware. Route groups allow shared prefix and middleware definitions; API endpoints are typically grouped with api_auth and json middleware. The middleware stack is resolved at compile time, so there is no per-request overhead for middleware resolution.
Database Layer: Query Logging and Transactions
The query log records every SQL query, its parameters, and execution time during a request. In development mode, the admin toolbar displays all queries with execution times, making it straightforward to identify N+1 query problems. The transaction helper automatically rolls back on exception:
$db->transaction(function($db) {
$db->insert('posts', ['title' => 'New Post', 'status' => 'draft']);
$postId = $db->lastInsertId();
$db->insert('post_meta', ['post_id' => $postId, 'key' => 'views', 'value' => 0]);
});
// Rolls back both inserts if either fails
Connection Pool Management
The database layer maintains a connection pool that reuses PDO connections across the request lifecycle. For sites running multiple database operations per request, this eliminates the overhead of establishing a new connection for each query. Connection pooling reduces total request time by 8-12ms on pages with 15+ queries.
Template Tags: Common Functions
The most frequently used template tags and their signatures:
get_post(int $id): ?arrayfetches a single post with all meta fieldsget_posts(array $args): arrayfetches posts matching criteria (status, category, tag, date range, limit)the_title(?int $id): stringreturns the escaped title of the current or specified postthe_content(?int $id): stringreturns rendered content with shortcodes processedget_categories(array $args): arrayreturns categories with optional hierarchyget_partial(string $name, array $data): stringrenders a template partial with passed dataget_setting(string $group, string $key): mixedretrieves a site setting valuesite_url(string $path): stringgenerates an absolute URL from a relative path
Contributing to the Open Source Components
External contributions are accepted through GitHub pull requests. The contribution guidelines require:
- All new functions must include PHPDoc annotations with parameter types and return types
- Unit tests are required for bug fixes (a failing test that proves the bug, then the fix)
- No breaking changes to existing function signatures within a major version
- Code style must pass PHP-CS-Fixer with the JekCMS ruleset
The most valuable contributions tend to be performance improvements with benchmarks, bug fixes with regression tests, and documentation improvements. Feature requests are discussed in GitHub Issues before implementation to ensure alignment with the design philosophy of staying close to PHP and PDO rather than adding abstraction layers.