# palaueb/pymesec-compliance-auditing-system architecture

> Architecture diagram of the GitHub repository palaueb/pymesec-compliance-auditing-system, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/palaueb/pymesec-compliance-auditing-system
- Repository: https://github.com/palaueb/pymesec-compliance-auditing-system

## Overview

#### Purpose and entry points
PymeSec is a modular SME compliance-auditing platform for security controls, risk, privacy, continuity, evidence, assessments, and regulatory frameworks. The main Laravel application is in `core/`; browser traffic enters through `core/public/index.php`, with product/workspace, administration, API, and console routes defined in `core/routes/web.php`, `core/routes/api.php`, and `core/routes/console.php`.

#### Runtime and deployment
The primary runtime is PHP 8.1+/Laravel 10, served locally through Dockerized Apache/PHP and MySQL. Docker composition and service configuration are rooted at `docker-compose.yml`, `docker/php/Dockerfile`, and `docker/nginx/default.conf`. Laravel uses configured database, filesystem, cache, queue, mail, plugin, and artifact adapters; local development defaults to file cache and synchronous queues. An optional LDAP service supports identity integration via `docker/ldap/Dockerfile`.

#### Core platform kernel
The core owns cross-domain platform concerns rather than most compliance business modules: plugin lifecycle, tenancy/scope context, authorization, identity-provider abstraction, navigation/UI registries, workflow, events, auditing, artifacts, notifications, and reference data. Dependency bindings and plugin bootstrapping are centralized in `core/app/Providers/AppServiceProvider.php` and `core/app/Providers/PluginServiceProvider.php`; application boot configuration is in `core/bootstrap/app.php`.

#### Request security and tenancy flow
HTTP requests resolve and canonicalize the authenticated principal, establish contextual membership/organization/scope, enforce permissions, then audit operations. The critical boundary middleware is `core/app/Http/Middleware/ResolveApiPrincipal.php`, `core/app/Http/Middleware/CanonicalizeAuthenticatedPrincipal.php`, and `core/app/Http/Middleware/AuthorizePermission.php`. Persistent organizations, scopes, memberships, and functional actors are introduced by migrations such as `core/database/migrations/2026_03_12_000010_create_organizations_table.php` and `core/database/migrations/2026_03_12_000030_create_memberships_table.php`.

#### Extensibility model
Plugins are independently packaged directories discovered from `plugins/`, declared through `plugin.json`, and enabled from environment configuration plus a private local state file. The core plugin manager validates manifests, dependencies, routes, menus, and lifecycle state through `core/src/Plugins/PluginDiscovery.php`, `core/src/Plugins/PluginManager.php`, and `core/src/Plugins/PluginLifecycleManager.php`. Plugins implement domain behavior and contribute routes/views/translation resources; examples include `plugins/risk-management/src/RiskManagementPlugin.php`, `plugins/controls-catalog/src/ControlsCatalogPlugin.php`, and `plugins/evidence-management/src/EvidenceManagementPlugin.php`.

#### Domain data, workflows, and traceability
Domain plugins generally expose repository-backed UI/API operations over shared MySQL tables. Core workflows persist instances and transitions through `core/src/Workflows/DatabaseWorkflowService.php` and migrations `core/database/migrations/2026_03_12_000100_create_workflow_instances_table.php` and `core/database/migrations/2026_03_12_000110_create_workflow_transitions_table.php`. Mutations can emit public events, create audit records, attach evidence artifacts, and notify users via `core/src/Events/DatabaseEventBus.php`, `core/src/Audit/DatabaseAuditTrail.php`, and `core/src/Artifacts/DatabaseArtifactService.php`.

#### Identity, external services, and integrations
Identity remains provider-agnostic in core and is supplied by plugins: local authentication is implemented by `plugins/identity-local/src/IdentityLocalAuthService.php`; LDAP synchronization/authentication by `plugins/identity-ldap/src/IdentityLdapService.php` and `plugins/identity-ldap/src/PhpLdapDirectoryGateway.php`. Outbound notifications use configured mail transport through `core/src/Notifications/OutboundNotificationMailer.php`. A separate Go MCP server exposes PymeSec to AI clients, with executable entry points at `mcp/cmd/pymesec-mcp/main.go` and smoke client at `mcp/cmd/pymesec-mcp-smoke/main.go`.

