Pest Control ERP (v7) Architecture & State Machines
1. Overall System Architecture
The ERP consists of multiple layers enforcing strict role-based and schema-driven execution.
flowchart TD
User[User Web UI / AI Chat] --> Backend
Mobile[Mobile App / Field Technicians] --> Backend
subgraph Backend Server
LLM[LLM Layer Translator]
Validation[Validation Layer Schema & Permissions]
CLI[CLI Layer Execute Commands]
Engine[Core Business Engine Deterministic Accounting]
User -- Actions --> LLM
Mobile -- GPS / Photos / Signatures --> Validation
LLM -- JSON Command --> Validation
Validation -- Validated Command --> CLI
CLI -- Command Execution --> Engine
end
DB[(PostgreSQL Database)]
S3[(Object Storage S3/Photos)]
Engine -- Persist Changes --> DB
Engine -- Save Photos/Sigs --> S3
2. Ticket State Machine
Tickets represent service work. They lock upon customer submission.
stateDiagram-v2
[*] --> DRAFT : Field Tech Creates Ticket
DRAFT --> SUBMITTED : Customer Signs & Submits
SUBMITTED --> INVOICED : Attached to Invoice
SUBMITTED --> EXCLUDED : Excluded from Invoice
SUBMITTED --> VOID_PENDING : Void Requested
VOID_PENDING --> VOIDED : Void Approved
INVOICED --> [*]
EXCLUDED --> [*]
VOIDED --> [*]