Open-source manufacturing ERP, MES and QMS. Quoting, MRP, inventory, shop floor, quality and lot/serial traceability on one Postgres schema, with a REST API and MCP server. Self-host or use Carbon Cloud.
People Module
Employee management, departments, shifts, holidays, time tracking (clock in/out, timecards), contacts, and employee attributes (custom fields). Manages the HR/organizational side — identity and permissions live in the users module.
Key Domain Concepts
- People vs Users vs Employees —
useris the global auth identity.employeeis a per-company record with composite PK(id, companyId)whereid → user.id.employeeJobholds title, location, department, shift, and manager. See.claude/rules/user-employee-job-relationships.md. - Departments — hierarchical organizational units via
parentDepartmentId. Used for org structure and reporting. - Shifts — work schedules with day-of-week boolean flags (
monday..sunday), start/end times, and location. Assigned to employees viaemployeeJob.shiftId. - Holidays — company-specific non-working days with year grouping. The scheduler closes every work center that is not lights-out (
workCenter.alwaysOn) for the whole day in the plant timezone, and treats every person as absent. - Time Tracking —
clockIn/clockOutfunctions managetimeCardEntryrecords. Weekly hours aggregated viagetWeeklyHoursForEmployees. - Contacts — external contacts (not employees) associated with customers/suppliers via the
contacttable. - Employee Attributes — custom field system: categories → attributes → values. Each attribute has a data type (text, numeric, boolean, date, user, file, list) from
attributeDataType. Values stored per user inuserAttributeValue.
Safety
Always
- MUST scope
employeeJobqueries by BOTHidANDcompanyId— composite PK. - MUST distinguish
employeeJob.title(job role string) fromuserToCompany.role(membership type enum: customer/employee/supplier). - MUST use
getEmployeeJobfor employee job info — it joins the correct tables with proper scoping. - MUST soft-delete attributes and attribute categories via
active: false—deleteAttributeanddeleteAttributeCategoryboth use soft-delete. - MUST soft-delete shifts via
active: false—deleteShiftsetsactive: false, not a hard delete.
Ask First
- Deleting departments with assigned employees — cascading impact on org structure.
- Modifying shifts actively assigned to employees — affects scheduling.
- Bulk-editing employee attributes — values are per-user and may have downstream effects.
Never
- Confuse
employeeJob(HR job placement) withjob(production work order) — completely different tables. - Directly modify
userPermission— permissions flow fromemployeeType → employeeTypePermission → userPermission. - Hard-delete attribute categories, attributes, or shifts — always soft-delete via
active: false.
Validation Commands
pnpm exec turbo run typecheck --filter=erp --concurrency=1 # the package is "erp", not "@carbon/erp"
pnpm --filter erp test -- people # vitest filters by file path
Key Data Model
| Table / View | Purpose |
|---|---|
employeeJob |
Job details: title, startDate, locationId, departmentId, shiftId, managerId |
employeeSummary (view) |
Denormalized employee info with names |
department |
Org units with parentDepartmentId hierarchy |
shift / shifts (view) |
Work schedules: day flags, times, location |
holiday / holidayYears (view) |
Company non-working days with year grouping |
timeCardEntry / timeCardEntries (view) |
Clock in/out records with notes |
userAttributeCategory / userAttribute / userAttributeValue |
Custom employee fields |
attributeDataType |
Lookup table for attribute data types |
contact |
External contacts (customer/supplier contacts) |
Key Service Functions
getEmployeeJob/updateEmployeeJob/insertEmployeeJob— employee job managementgetEmployeeSummary— denormalized employee datagetPeople— people directory with attributes merged fromuserAttributeCategorygetContacts— external contact searchgetDepartments/getDepartmentsList/getDepartmentsTree— org structuregetShifts/getShiftsList/upsertShift— work schedule managementgetShiftsWithTimes— shifts withstartTime/endTime+ per-weekday flags for a location (people capacity math);getEmployeeShifts— company-wideemployeeShiftmap (each person's standing shift)getHolidays/getHolidayYears/upsertHoliday— holiday calendarclockIn/clockOut/getTimeCardEntries/getWeeklyHoursForEmployees— time trackinggetClockedInEmployees/getScheduledEmployeesToday— real-time workforce statusgetAttribute/getAttributeCategories/insertAttribute/updateAttribute— custom fields
Operations (people.server.ts)
Each is a defineServiceFn const in people.server.ts. The route calls it as api.people.<name>(input); the API and MCP publish the ones tagged @mcp as people_<name>. Routes validate the request, call one, and answer with respond(request, result).redirect(…) (a flash) or the result.
createShift(people create),updateShift(people create and update: the old route's gate and theshiftUPDATE policy; refusednotFoundwhen the update reaches no row of the company),deleteShift(people delete; setsactive: false). All three notify the scheduler with kindshiftand the shift id, so the mark step stamps the jobs on the work centers that run the shift; an update that moves the shift to another location notifies kindlocation(company-wide), since the stations it left lose its hours too. Published.createHoliday,updateHoliday,deleteHoliday— the holiday calendar (x+/people+/holidays.*). A holiday closes the plant for the scheduler, so each one notifies kindlocationafter it saves.updatePersonJob— the person's job (updateEmployeeJob: ids checked against the company,employeeShiftkept in step, one transaction), then reschedules. Published.- The person timecard page (
x+/person+/$personId.timecard.tsx):clockInPerson,clockOutPerson,addPersonTimeCardEntry,updatePersonTimeCardEntry,deletePersonTimeCardEntry. They need only people view, as that page always did, so they stay unpublished. A helper's own refusal ("Already clocked in") is aruleerror; a database error isinternal. clockInSelf,clockOutSelffor the caller (api+/people.timecard.ts, the "Forgot to clock out?" prompt). Unpublished.
The building blocks they call (updateEmployeeJob, upsertShift, clockIn, clockOut) are in people.service.ts and are never tools. Import other modules' code from the file that defines it (*.service.ts, *.models.ts).
Key Exports
import { getEmployeeJob, getDepartmentsList, clockIn, clockOut } from "~/modules/people/people.service";
Related Modules
- resources — locations and shifts are shared; work centers assign employees via abilities
- production — job operations have
assignee(employee); production events track employee time - users — identity, permissions, and claims (separate module)
- sales — customer contacts overlap;
getEmployeeJobused for assignee lookups - accounting — employees used as dimension values in journal entries
Rules References
.claude/rules/user-employee-job-relationships.md— identity graph: user → employee → employeeJob → permissions