Main entry points: [`core/src/Plugins/PluginManager.php`](https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/core/src/Plugins/PluginManager.php) (Plugin lifecycle manager), [`plugins/risk-management/src/RiskManagementPlugin.php`](https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/plugins/risk-management/src/RiskManagementPlugin.php) (Compliance domain plugins), [`core/public/index.php`](https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/core/public/index.php) (HTTP entry point), [`core/app/Http/Middleware/ResolveApiPrincipal.php`](https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/core/app/Http/Middleware/ResolveApiPrincipal.php) (Principal, scope, authorization)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime"]
  node_browser(("Browser clients"))
  node_docker["Docker services<br/>deployment<br/>[docker-compose.yml]"]
  node_mysql[("MySQL<br/>primary database")]
end

subgraph group_core["Laravel Core"]
  node_http_entry["HTTP entry point<br/>Laravel front controller<br/>[index.php]"]
  node_routes["Product, admin, API routes<br/>route definitions<br/>[web.php]"]
  node_security_tenancy["Principal, scope, authorization<br/>middleware boundary"]
  node_kernel["Platform kernel<br/>service bindings"]
  node_plugin_provider["Plugin bootstrap<br/>service provider"]
  node_plugin_manager["Plugin lifecycle manager<br/>plugin runtime<br/>[PluginManager.php]"]
  node_workflow["Workflow service<br/>workflow persistence"]
  node_traceability["Audit, events, artifacts<br/>traceability services"]
  node_notifications["Outbound mail<br/>notification adapter"]
end

subgraph group_plugins["Plugin Domains"]
  node_domain_plugins["Compliance domain plugins<br/>plugin packages"]
  node_plugin_manifests["Plugin manifests<br/>plugin metadata<br/>[plugin.json]"]
  node_local_identity["Local identity provider<br/>identity plugin"]
  node_ldap_identity["LDAP identity provider<br/>identity plugin"]
end

subgraph group_integrations["Integrations"]
  node_ldap[("LDAP service<br/>directory service")]
  node_mcp_server{{"PymeSec MCP server<br/>Go AI integration<br/>[main.go]"}}
end

node_browser -->|"HTTP requests"| node_http_entry
node_docker -->|"serves"| node_http_entry
node_docker -->|"runs"| node_mysql
node_http_entry -->|"dispatches"| node_routes
node_routes -->|"middleware"| node_security_tenancy
node_security_tenancy -->|"uses platform services"| node_kernel
node_security_tenancy -->|"loads membership and scope"| node_mysql
node_kernel -->|"boots"| node_plugin_provider
node_plugin_provider -->|"initializes"| node_plugin_manager
node_plugin_manifests -->|"discovered and validated"| node_plugin_manager
node_plugin_manager -->|"enables and boots"| node_domain_plugins
node_plugin_manager -->|"loads provider"| node_local_identity
node_plugin_manager -->|"loads provider"| node_ldap_identity
node_domain_plugins -->|"runs workflows"| node_workflow
node_domain_plugins -->|"emits evidence and audit activity"| node_traceability
node_domain_plugins -->|"repository-backed data"| node_mysql
node_workflow -->|"instances and transitions"| node_mysql
node_traceability -->|"persists records"| node_mysql
node_traceability -.->|"triggers"| node_notifications
node_ldap_identity -->|"directory gateway"| node_ldap
node_mcp_server -->|"accesses platform"| node_http_entry

