Skip to main content

12.1 Data Architecture

This section documents the migrated database model for the MoH Helpdesk platform. The current implementation uses separate PostgreSQL databases per service. This page focuses on the two core service databases requested for handover:

  • User Service database: identity, organization, facility, access, package, and automation configuration.
  • Ticketing Service database: ticket lifecycle, assignment, categorization, conversation, attachment, SLA, and reporting source data.

The tables below are based on the Entity Framework Core model snapshots and entities currently migrated in the codebase.

12.1.1 Shared Entity Pattern

Most migrated entities inherit a common audit model.

FieldPurpose
CreatedByUser or service actor that created the row.
DateCreatedCreation timestamp.
ModifiedByUser or service actor that last changed the row.
DateModifiedLast modification timestamp.
OrganizationIdLogical tenant/organization boundary.
IsDeletedSoft-delete flag.
IsSyncedInternal sync flag.
IsTPSyncedThird-party sync flag.
IsArchivedArchive flag.

Cross-service references are stored mainly as GUIDs. For example, Ticketing stores ContactId, FacilityId, ExpertId, and OrganizationId as logical references to User Service records instead of enforcing database-level foreign keys across service databases.

12.1.2 User Service Data Model

The User Service owns platform identity, organizations, facilities, regions, contacts, service access, roles, packages, user requests, and notification automation settings.

User Service Tables

TablePrimary KeyMain FieldsPurpose
UserAccountsOidFirstName, Surname, Email, Cellphone, Password, RegionId, UserType, IsSystemAdministrator, IsActiveStores internal system users such as administrators, national users, regional users, and support users.
BiometricsOidImage, FingerprintStores biometric data linked one-to-one with a user account.
OrganizationsOidName, Address, City, State, ExpiryDate, ContactNumber, OrganizationSuffix, IsPublicPortalConfigured, IsActive, StatusStores tenant or client organizations.
IdentifiedOrganizationsOidUserAccountId, OrganizationId, IsActive, IsAdministratorMaps users to organizations and marks organization-level administrators.
AssignedOrganizationServicesOidOrganizationId, ServiceDefines which platform services are enabled for an organization.
RegionsOidNameStores geographic or operational regions.
CompaniesOidName, Description, Address, PrimaryPhone, Email, Website, RegionId, FacilityCodeStores facilities/companies and links them to regions.
ContactsOidFullName, Email, Phone, CompanyId, PasswordStores external/facility contacts who can report or own tickets.
DepartmentsOidName, DescriptionStores organizational departments.
IdentifiedUserDepartmentsOidDepartmentId, IdentifiedUserIdMaps an organization-scoped user to departments.
IdentifiedUserAccessesOidServices, UserAccountIdDefines a user's service-level access.
IdentifiedUserRolesOidIdentifiedUserAccessId, RolesDefines service roles for a user's service access.
IdentifiedRoleActionsOidRole, Feature, ActionTypeDefines role-to-feature/action permission rules.
LoginHistoriesOidLoginDateTime, IsLoggedOut, UserIdStores login session history for audit and activity tracking.
PackagesOidTitle, Description, IsActiveStores commercial or subscription package definitions.
PackageFeaturesOidPackageId, DescriptionStores feature rows under each package.
UserRequestsOidOrganizationName, RequestDate, FirstName, Surname, Email, Cellphone, RequestStatus, GenderStores onboarding or access requests before final account setup.
AutomationRulesOidServiceType, EventType, IsCreate, AutoAssignTime, Description, OrganizationIdStores notification/automation rules per service, event type, and organization.
AutomationChannelsOidAutomationRuleId, ChannelStores delivery channels for an automation rule.
IdentifiedAutomationRolesOidAutomationChannelId, RoleStores recipient roles for an automation channel.

User Service Relationship Diagram

100%
50%300%
User Service relationship diagram

User Service Notes

The migration defines these important relationships:

RelationshipMeaning
Organization to Identified OrganizationsOne organization can have many assigned users.
User Account to Identified OrganizationsOne user can be assigned to many organizations.
Region to CompaniesOne region can contain many facilities/companies.
Region to User AccountsA regional user can be tied to a region.
Company to ContactsOne facility/company can have many reporting contacts.
User Account to Access to RolesService-level permissions are assigned through access records and role records.
Automation Rule to Channels to RolesNotification rules define channels and recipient roles.

The User Service has a composite unique index on automation rules for ServiceType, EventType, and OrganizationId, preventing duplicate automation rules for the same service/event/organization combination.

