Week at Work · System Design Case Study

Designing a Flexible Shift Trade & Approval System

How a seemingly simple shift-swap feature evolved into a flexible workflow architecture supporting employee eligibility, competing responses, multi-manager approvals, operational day parts, and transactional schedule changes.

System Architecture Domain Modeling CQRS Workflow Design Database Design Workforce Management
Product
Week at Work
My Role
System Architect & Developer
Primary Challenge
Multi-stage approval workflows
Architecture
Workflow + CQRS Read Models
01 — OVERVIEW

A shift trade is more than changing an employee ID.

Real-world scheduling introduces qualifications, competing responses, management responsibility, operational boundaries, approvals, revalidation, and audit requirements.

While developing Week at Work, the shift trade feature was designed around an important architectural principle: a trade represents a workflow, not simply a database update.

That distinction allowed the architecture to support shift give-ups, employee-to-employee swaps, pickup responses, qualification-based eligibility, multi-manager approval, manager notes, and a complete history of how each scheduling change occurred.

Model the workflow that produces the scheduling change—not just the final scheduling change itself.

02 — THE PROBLEM

Simple requirements quickly became complex business rules.

The design needed to accommodate several different employee and management workflows without creating separate systems for each scenario.

1

Different Trade Types

Employees may give away a shift, exchange shifts, or withdraw a pending request.

2

Employee Eligibility

Employees accepting a shift must satisfy its position, training, qualification, and business requirements.

3

Competing Responses

Multiple employees may respond to one trade before the requester selects the preferred response.

4

Variable Approval Rules

A trade might require one manager approval, any manager from a pool, or several independent approvals depending on the trade type and which day parts are affected by the trade.

5

Operational Ownership

Different managers may be responsible for different shifts or different periods within the same shift.

6

Auditability

The platform needs to preserve who made each decision, why it was made, and how the schedule ultimately changed.

03 — DOMAIN MODEL

Separating requests from responses.

A trade request represents intent. Responses represent individual proposals for satisfying that intent.

ShiftTradeRequest
  • RequestId
  • LocationId
  • RequesterId
  • ShiftId
  • RequestType
  • Reason
  • Status
  • CreatedAt
ShiftTradeResponse
  • ResponseId
  • RequestId
  • ResponderId
  • ResponderShiftId
  • Status
  • Message
  • CreatedAt
Trade Request Alice offers Shift #1001
Response A Bob offers Shift #2004
Response B Chris offers Shift #3010
Response C Sam offers pickup

This one-to-many structure allows several employees to respond without mutating the original request. For a simple give-up, the responding employee does not need to offer another shift. For a swap, the response identifies the shift being proposed in exchange.

04 — ELIGIBILITY

Keep qualification rules outside the trade workflow.

Not every employee is eligible to work every shift. Rather than embedding qualification logic into the trade tables, employee qualifications and shift requirements remain independent domain concepts.

Employee Employee qualifications
Eligibility Check Compare requirements
Shift Required qualifications

The qualification system determines whether an employee can work the shift. The trade workflow determines whether the proposed change should proceed.

05 — APPROVAL WORKFLOW

Approval became a first-class domain concept.

Storing ApprovedBy and ApprovedAt on the request would fail as soon as multiple managers became involved.

ShiftTradeApproval
  • ApprovalId
  • RequestId
  • ResponseId
  • ShiftId
  • ApproverId
  • ApprovalGroupId
  • DayPartId
  • Decision
  • Notes
  • DecisionAt

Solving the one-of-many manager problem

Approval Group 501

Manager A Pending
Manager B Pending
Manager C Pending

Manager B Approves

Manager A Resolved
Manager B Approved
Manager C Resolved

The requirement belongs to the approval group. Individual approval records represent the managers capable of satisfying that requirement.

06 — SWAP APPROVALS

Evaluate each side of a shift swap independently.

Alice's shift and Bob's shift may fall under different management responsibility, so approval requirements attach to the shift being evaluated rather than to the swap globally.

SHIFT A

Alice's Morning Shift

Shift #1001

Approval Group A Manager A or Manager B
SHIFT B

Bob's Evening Shift

Shift #2004

Approval Group B Manager C

Both approval groups must be satisfied before the employee assignments can be exchanged.

07 — OPERATIONAL PERIODS

Reuse day parts instead of inventing another scheduling concept.

Week at Work already understands operational day parts. The approval workflow can use those same boundaries to determine management responsibility.

10:00 AM 8:00 PM
Morning Day Part
Evening Day Part
Morning MOD Approval Group
Evening MOD Approval Group

Reusing an existing domain concept avoids creating a second representation of the same operational boundary.

08 — READ ARCHITECTURE

Optimize complex workflow screens independently from writes.

Manager task dashboards cross several domains, making them a natural fit for CQRS-style application queries rather than a repository belonging to one aggregate.

Shift Trade Approvals
Time-Off Approvals
Availability Approvals
Manager Tasks Read Model

Trade request screens use a similar pattern. Requests, responses, and approvals can be returned as separate result sets in a single database round trip and then grouped by the application.

This avoids massive joined result sets containing duplicated request data while retaining the performance benefits of efficient infrastructure queries.

09 — EXAMPLE WORKFLOW

From employee request to transactional schedule change.

1

Request

Alice offers Shift #1001 for trade.

2

Eligibility

Bob's qualifications are evaluated against Shift #1001's requirements.

3

Response

Bob proposes Shift #2004 in exchange.

4

Selection

Alice accepts Bob's proposed swap.

5

Resolve Approval Requirements

The application evaluates both shifts, applicable day parts, and eligible managers.

6

Manager Decisions

Each required approval group reaches a decision, preserving manager notes and timestamps.

7

Revalidation

Qualifications, shift state, and other critical constraints are checked again before commit.

8

Transactional Commit

Employee assignments are exchanged atomically.

9

Audit

Approval history and assignment changes are recorded for future review.

10 — DESIGN PRINCIPLES

Architectural decisions that shaped the system.

Model the Workflow

Requests, responses, selections, approvals, and completion are meaningful business states—not implementation details.

Separate Eligibility

Qualification rules remain independent from the trade workflow so each can evolve independently.

Separate Requirements from Approvers

Approval groups model what must be approved while approval records identify who may satisfy that requirement.

Reuse Domain Concepts

Existing day parts model operational boundaries and can therefore help determine management responsibility.

Preserve History

Current state answers what is true now while audit data preserves how the system reached that state.

Optimize Reads Separately

CQRS-style read queries enable efficient task dashboards without distorting transactional domain models.

11 — OUTCOME

A flexible workflow engine for controlled schedule changes.

New approval scenarios can primarily be introduced through business rules rather than database redesign.

Flexible Trades Give-ups, direct swaps, pickup requests, and multiple employee responses.
Qualification Safety Employees are validated against the requirements of the shifts they would receive.
Composable Approvals Supports one-of-many managers as well as multiple independently required approvals.
Operational Awareness Approval responsibilities can follow existing scheduling day parts.
Complete Auditability Decision notes, approval history, and assignment changes remain traceable.
Efficient Read Models Location-based retrieval and CQRS queries support manager dashboards efficiently.
The difficult part of scheduling software isn't storing the schedule—it's accurately modeling the rules and human decisions that are allowed to change it.

Explore More of My Work

See additional software architecture, product development, and engineering projects.