Bluewoo HRMS

Domain Model

Core entities and business rules

Domain Model

Goal

Build a multi-tenant HR data model that supports employee management, time-off tracking, documents, team communication, goals, and workflows with flexible organizational relationships.

Core Entities (~20 entities)

EntityPurpose
TenantCompany using the HRMS
UserAuthentication account (linked to Employee)
EmployeePerson working for a tenant
DepartmentOrganizational unit
TeamCross-functional or permanent grouping
RoleJob role within tenant
TimeOffPolicyPolicy defining leave types and allowances
TimeOffBalanceEmployee's balance for a policy year
TimeOffRequestLeave request with approval workflow
DocumentFiles and HR documents with access control
DocumentAccessFine-grained document sharing
TeamPostFeed posts with likes/comments
GoalOKR/goal tracking
KeyResultMeasurable outcomes for goals
WorkflowOnboarding/offboarding templates
WorkflowTaskIndividual tasks in workflows
TagFlexible categorization system
TagCategoryGroups of related tags
CustomFieldDefinitionTenant-defined metadata fields
DashboardConfigurable widget dashboards

Organizational Structure

Flexible Manager Relationships

The HRMS supports flexible organizational relationships, not just 1:1 manager-employee:

┌─────────────────────────────────────────────────────────────┐
│                 Employee Relationships                       │
├─────────────────────────────────────────────────────────────┤
│ Primary Manager    │ 0..1  │ Main reporting line             │
│ Dotted-Line Mgrs   │ 0..N  │ Secondary reporting (projects)  │
│ Departments        │ 0..N  │ Can belong to multiple depts    │
│ Teams              │ 0..N  │ Cross-functional team members   │
│ Roles              │ 0..N  │ Multiple job roles supported    │
└─────────────────────────────────────────────────────────────┘

Relationship Types

RelationshipCardinalityPurpose
Employee → Primary Manager0..1Main reporting line (nullable for CEO/founders)
Employee ↔ Dotted-Line Managers0..NProject leads, matrix reporting
Employee ↔ Departments0..NMulti-department assignments
Employee ↔ Teams0..NTeam memberships with roles
Employee ↔ Roles0..NJob titles and responsibilities

Circular Reference Prevention

The system automatically validates:

  1. No employee can be their own manager (direct cycle)
  2. No circular chains (A → B → C → A)
  3. Terminated employees cannot be managers

Time-Off System

Policy Structure

TimeOffPolicy
├── Code (e.g., "VACATION", "SICK")
├── Leave Type (PAID/UNPAID/PARENTAL/etc.)
├── Annual Allowance (days)
├── Accrual Schedule (ANNUAL/MONTHLY/NONE)
├── Carry-Over Rules
└── Required Approval Level

Balance Calculation

Available = Total Allocation
          + Carried Over
          - Used (approved)
          - Pending (awaiting approval)

Document Access Control

Visibility Levels

LevelWho Can View
PRIVATEOnly owner
TEAMOwner's team members
DEPARTMENTOwner's department
MANAGERSAll managers in tenant
COMPANYAll employees in tenant
CUSTOMSpecific users/teams/departments

Documents also support:

  • Tag-based categorization
  • Time-limited sharing (expiration dates)
  • Download vs view-only permissions

Goals/OKR Structure

Goal
├── Title, Description
├── Type (PERSONAL/TEAM/DEPARTMENT/COMPANY)
├── Time Period (Q1, Q2, H1, YEAR)
├── Status (DRAFT/ACTIVE/COMPLETED/CANCELLED)
├── Progress (0-100%)
└── Key Results (0..N)
    ├── Description
    ├── Target Value
    ├── Current Value
    └── Unit (%, count, currency)

Tag System

Tags provide flexible categorization:

TagCategory (e.g., "Skills", "Locations")
└── Tags (e.g., "Python", "Remote")
    └── Can be assigned to:
        ├── Employees
        ├── Documents
        └── Goals

Role-based permissions control who can assign/remove tags.

Custom Fields

Tenants can define additional fields for entities:

Entity TypeExample Custom Fields
EmployeeT-Shirt Size, Emergency Contact, Employee ID (external)
DepartmentCost Center, Budget Code
TeamProject Code, Slack Channel
GoalPriority Level, Business Unit

Field types: TEXT, NUMBER, DATE, DROPDOWN, CHECKBOX, URL, EMAIL

Key Use Cases

  1. Flexible Org Structure - Primary managers + dotted-line managers + multi-team membership
  2. Time-Off Workflow - Submit → Manager(s) approve → Balance updates
  3. Document Access Control - Fine-grained sharing with expiration
  4. Team Communication - Posts with visibility controls (team, department, company)
  5. OKR Tracking - Goals with key results, progress tracking
  6. Workflow Automation - Onboarding/offboarding task templates
  7. Tagging - Flexible categorization with permissions
  8. Custom Fields - Tenant-specific metadata

Critical Rules

Multi-Tenancy

  • Every entity (except Tenant) has tenantId
  • Every query must filter by tenantId
  • Complete data isolation between tenants
  • PostgreSQL RLS as additional safety layer

IDs and Audit

  • All IDs are UUIDs (v4)
  • All entities have createdAt, updatedAt
  • Soft deletes via deletedAt field
  • Audit logs for sensitive operations

Employee Rules

  • Employee number unique within tenant
  • Email unique within tenant
  • Manager must be active employee in same tenant
  • No circular management chains
  • Terminated employees cannot be managers
  • Status transitions: ONBOARDING → ACTIVE → ON_LEAVE → TERMINATED

Time-Off Rules

  • Balance: available = total - used - pending
  • Employees cannot approve own requests
  • Managers approve for direct reports only
  • No overlapping approved time-off
  • Policies define accrual and carry-over rules

Document Rules

  • Max 10MB per file
  • Allowed: PDF, DOCX, DOC, XLS, XLSX, JPG, PNG, GIF
  • No executables (.exe, .sh, .bat)
  • Access checked on every request (not cached)

Tag Rules

  • Tags belong to categories
  • Categories define which entity types can use them
  • Role-based permissions for tag assignment/removal

Complete Schema: See Database Schema for full Prisma models.