Employee Domain Model
Summary
The domain layer models Employee, Department, and Designation as aggregate roots, with employee-owned profile entities, immutable/self-validating value objects, domain events, and aggregate invariants.
Audience
- Backend developers and QA engineers
- Domain modelers and solution architects
Reference Content
Aggregates
Employee: workforce master consistency boundary; owns employment, profile collections, notes, document references, and timeline entries and references organization identifiers.Department: tenant-scoped organization aggregate with optional parent and head references.Designation: tenant-scoped organization aggregate with optional department relationship.
Employee-owned entities
Employment is modeled as owned employment state. Education, experience, emergency contact, skill, bank account, document reference, note, and timeline entry are employee child entities stamped with employee and tenant identity.
Value objects and primitives
The domain defines Entity, AggregateRoot, ValueObject, and DomainValidationException. Confirmed value objects include employee code, employee name, email address, phone number, address, money, and audit information. Employee currently stores normalized scalar values produced by several of those value objects rather than retaining every value-object type as a property.
Domain events
Employee raises internal events for creation, update, deletion/termination, manager change, department change, employment-status change, and timeline recording. Payload documentation is intentionally deferred. Infrastructure translates supported domain events to shared contracts at commit.
Business invariants
- Employee code and first name are required and normalized.
- Display name, email, and phone enforce source-defined format/length rules.
- An employee cannot report to themselves.
- Employee status controls the active indicator for Terminated state.
- Notes and document references enforce required content.
- Department and designation require names and codes.
- Department cannot be its own parent.
Cross-aggregate existence, active-state, uniqueness, and assignment checks are application/persistence validations rather than aggregate-only invariants.
Domain services
No dedicated domain-service class was found. Department and designation coordination classes reside in the Application layer. Cross-aggregate rules are implemented by application validators and handlers using repository ports.
Source References
microservices/src/employee-service/Domain/Common/DomainPrimitives.csmicroservices/src/employee-service/Domain/Common/ValueObjects.csmicroservices/src/employee-service/Domain/Employees/Employee.csmicroservices/src/employee-service/Domain/Organization/Organization.cs
Related Articles
See Also
Keywords
- Aggregate root
- Domain entity
- Domain invariant
Revision Information
- Status: Draft
- Last reviewed: 2026-07-15
- Review cycle: Quarterly