click node_docker "https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/docker-compose.yml"
click node_http_entry "https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/core/public/index.php"
click node_routes "https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/core/routes/web.php"
click node_security_tenancy "https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/core/app/Http/Middleware/ResolveApiPrincipal.php"
click node_kernel "https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/core/app/Providers/AppServiceProvider.php"
click node_plugin_provider "https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/core/app/Providers/PluginServiceProvider.php"
click node_plugin_manager "https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/core/src/Plugins/PluginManager.php"
click node_workflow "https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/core/src/Workflows/DatabaseWorkflowService.php"
click node_traceability "https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/core/src/Audit/DatabaseAuditTrail.php"
click node_notifications "https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/core/src/Notifications/OutboundNotificationMailer.php"
click node_domain_plugins "https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/plugins/risk-management/src/RiskManagementPlugin.php"
click node_plugin_manifests "https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/plugins/risk-management/plugin.json"
click node_local_identity "https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/plugins/identity-local/src/IdentityLocalAuthService.php"
click node_ldap_identity "https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/plugins/identity-ldap/src/IdentityLdapService.php"
click node_ldap "https://github.com/palaueb/pymesec-compliance-auditing-system/tree/main/docker/ldap/Dockerfile"
click node_mcp_server "https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/mcp/cmd/pymesec-mcp/main.go"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_browser,node_docker,node_mysql toneBlue
class node_http_entry,node_routes,node_security_tenancy,node_kernel,node_plugin_provider,node_plugin_manager,node_workflow,node_traceability,node_notifications toneAmber
class node_domain_plugins,node_plugin_manifests,node_local_identity,node_ldap_identity toneMint
class node_ldap,node_mcp_server toneRose
```

## Components

### Runtime

- **Browser clients**: client
- [Docker services](https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/docker-compose.yml): deployment · Apache/PHP, MySQL, and optional LDAP run locally. · `docker-compose.yml`
- **MySQL**: primary database · Stores organizations, memberships, domain data, workflows, and traceability records.

### Laravel Core

- [HTTP entry point](https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/core/public/index.php): Laravel front controller · `core/public/index.php`
- [Product, admin, API routes](https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/core/routes/web.php): route definitions · `core/routes/web.php`
- [Principal, scope, authorization](https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/core/app/Http/Middleware/ResolveApiPrincipal.php): middleware boundary · Resolves API principals and enforces permissions in contextual scope. · `core/app/Http/Middleware/ResolveApiPrincipal.php`
- [Platform kernel](https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/core/app/Providers/AppServiceProvider.php): service bindings · Centralizes tenancy, authorization, UI registries, adapters, and plugin bootstrapping. · `core/app/Providers/AppServiceProvider.php`
- [Plugin bootstrap](https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/core/app/Providers/PluginServiceProvider.php): service provider · `core/app/Providers/PluginServiceProvider.php`
- [Plugin lifecycle manager](https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/core/src/Plugins/PluginManager.php): plugin runtime · Discovers manifests, validates dependencies, and manages enabled lifecycle state. · `core/src/Plugins/PluginManager.php`
- [Workflow service](https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/core/src/Workflows/DatabaseWorkflowService.php): workflow persistence · Persists workflow instances and transitions. · `core/src/Workflows/DatabaseWorkflowService.php`
- [Audit, events, artifacts](https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/core/src/Audit/DatabaseAuditTrail.php): traceability services · Records mutations, publishes events, and manages evidence artifacts. · `core/src/Audit/DatabaseAuditTrail.php`
- [Outbound mail](https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/core/src/Notifications/OutboundNotificationMailer.php): notification adapter · `core/src/Notifications/OutboundNotificationMailer.php`

### Plugin Domains

- [Compliance domain plugins](https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/plugins/risk-management/src/RiskManagementPlugin.php): plugin packages · Risk, controls catalog, evidence management, and other compliance modules. · `plugins/risk-management/src/RiskManagementPlugin.php`
- [Plugin manifests](https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/plugins/risk-management/plugin.json): plugin metadata · Each package declares itself through plugin.json. · `plugins/risk-management/plugin.json`
- [Local identity provider](https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/plugins/identity-local/src/IdentityLocalAuthService.php): identity plugin · `plugins/identity-local/src/IdentityLocalAuthService.php`
- [LDAP identity provider](https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/plugins/identity-ldap/src/IdentityLdapService.php): identity plugin · Provides LDAP authentication and synchronization. · `plugins/identity-ldap/src/IdentityLdapService.php`

### Integrations

- [LDAP service](https://github.com/palaueb/pymesec-compliance-auditing-system/tree/main/docker/ldap/Dockerfile): directory service · `docker/ldap/Dockerfile`
- [PymeSec MCP server](https://github.com/palaueb/pymesec-compliance-auditing-system/blob/main/mcp/cmd/pymesec-mcp/main.go): Go AI integration · Exposes PymeSec capabilities to AI clients. · `mcp/cmd/pymesec-mcp/main.go`

## Connections

- Browser clients → HTTP entry point: HTTP requests
- Docker services → HTTP entry point: serves
- Docker services → MySQL: runs
- HTTP entry point → Product, admin, API routes: dispatches
- Product, admin, API routes → Principal, scope, authorization: middleware
- Principal, scope, authorization → Platform kernel: uses platform services
- Principal, scope, authorization → MySQL: loads membership and scope
- Platform kernel → Plugin bootstrap: boots
- Plugin bootstrap → Plugin lifecycle manager: initializes
- Plugin manifests → Plugin lifecycle manager: discovered and validated
- Plugin lifecycle manager → Compliance domain plugins: enables and boots
- Plugin lifecycle manager → Local identity provider: loads provider
- Plugin lifecycle manager → LDAP identity provider: loads provider
- Compliance domain plugins → Workflow service: runs workflows
- Compliance domain plugins → Audit, events, artifacts: emits evidence and audit activity
- Compliance domain plugins → MySQL: repository-backed data
- Workflow service → MySQL: instances and transitions
- Audit, events, artifacts → MySQL: persists records
- Audit, events, artifacts → Outbound mail: triggers
- LDAP identity provider → LDAP service: directory gateway
- PymeSec MCP server → HTTP entry point: accesses platform