12.1.3 Ticketing Service Data Model

The Ticketing Service owns service desk tickets and all local data needed to classify, route, assign, discuss, attach, resolve, audit, and report on tickets.

Ticketing Service Tables

TablePrimary KeyMain FieldsPurpose
IncidentsOidSLNumber, TicketTitle, Description, DateResolved, IsAssigned, IncidentStatus, IncidentSource, DueDate, IncidentPriority, IncidentCreateMethod, TicketType, FacilityId, ContactId, MailThreadId, CategoryId, TeamId, ApplicationId, BranchId, ImagesCentral ticket/case table. Stores ticket identity, status, SLA dates, source, priority, ownership references, category/team routing, and external references.
ApplicationsOidNameStores application/system names used to classify incidents.
BranchesOidName, Description, IsActiveStores branch/location records used by tickets and branch permissions.
BranchPermissionsOidBranchId, UserAccountId, IsActiveMaps users to branches for access control.
CategoriesOidName, Description, ParentCategoryIdStores ticket categories and parent-child category grouping.
TeamsOidName, Description, IsAssignedStores support teams.
TeamMembersOidUserId, TeamId, IsTeamLead, IsPrimaryTeamMaps user IDs to teams.
IdentifiedCategoriesOidCategoryId, TeamIdMaps categories to teams for routing/assignment.
IdentifiedAssignedIncidentsOidDescription, DateIdentified, AllowAccess, IncidentId, ExpertId, TeamIdStores incident assignment history and current access/ownership records.
MessagesOidMessageDate, Description, IsInternal, IsResolution, IsOpen, IncidentId, EmailMessageIdStores ticket conversation entries, internal notes, and resolution messages.
MessageAttachmentsOidAttachmentPath, MessageIdStores file references attached to ticket messages.
IncidentAttacmentsOidAttacmentPath, IncidentId, MailAttachmentIdStores file references attached directly to incidents. The migrated table name preserves the existing spelling.
IncidentHistoriesOidDescription, ActionType, ActionDate, FieldName, OldFieldValue, NewFieldValue, IncidentId, UserAccountId, ContactIdStores ticket audit history and field-change records.
IncidentSolutionSuggestionsOidIncidentId, SourceIncidentId, SourceSLNumber, SuggestedSolution, SimilarityScore, IsAiVerified, AiVerificationReason, Status, CustomerRespondedAt, CustomerMessageIdStores AI/similar-ticket solution suggestions for resolution support.
PriorityConfigurationsOidPriority, TimeInMinutesStores SLA time configuration by ticket priority.

Ticketing Service Relationship Diagram

100%
50%300%
Ticketing Service relationship diagram

Ticketing Service Notes

The migration defines these important relationships:

RelationshipMeaning
Incident to Category, Team, Application, BranchA ticket can be classified by category, routed to a team, linked to an application, and optionally tied to a branch.
Incident to MessagesOne ticket can have many conversation messages, internal notes, and resolution messages.
Incident to Identified Assigned IncidentsAssignment history is retained as separate rows, which supports reassignment and escalation reporting.
Message to Message AttachmentsMessage-specific files are stored separately from incident-level files.
Incident to Incident AttachmentsTicket-level attachments are stored as file paths linked to the incident.
Incident to Incident HistoriesField changes and lifecycle actions are audited against the ticket.
Category to Identified Categories to TeamCategory-to-team routing is configurable through a mapping table.
Team to Team MembersTeam membership is stored separately from the team definition and references User Service users by GUID.

The Ticketing Service has a composite unique index on SLNumber and OrganizationId, so ticket serial numbers are unique inside each organization.

12.1.4 Cross-Service Logical References

The service databases remain independently owned. The following Ticketing fields are logical references to User Service data:

Ticketing FieldReferenced User Service Concept
Incidents.OrganizationIdOrganizations.Oid
Incidents.FacilityIdCompanies.Oid
Incidents.ContactIdContacts.Oid
IdentifiedAssignedIncidents.ExpertIdUserAccounts.Oid
TeamMembers.UserIdUserAccounts.Oid
BranchPermissions.UserAccountIdUserAccounts.Oid
IncidentHistories.UserAccountIdUserAccounts.Oid
IncidentHistories.ContactIdContacts.Oid

These relationships should be treated as service-level contracts rather than database-level foreign keys. The application resolves names and profile details through service calls when displaying ticket reports, assignments, contacts, facilities, and users.