Entity System Overview
Introduction
The Entity System is the foundation of CXTMS, providing a comprehensive data model for all business objects in the transportation and logistics domain. With 121 pre-defined entities, the system covers every aspect of freight forwarding operations, from customer management to financial transactions, shipping documentation, and warehouse operations.
Entities in CXTMS are more than just database tables - they are intelligent business objects with built-in behaviors, relationships, validations, and workflow integration capabilities. This low-code approach allows rapid development of complex logistics applications while maintaining data integrity and business rule enforcement.
Recent entity behavior notes
- Contact display names can be regenerated from trimmed first/last name parts when organization-user profile data changes, keeping linked contact profile names in sync.
- Contact imports validate
DivisionIdagainst the target organization. Foreign, stale, or unparsable division IDs are ignored; new contacts fall back to the importing user's division when no valid division is supplied. Nesteddivision.divisionNamevalues are resolved to organization divisions before import. - Commodity GraphQL now exposes
getWeightTotal(weightUnit)for unit-aware total-weight projection.
Core Concepts
What is an Entity?
An entity represents a business object or concept in the TMS system. Each entity:
- Has a unique identifier and standardized naming convention
- Contains fields (attributes) that store data
- Defines relationships with other entities
- Includes business rules and validations
- Integrates with workflows, permissions, and UI components
- Supports custom extensions and configurations
- Inherits automatic audit tracking (created/modified timestamps and users)
- Publishes domain events for cross-entity communication
Entity Architecture
All entities in the system follow a consistent inheritance hierarchy:
BaseEntity
↓
AuditableEntity
↓
[All Business Entities]
BaseEntity provides:
- Domain events infrastructure for publishing business events
- Methods to add, remove, and clear domain events
- Foundation for all entity classes
AuditableEntity extends BaseEntity and adds:
CreatedBy- User ID who created the entityCreated- Timestamp when entity was createdLastModifiedBy- User ID who last modified the entityLastModified- Timestamp of last modification- References to
ApplicationUserfor created and updated users
All business entities inherit from AuditableEntity, providing automatic audit trail tracking across the entire system.
Architecture Patterns
The entity system implements several Domain-Driven Design patterns:
1. Aggregate Roots
Aggregate roots are entities that serve as the primary entry point for related entities, enforcing consistency boundaries:
- Order - Controls order commodities, charges, entities, carriers, documents, and events
- Job - Aggregates multiple orders, commodities, and accounting transactions
- Commodity - Manages hierarchical commodity containers and tracking
- AccountingTransaction - Coordinates charges, payments, and accounting items
2. Hierarchical Entities
Some entities support parent-child relationships for organizational structures:
- Division - Organizational hierarchy within a tenant (
ParentDivisionId) - Commodity - Container system where commodities can contain other commodities (
ContainerCommodityId) - Contact - Hierarchical contact relationships (
ParentContactId)
3. Polymorphic Entities
Certain entities represent multiple business concepts through type discrimination:
- Contact - Can be Customer, Vendor, Agent, Carrier, Broker, or Employee (via
ContactTypeenum) - AccountingTransaction - Invoice, Bill, Credit Memo, Debit Memo, or Payment (via
AccountingTransactionTypeenum) - Order - Multiple order types including Shipment, Quote, Warehouse Receipt (via
OrderTypesenum)
4. Junction Tables
Many-to-many relationships are implemented through junction entities:
- OrderCommodity - Links orders to commodities
- OrderCarrier - Associates carriers with orders
- OrderCharge - Connects charges to orders
- JobOrder - Links jobs to orders
- AccountingTransactionCharges - Associates charges with accounting transactions
- AccountingTransactionPayment - Links payments to transactions
5. Tag System
Flexible tagging across multiple entity types:
- Tag - Reusable tag definitions with entity type discrimination
- OrderTag, CommodityTag, InventoryItemTag - Entity-specific tag assignments
6. Custom Values & Extensions
Many entities support extensibility through custom values:
- Order, Job, Commodity, Contact - Include
CustomValuesdictionary (Dictionary<string, object?>) - CustomField - System-wide custom field definitions
- Enables adding custom properties without schema changes
7. Audit Trail
Comprehensive change tracking across all entities:
- All entities inherit
CreatedBy,Created,LastModifiedBy,LastModified - AuditChangeLog entity stores detailed change history
- Integration with
ApplicationUserfor user attribution
8. Multi-Tenancy
Data isolation through organizational structures:
- Tenant - Top-level tenant isolation
- Organization - Primary organizational container
- Division - Hierarchical sub-organizations
- Most entities include
OrganizationIdfor data partitioning
9. Domain Events
Event-driven architecture for cross-entity communication:
- Entities publish events on significant state changes
- Examples:
OrderStatusChangedEvent,CommodityStatusChangedEvent - Events processed asynchronously for loose coupling