Technical SpecsService Specs
Ticket System Architecture
Schema and Logic for Case Management.
Ticket System Architecture
Data Model
The case object is the core entity.
// packages/service/src/case.object.ts
export default {
name: 'case',
fields: {
subject: { type: 'text', required: true },
description: { type: 'textarea' },
status: { type: 'select', options: ['New', 'In Progress', 'Escalated', 'Closed'] },
priority: { type: 'select', options: ['Low', 'Medium', 'High', 'Critical'] },
origin: { type: 'select', options: ['Email', 'Phone', 'Web'] },
contact: { type: 'lookup', reference_to: 'contact' },
account: { type: 'lookup', reference_to: 'account' }
}
}Email-to-Case Handler
The EmailHandler class processes incoming MIME messages.
- Parse: Extract From, Subject, Body.
- Match: Find existing
contactby email address.- If found: Link to Contact/Account.
- If not found: Create new Contact (optional config).
- Thread: Check for
[Ref:ID]in subject.- If exists: Create
email_messagelinked to existing Case. - Application updates
case.statusto 'New Response'. - If new: Create new
case.
- If exists: Create
Entitlement Verification
On case creation, the system checks for active entitlements.
- Lookup: Find active
entitlementlinked to the Account. - Deduct: If entitlement is incident-based, decrement remaining balance.
- SLA: Calculate
target_resolution_datebased onentitlement_process.