Skip to content

Architecture

Pedro de Carvalho edited this page Jul 29, 2026 · 1 revision

Architecture

Saltus Framework follows a service-oriented architecture with a dependency injection container at its core. The framework bootstraps through the Core class, which registers all services, routes, and tool providers.

Core (Plugin interface)
  |
  |- ServiceContainer (DI container)
  |    |- Registers 10 feature services
  |    |- Two-pass registration: unconditional for routes/tools,
  |    |   gated via is_needed() for hooks/assets
  |
  |- Modeler (RestRouteProvider + ToolContributor)
  |    |- Scans {project}/src/models/ for config files
  |    |- Creates PostType or Taxonomy instances via ModelFactory
  |    |- Exposes get_models(), REST routes, and MCP tools
  |
  |- RestServer
  |    |- Registers 11 REST routes in saltus-framework/v1/
  |    |- Uses ModelRestPolicy + CapabilityPolicy for gating
  |
  |- MCP/Abilities
       |- 18 MCP tools registered as saltus/* abilities
       |- Middleware pipeline (permission, validation, audit, cache, rate-limit)
       |- Backed by REST controllers

Key Components

Core (src/Core.php)

The main entry point. Initializes the service container, registers all services, and hooks into WordPress's init action.

Modeler (src/Modeler.php)

Loads model configuration files from the project's src/models/ directory and registers them as WordPress post types and taxonomies.

Service Container (src/Infrastructure/Container/)

A PSR-11-compatible dependency injection container with support for:

  • Service registration and resolution
  • Conditional service loading via is_needed()
  • Factory-based instantiation
  • Assembly-based wiring

REST API (src/Rest/)

Eleven REST controllers registered under the saltus-framework/v1/ namespace, covering models, posts, settings, meta, and more.

MCP/Abilities (src/MCP/)

WordPress-native MCP/Abilities integration exposing 18 tools through a middleware pipeline with caching, rate limiting, audit logging, and permission gating.

Two-Pass Service Registration

REST route providers and MCP tool contributors are registered unconditionally during plugin boot to ensure endpoints appear in the WordPress REST index. All other services (admin screens, scripts, frontend hooks) are gated behind is_needed() to avoid loading unnecessary code.

Middleware Pipeline

Permission, validation, error formatting, audit, cache, and rate-limit logic each exist in exactly one place — a composable middleware pipeline shared by both REST and MCP paths.

Registered Services

Service Class Description
admin_cols AdminCols Custom admin list table columns
admin_filters AdminFilters Admin list table filter dropdowns
draganddrop DragAndDrop Drag-and-drop post reordering
duplicate Duplicate One-click post duplication
meta Meta Codestar-powered metaboxes
mcp MCP MCP/Abilities tools registration
quick_edit QuickEdit Quick edit custom fields
remember_tabs RememberTabs Tab state persistence
settings Settings Codestar-powered settings pages
single_export SingleExport Single-post WXR export

Key Decisions

  • Codestar Framework: Used for metaboxes and settings pages. Custom patches maintained in lib/codestar-framework/patches/.
  • SoberWP/Models: Simplified version included for declarative CPT/taxonomy registration via PHP/JSON/YAML config files.
  • Composer Classmap: Legacy libraries use classmap autoloading. Run composer dump-autoload when adding new classes to mapped directories.
  • GitHub Updater: Native support for afragen/github-updater for plugin updates from GitHub.

Clone this wiki locally