PolyCMS Architecture Overview
MVC Architecture
PolyCMS follows strict Model-View-Controller architecture built on CodeIgniter - the same framework powering Perfex CRM. This ensures seamless integration with the CRM's existing codebase and conventions.
File Structure
modules/polycms/
├── polycms.php # Main module bootstrap & hook entry point
├── install.php # Database installer (19 tables) & defaults
├── uninstall.php # Module uninstaller & cleanup script
├── config/
│ ├── my_routes.php # Dynamic routing engine with blog prefix rules
│ └── csrf_exclude_uris.php # REST API CSRF exclusion rules
├── controllers/ # MVC Controllers
│ ├── Admin.php # PolyCMS admin dashboard & stats
│ ├── Api.php # Comprehensive REST API controller
│ ├── Api_explorer.php # Interactive API Explorer sandbox
│ ├── Banner_slider.php # Banner Slider admin controller
│ ├── Categories.php # Hierarchical Category tree CRUD
│ ├── Comments.php # Comment moderation controller
│ ├── Frontend.php # Public frontend renderer (Single, Archive, Pages, Search, RSS)
│ ├── Media.php # Media Library manager & WebP uploader
│ ├── Menus.php # Drag-and-drop Navigation Menu Builder
│ ├── Mtbuilder.php # MTBuilder Visual Page Builder controller
│ ├── Pages.php # Static CMS Pages CRUD & template manager
│ ├── Permalink_settings.php # Permalink structures & 301 redirection manager
│ ├── Plugins.php # Plugin management (ZIP install, activate, settings)
│ ├── Posts.php # Blog Post CRUD, TinyMCE, SEO, scheduled publishing
│ ├── Settings.php # Core CMS settings (General, Reading, SEO, Discussion)
│ ├── Tags.php # Post tags CRUD & usage metrics
│ ├── Theme_options.php # Live Theme Customizer & options storage
│ ├── Themes.php # Theme management (ZIP install, switcher)
│ ├── Tools.php # WXR/JSON Import/Export, DB backup/restore, Demo generator
│ └── Widgets.php # Drag-and-drop Widget Area manager
├── models/ # Database Models (Active Record)
│ ├── Blog_post_model.php # Posts DB queries, pagination, search, filters
│ ├── Blog_category_model.php # Categories hierarchy tree model
│ ├── Blog_tag_model.php # Tags taxonomy & cloud generator model
│ ├── Blog_comment_model.php # Comments nested threading model
│ ├── Blog_page_model.php # Pages model & custom fields
│ ├── Blog_menu_model.php # Menus & nested item reordering model
│ ├── Blog_plugin_model.php # Plugins status & options model
│ ├── Blog_theme_model.php # Themes status & headers model
│ ├── Blog_widget_model.php # Widgets & area instances model
│ └── Blog_media_model.php # Media dimensions, mime types & file sync model
├── libraries/ # Service Libraries
│ ├── Blog_hooks.php # WordPress-style Action & Filter hook engine
│ ├── Blog_plugin_loader.php # Plugin header parser & security scanner
│ ├── Blog_theme_loader.php # Theme header parser & template hierarchy
│ ├── Blog_shortcode.php # Shortcode registry & recursive parser
│ ├── Blog_widget.php # Widget base class & area registry
│ ├── Polycms_Asset_Manager.php # Asset enqueue manager for CSS/JS
│ ├── Polycms_Integration.php # Perfex CRM core integration & homepage router
│ └── Polycms_Rate_Limiter.php # IP-based rate limiter library
├── plugins/ # 7 Built-in Plugins
│ ├── mtbuilder/ # MT Studio Visual Page Builder
│ ├── mtoptimize/ # Performance, Minification & Cache Optimizer
│ ├── banner-slider/ # Responsive Hero Banner Slider
│ ├── api-explorer/ # Interactive REST API Explorer Sandbox
│ ├── google-analytics/ # Google Analytics GA4 / GTM Tracking
│ ├── maintenance-mode/ # Frontend Maintenance & Coming Soon Mode
│ └── xml-sitemap/ # Automatic XML Sitemap Generator
├── themes/ # Themes Ecosystem
│ └── head-random/ # Head Random Production Theme
├── widgets/ # 9 Built-in Widget Classes
└── shortcodes/ # 3 Built-in Shortcode Handlers
Database Schema (19 Relational Tables)
PolyCMS creates 19 dedicated tables, all prefixed with your Perfex CRM table prefix + blog_:
| Group | Tables | Count |
|---|---|---|
| Content | blog_posts, blog_pages, blog_page_meta | 3 |
| Taxonomy | blog_categories, blog_tags, blog_post_categories, blog_post_tags, blog_post_meta | 5 |
| Engagement | blog_comments | 1 |
| Media | blog_media | 1 |
| Navigation | blog_menus, blog_menu_items, blog_widgets | 3 |
| Extensions | blog_plugins, blog_plugin_options, blog_themes, blog_theme_options | 4 |
| Configuration | blog_settings, blog_permalink_settings | 2 |
All tables use proper foreign key constraints and InnoDB indexes for optimal query performance. CMS data is completely isolated from CRM client data.
Request Lifecycle
Admin Requests
- Perfex CRM routes request to PolyCMS controller.
- Controller validates
staff_can()permissions. - Controller calls Model for database operations.
- Model returns data via CodeIgniter Active Record.
- Controller loads admin View with data.
Frontend Requests
- Dynamic routing system matches URL against permalink patterns.
Frontend.phpcontroller determines content type (post, page, category, tag, search, archive).- Hooks fire:
polycms_frontend_init,polycms_head. Blog_theme_loaderresolves template hierarchy -> selects appropriate theme template.- Template renders with data, widgets, and shortcodes processed.
- Hooks fire:
polycms_footer.
Plugin System Architecture
Plugins are loaded by the Blog_plugin_loader during module initialization:
- Scan
plugins/directory forplugin.jsonmanifests. - Check activation status in
blog_pluginstable. - Load active plugin main files.
- Plugins register hooks via
polycms_add_action()andpolycms_add_filter(). - Hooks fire at appropriate lifecycle points during request processing.
Theme System Architecture
The Blog_theme_loader handles template resolution:
- Check active theme in
blog_themestable. - Determine content type from current request.
- Walk template hierarchy:
single.php->category.php->tag.php->page.php->index.php. - Load first matching template file from active theme directory.
- Pass content data, widgets, and theme options to template scope.
Security Architecture
- Permission Layer - All admin actions gated by
staff_can('polycms', ...). - XSS Protection - HTMLPurifier sanitizes all rich-text content.
- SQL Protection - CodeIgniter Active Record / Query Builder prevents injection.
- File Protection -
polycms_validate_file_pathprevents directory traversal. - Rate Limiting - IP-based cache limiter on public endpoints.
- BASEPATH Guard - Every PHP file includes
defined('BASEPATH') or exit().
Related Documentation
- Hooks & Filters Reference - Complete hook API documentation.
- Building a Custom Plugin - Plugin development guide with sample code.
- Building a Custom Theme - Theme development guide with template hierarchy.
- Template Tags & Helpers - Available helper functions for themes and plugins.
Launch Your CMS for Perfex CRM — Lifetime Access for Just $19
Create blogs, pages, themes, plugins, and manage everything from one powerful unified admin panel.
Early Adopter Advantage
Current pricing reflects the module’s present feature set. As additional plugins, themes, multilingual capabilities, builders (MTBuilder), and ecosystem integrations are released, pricing may be adjusted. Early customers secure today’s price while benefiting from future updates.