# oshantheanalyst/pdpa-monitor-compliance-system architecture

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

- Interactive diagram: https://gitdiagram.com/oshantheanalyst/pdpa-monitor-compliance-system
- Repository: https://github.com/oshantheanalyst/pdpa-monitor-compliance-system

## Overview

This is a PDPA-aware security-posture monitoring prototype: CRM staff record customer-data collection and retrieval, which App A reports to App B for audit logging, rule and ML scoring, alerts, and governance reporting. App B also offers role-specific administration, regulator views, scheduled rule checks, and report exports. The source excerpts show the CRM event flow and App B’s synchronous event processing; the README documents the separate ML service and broader product capabilities. Some unsampled subsystem links are therefore omitted or shown as unverified.

Main entry points: [`app-b-compliance/app/Http/Controllers/Api/V1/EventController.php`](https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-b-compliance/app/Http/Controllers/Api/V1/EventController.php) (Event API), [`app-a-crm/app/Http/Controllers/CustomerController.php`](https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-a-crm/app/Http/Controllers/CustomerController.php) (Customer Workflow), [`app-b-compliance/app/Services/ReportExportService.php`](https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-b-compliance/app/Services/ReportExportService.php) (Report Exports), [`app-b-compliance/app/Http/Livewire`](https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/tree/main/app-b-compliance/app/Http/Livewire) (Role Dashboards)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_crm["Demo CRM"]
  node_crm_customers["Customer Workflow"]
  node_crm_records[("Customer Records<br/>[Customer.php]")]
  node_crm_retrievals[("Retrieval History")]
  node_crm_compliance["Compliance Client"]
end

subgraph group_monitoring["Compliance Monitoring"]
  node_event_api["Event API"]
  node_audit_logs[("Audit Ledger<br/>[AuditLog.php]")]
  node_organizations[("Organizations<br/>[Organization.php]")]
  node_rule_engine["Event Rule Engine<br/>[RuleEngine.php]"]
  node_rule_sets["PDPA Rules"]
  node_alerts[("Alerts<br/>[Alert.php]")]
  node_scheduled_rules["Scheduled Checks"]
  node_escalation["Alert Escalation"]
end

subgraph group_governance["Governance &amp; Reporting"]
  node_role_dashboards["Role Dashboards"]
  node_org_management["Organization Management"]
  node_report_controller["Report Requests"]
  node_report_service["Report Exports"]
  node_compliance_score["Posture Score"]
  node_breach_dsr_dpia[("Breach, DSR &amp; DPIA")]
end

subgraph group_ml["ML Scoring"]
  node_ml_scorer["ML Scorer Client"]
  node_ml_service["Anomaly Scoring API<br/>[main.py]"]
end

node_staff(("CRM Staff"))
node_org_admin(("Organization Admin"))
node_platform_admin(("Platform Admin"))
node_regulator(("Regulator"))

node_staff -->|"records data"| node_crm_customers
node_crm_customers -->|"stores customer"| node_crm_records
node_crm_customers -->|"logs retrieval"| node_crm_retrievals
node_crm_customers -->|"sends events"| node_crm_compliance
node_crm_compliance -->|"posts events"| node_event_api
node_event_api -->|"writes events"| node_audit_logs
node_event_api -->|"resolves tenant"| node_organizations
node_event_api -->|"evaluates rules"| node_rule_engine
node_rule_engine -->|"evaluates rules"| node_rule_sets
node_rule_engine -->|"persists alerts"| node_alerts
node_event_api -->|"requests scoring"| node_ml_scorer
node_ml_scorer -->|"requests anomaly score"| node_ml_service
node_scheduled_rules -.->|"raises scheduled alerts"| node_alerts
node_scheduled_rules -.->|"checks events"| node_audit_logs
node_escalation -.->|"escalates alerts"| node_alerts
node_org_admin -->|"reviews posture"| node_role_dashboards
node_platform_admin -->|"manages platform"| node_role_dashboards
node_regulator -->|"reviews compliance"| node_role_dashboards
node_platform_admin -->|"manages organizations"| node_org_management
node_org_admin -->|"requests reports"| node_report_controller
node_regulator -->|"requests reports"| node_report_controller
node_report_controller -->|"exports reports"| node_report_service
node_report_service -->|"queries audit trail"| node_audit_logs
node_report_service -->|"queries alerts"| node_alerts
node_organizations -->|"calculates score"| node_compliance_score
node_report_service -->|"uses posture score"| node_compliance_score
node_role_dashboards -.->|"tracks obligations"| node_breach_dsr_dpia

