HKPhase 1

Complete Database Design

Database Design

Download Markdown

This document defines the target database for the Headkount build phase.

Headkount will use this database as the main record for scheduling. External systems will remain the source for the data that they own.

Database scope

The database will hold six connected areas of information.

AreaInformation
People and accessUsers, beauty educators, roles, availability, work limits, and eligibility
Business networkMarkets, retailers, Doors, and Brands
Contracted workContracts, commitments, required visits, and required Events
SchedulingSchedule requests, generated versions, assignments, gaps, comparisons, and approvals
Daily operationsRetailer slots, bookings, Connecteam shifts, callouts, cancellations, and repairs
History and controlSource records, import problems, important changes, and approved agent actions

Table definitions

These are the target table names. Each definition explains the business purpose of one table.

People and access

TableBusiness definition
userA person who can sign in and take action in Headkount.
accountThe sign-in method that belongs to a User.
sessionOne active sign-in period for a User.
verificationA secure record that supports sign-in and account verification.
user_invitationAn invitation for a person to join Headkount with an assigned role.
beauty_educatorAn educator who can receive scheduled work.
be_hour_ruleThe work target and hour limits for one beauty educator.
be_regular_availabilityThe regular weekly times when a beauty educator can work.
be_blocked_timeTime Off or existing work that blocks new assignments.
be_market_eligibilityThe Markets where a beauty educator can work.
be_brand_eligibilityThe Brands that a beauty educator can represent.
be_door_eligibilityThe Doors where a beauty educator can work.

Business network

TableBusiness definition
marketA geographic area that Headkount schedules as one operating unit.
retailerA retail company that operates Doors.
doorA physical store where Headkount delivers work.
door_proximityA relationship between nearby Doors that can support stacked visits.
brandA beauty client that purchases Headkount services.

Contracted work

TableBusiness definition
contractThe commercial agreement between Headkount and a Brand for a set period.
service_commitmentThe amount and type of work promised for a Door and period.
service_requirementOne visit or Event that the schedule must place.

Scheduling

TableBusiness definition
scheduleThe planning period for one Market.
schedule_change_requestThe original request to create or change a Schedule.
scheduling_instructionOne specific scheduling instruction from a change request.
schedule_assignment_lockA decision to keep an Assignment in place during a new scheduling run.
schedule_rule_exceptionAn approved case that can differ from a standard scheduling rule.
schedule_generationOne scheduling run and the information that it used.
schedule_versionOne complete and unchanged result from a scheduling run.
schedule_assignmentOne placement of required work with an educator, Door, and time.
schedule_requirement_resultThe scheduling result for one required visit or Event.
schedule_version_diffThe changes between a Schedule Version and its prior version.
schedule_approvalThe acceptance of one complete Schedule Version.

Daily operations

TableBusiness definition
integration_accountApproved access to a retailer portal or external service.
retailer_slotAn open time from a retailer portal.
retailer_bookingA retailer request or confirmation for a Schedule Assignment.
external_shiftA Connecteam shift that links to a Schedule Assignment.
schedule_ticketA work item for a callout, cancellation, repair, or operating problem.
activity_eventAn unchanged record of an important action or business change.

AI Agent control

TableBusiness definition
agent_runOne User request that the AI Agent handles.
agent_tool_callOne external action that the AI Agent attempts.
action_approvalA human decision on an AI Agent action that changes business data.

Data imports

TableBusiness definition
ingestion_sourceAn external source that sends information to Headkount.
ingestion_runOne import from an external source.
ingestion_raw_recordThe original source evidence saved before Headkount changes its format.
external_record_linkThe connection between a source record and a Headkount record.
ingestion_issueA problem that stops an import from safely updating Headkount data.

Core model

Brand -> Contract -> Commitment -> Required Work
                                           |
Market -> Door <- Retailer                  |
   |                                       v
   +------ Beauty Educator ----------> Schedule
              |                            |
              +-- Availability             v
              +-- Work Limits         Schedule Version
              +-- Eligibility              |
                                           v
                                       Assignment
                                           |
                              +------------+------------+
                              |                         |
                       Retailer Booking          Connecteam Shift

A Contract defines the work that Headkount owes a Brand. A Commitment assigns that work to a Door and a period.

Required Work defines each visit or Event that the schedule must place. An Assignment connects that work to a beauty educator, time, and Door.

Schedule history

Each scheduling run creates a new Schedule Version. A new version never changes an earlier version.

Each version contains the complete schedule, its gaps, and its comparison with the prior version. An approval accepts one complete version.

This structure gives Headkount a clear record of what changed, why it changed, and who approved it.

Daily operations

The database connects the approved schedule to retailer portals and Connecteam.

Retailer Slot -> Assignment -> Retailer Booking -> Connecteam Shift
                       |
                       +-> Callout or Cancellation -> Repair

This connection keeps the planned work, retailer result, published shift, and later repair in one history.

Source ownership

InformationSource
Users, Contracts, required work, and SchedulesHeadkount application
Beauty educator profiles and eligibilityHeadkount application after migration
Existing shifts and Time OffConnecteam
Open slots and booking resultsRetailer portals
Messages and filesSlack
Historical visits and EventsImported tracker records

The database links imported records to Headkount records. It does not replace the external source record.

Data controls

  • Each person, Brand, Door, Contract, and work requirement has one main record.
  • Approved Schedule Versions remain unchanged.
  • Important changes include the User, source, time, and reason.
  • Import problems remain visible until staff resolve them.
  • Secrets stay in a secret manager and do not enter business records.
  • The AI Agent uses approved application commands and cannot write directly to business records.

Migration

The Build phase will move current information into this model.

  1. Save read-only copies of the tracker, Connecteam, Slack, retailer files, and the legacy database.
  2. Standardize names, dates, times, locations, and status values.
  3. Create the main People, Brand, Door, Contract, and Schedule records.
  4. Link historical and external records to the main records.
  5. Compare record counts and work totals before the application changes to the new database.

The migration keeps the source evidence and the links between old and new records.

Repository fit

The build keeps the current clean schemas for authentication, Markets, beauty educators, and Brands.

The build adds schemas for Doors, scheduling, integrations, daily operations, and activity history. The legacy database remains a migration source only.

Result

This model gives Headkount one connected record for contracted work, scheduling, retailer bookings, published shifts, exceptions, approvals, and operating history.