Prompt
I'm building a support system for multiple brands and need queues, permissions, and audit trails
Latest observation
A good multi-brand support system usually needs a tenant-aware design with queue routing, fine-grained permissions, and immutable audit logging. Here’s a solid blueprint.
1) Core concepts to model
Brands / tenants
Each brand should be isolated logically:
- brand_id
- brand name
- settings / SLA rules
- support channels
- routing rules
Queues
Queues are the work buckets agents process:
- queue_id
- brand_id
- name
- purpose/category
- priority rules
- assignment policy
A queue can belong to:
- one brand only, or
- multiple brands if you want shared operations
Users and roles
Typical roles:
- Super admin: all brands
- Brand admin: manages one brand
- Manager: can view/assign within a brand
- Agent: works assigned tickets
- Auditor: read-only access to logs
Tickets
Tickets should include:
- ticket_id
- brand_id
- queue_id
- customer_id
- status
- assignee_id
- created_at / updated_at
- priority
- channel
Audit events
Every sensitive change should be recorded:
- who did it
- what changed
- when
- from where
- before/after values
2) Permission model
Use RBAC + brand scoping.
Example permissions
ticket.viewticket.createticket.assignticket.reopenqueue.manageuser.manageaudit.viewsettings.manage
Scope
Permissions should be constrained by:
- brand scope
- queue scope
- ownership scope
Example:
- Agent can
ticket.viewonly for queues they belong to - Brand admin can manage queues and users within their brand
- Super admin can access all brands
Recommended rule pattern
A permission check should answer:
- Does the user have the capability?
- Is the target object in an allowed brand/queue?
- Is there an override or escalation path?
3) Queue design
Routing
Tickets can enter queues based on:
- brand
- topic/category
- language
- channel
- customer tier
- SLA priority
Assignment options
- manual assignment
- round-robin
- least-loaded
- skill-based routing
- escalation routing
Queue membership
Agents can be members of:
- one queue
- many queues
- different queues per brand
Store memberships explicitly:
- user_id
- queue_id
- role_in_queue
- active flag
4) Audit trail design
You want audit logs that are:
- append-only
- searchable
- tamper-resistant
- linked to the affected entity
Log fields
- audit_id
- actor_user_id
- brand_id
- entity_type
- entity_id
- action
- timestamp
- ip_address
- user_agent
- before_state
- after_state
- correlation_id
Actions to log
- login/logout
- role changes
- queue creation/update/delete
- ticket assignment changes
- ticket status changes
- permission changes
- export/download actions
- integration changes
Best practice
Store both:
- event summary for indexing
- structured JSON diff for detail
5) Data model sketch
A simple relational model could include:
brandsusersrolespermissionsuser_rolesqueuesqueue_membershipsticketsticket_eventsaudit_logs
If you need multi-brand access, also add:
brand_memberships
6) Security considerations
- Enforce brand scoping in every query
- Never trust client-side filtering
- Use row-level security if available
- Separate audit log storage from primary app data
- Prevent hard deletion of audit records
- Add MFA for admins
- Log permission changes immediately
7) Example access rules
Agent
- View tickets in assigned queues
- Update ticket status
- Add internal notes
- Cannot change permissions
Brand manager
- Manage queues
- Assign agents
- View all tickets for brand
- View audit logs for brand
Super admin
- Cross-brand visibility
- Manage all brands
- Full audit access
8) Practical implementation approach
If you’re designing the backend API:
Key endpoints
POST /brandsPOST /queuesPOST /ticketsPATCH /tickets/{id}POST /tickets/{id}/assignGET /audit-logsPOST /users/{id}/roles
Middleware
Add middleware for:
- authentication
- brand context resolution
- permission evaluation
- audit logging
9) Recommended pattern for audit logging
Use domain events like:
TicketCreatedTicketAssignedQueueCreatedUserRoleChanged
Then write audit records from those events. This keeps logging consistent and easier to scale.
If you want, I can turn this into:
- a database schema,
- a permission matrix, or
- an API design for your support platform.