click node_crm_customers "https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-a-crm/app/Http/Controllers/CustomerController.php"
click node_crm_records "https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-a-crm/app/Models/Customer.php"
click node_crm_retrievals "https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-a-crm/app/Models/CustomerRetrieval.php"
click node_crm_compliance "https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-a-crm/app/Services/ComplianceApiService.php"
click node_event_api "https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-b-compliance/app/Http/Controllers/Api/V1/EventController.php"
click node_audit_logs "https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-b-compliance/app/Models/AuditLog.php"
click node_organizations "https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-b-compliance/app/Models/Organization.php"
click node_rule_engine "https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-b-compliance/app/Services/RuleEngine/RuleEngine.php"
click node_rule_sets "https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/tree/main/app-b-compliance/app/Services/RuleEngine/Rules"
click node_alerts "https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-b-compliance/app/Models/Alert.php"
click node_scheduled_rules "https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-b-compliance/app/Console/Commands/RunScheduledRules.php"
click node_escalation "https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-b-compliance/app/Services/EscalationService.php"
click node_ml_scorer "https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-b-compliance/app/Services/MlScorerService.php"
click node_ml_service "https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/ml-service/main.py"
click node_role_dashboards "https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/tree/main/app-b-compliance/app/Http/Livewire"
click node_org_management "https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-b-compliance/app/Http/Livewire/PlatformAdmin/OrganizationManager.php"
click node_report_controller "https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-b-compliance/app/Http/Controllers/ReportExportController.php"
click node_report_service "https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-b-compliance/app/Services/ReportExportService.php"
click node_compliance_score "https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-b-compliance/app/Services/ComplianceScoreService.php"
click node_breach_dsr_dpia "https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/tree/main/app-b-compliance/app/Models"

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_crm_customers,node_crm_records,node_crm_retrievals,node_crm_compliance toneBlue
class node_event_api,node_audit_logs,node_organizations,node_rule_engine,node_rule_sets,node_alerts,node_scheduled_rules,node_escalation toneAmber
class node_role_dashboards,node_org_management,node_report_controller,node_report_service,node_compliance_score,node_breach_dsr_dpia toneMint
class node_ml_scorer,node_ml_service toneRose
class node_staff,node_org_admin,node_platform_admin,node_regulator toneIndigo
```

## Components

### Demo CRM

- [Customer Workflow](https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-a-crm/app/Http/Controllers/CustomerController.php): `app-a-crm/app/Http/Controllers/CustomerController.php`
- [Customer Records](https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-a-crm/app/Models/Customer.php): `app-a-crm/app/Models/Customer.php`
- [Retrieval History](https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-a-crm/app/Models/CustomerRetrieval.php): `app-a-crm/app/Models/CustomerRetrieval.php`
- [Compliance Client](https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-a-crm/app/Services/ComplianceApiService.php): `app-a-crm/app/Services/ComplianceApiService.php`

### Compliance Monitoring

- [Event API](https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-b-compliance/app/Http/Controllers/Api/V1/EventController.php): `app-b-compliance/app/Http/Controllers/Api/V1/EventController.php`
- [Audit Ledger](https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-b-compliance/app/Models/AuditLog.php): `app-b-compliance/app/Models/AuditLog.php`
- [Organizations](https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-b-compliance/app/Models/Organization.php): `app-b-compliance/app/Models/Organization.php`
- [Event Rule Engine](https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-b-compliance/app/Services/RuleEngine/RuleEngine.php): `app-b-compliance/app/Services/RuleEngine/RuleEngine.php`
- [PDPA Rules](https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/tree/main/app-b-compliance/app/Services/RuleEngine/Rules): `app-b-compliance/app/Services/RuleEngine/Rules`
- [Alerts](https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-b-compliance/app/Models/Alert.php): `app-b-compliance/app/Models/Alert.php`
- [Scheduled Checks](https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-b-compliance/app/Console/Commands/RunScheduledRules.php): `app-b-compliance/app/Console/Commands/RunScheduledRules.php`
- [Alert Escalation](https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-b-compliance/app/Services/EscalationService.php): `app-b-compliance/app/Services/EscalationService.php`

### Governance & Reporting

- [Role Dashboards](https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/tree/main/app-b-compliance/app/Http/Livewire): `app-b-compliance/app/Http/Livewire`
- [Organization Management](https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-b-compliance/app/Http/Livewire/PlatformAdmin/OrganizationManager.php): `app-b-compliance/app/Http/Livewire/PlatformAdmin/OrganizationManager.php`
- [Report Requests](https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-b-compliance/app/Http/Controllers/ReportExportController.php): `app-b-compliance/app/Http/Controllers/ReportExportController.php`
- [Report Exports](https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-b-compliance/app/Services/ReportExportService.php): `app-b-compliance/app/Services/ReportExportService.php`
- [Posture Score](https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-b-compliance/app/Services/ComplianceScoreService.php): `app-b-compliance/app/Services/ComplianceScoreService.php`
- [Breach, DSR & DPIA](https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/tree/main/app-b-compliance/app/Models): `app-b-compliance/app/Models`

### ML Scoring

- [ML Scorer Client](https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/app-b-compliance/app/Services/MlScorerService.php): `app-b-compliance/app/Services/MlScorerService.php`
- [Anomaly Scoring API](https://github.com/oshantheanalyst/pdpa-monitor-compliance-system/blob/main/ml-service/main.py): `ml-service/main.py`

### Other components

- **CRM Staff**
- **Organization Admin**
- **Platform Admin**
- **Regulator**

## Connections

- CRM Staff → Customer Workflow: records data
- Customer Workflow → Customer Records: stores customer (evidence: `app-a-crm/app/Http/Controllers/CustomerController.php`)
- Customer Workflow → Retrieval History: logs retrieval (evidence: `app-a-crm/app/Http/Controllers/CustomerController.php`)
- Customer Workflow → Compliance Client: sends events (evidence: `app-a-crm/app/Http/Controllers/CustomerController.php`)
- Compliance Client → Event API: posts events
- Event API → Audit Ledger: writes events (evidence: `app-b-compliance/app/Http/Controllers/Api/V1/EventController.php`)
- Event API → Organizations: resolves tenant (evidence: `app-b-compliance/app/Http/Controllers/Api/V1/EventController.php`)
- Event API → Event Rule Engine: evaluates rules (evidence: `app-b-compliance/app/Http/Controllers/Api/V1/EventController.php`)
- Event Rule Engine → PDPA Rules: evaluates rules (evidence: `app-b-compliance/app/Services/RuleEngine/RuleEngine.php`)
- Event Rule Engine → Alerts: persists alerts (evidence: `app-b-compliance/app/Services/RuleEngine/RuleEngine.php`)
- Event API → ML Scorer Client: requests scoring (evidence: `app-b-compliance/app/Http/Controllers/Api/V1/EventController.php`)
- ML Scorer Client → Anomaly Scoring API: requests anomaly score
- Scheduled Checks → Alerts: raises scheduled alerts
- Scheduled Checks → Audit Ledger: checks events
- Alert Escalation → Alerts: escalates alerts
- Organization Admin → Role Dashboards: reviews posture
- Platform Admin → Role Dashboards: manages platform
- Regulator → Role Dashboards: reviews compliance
- Platform Admin → Organization Management: manages organizations (evidence: `app-b-compliance/app/Http/Livewire/PlatformAdmin/OrganizationManager.php`)
- Organization Admin → Report Requests: requests reports
- Regulator → Report Requests: requests reports
- Report Requests → Report Exports: exports reports (evidence: `app-b-compliance/app/Http/Controllers/ReportExportController.php`)
- Report Exports → Audit Ledger: queries audit trail (evidence: `app-b-compliance/app/Services/ReportExportService.php`)
- Report Exports → Alerts: queries alerts (evidence: `app-b-compliance/app/Services/ReportExportService.php`)
- Organizations → Posture Score: calculates score (evidence: `app-b-compliance/app/Models/Organization.php`)
- Report Exports → Posture Score: uses posture score (evidence: `app-b-compliance/app/Services/ReportExportService.php`)
- Role Dashboards → Breach, DSR & DPIA: tracks obligations (evidence: `app-b-compliance/app/Http/Livewire/PlatformAdmin/OrganizationManager.php`)
