feat: complete ShiftCraft — AI-powered shift scheduling SaaS
Complete implementation including:
- Landing page with hero, features, how-it-works, pricing
- Employee management (CRUD with soft delete)
- AI constraint parser (Anthropic Claude API)
- German labor law templates (ArbZG §3, §5, §9)
- HiGHS ILP solver for optimal fair schedules
- Schedule calendar result view (employee × date grid)
- Shift framework configuration (periods + shifts)
- Subscription tiers: Free / Pro / Business
- PocketBase setup script with collection creation + seed data
- .env.example with all required variables documented
Pages: employees, constraints (list/new/templates), schedules (list/new/[id]),
settings (organization/shifts/billing), dashboard
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
35
shared/types/constraint.ts
Normal file
35
shared/types/constraint.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
export type ConstraintType =
|
||||
| 'max_hours_per_day'
|
||||
| 'max_hours_per_week'
|
||||
| 'min_rest_between_shifts'
|
||||
| 'max_consecutive_shifts'
|
||||
| 'max_consecutive_shift_type'
|
||||
| 'min_consecutive_days_off'
|
||||
| 'max_shifts_per_period_per_week'
|
||||
| 'forbidden_shift_sequence'
|
||||
| 'employee_unavailable'
|
||||
| 'employee_prefers_period'
|
||||
| 'employee_avoids_period'
|
||||
| 'require_role_per_shift'
|
||||
| 'max_weekend_shifts_per_month'
|
||||
| 'fair_distribution'
|
||||
|
||||
export type ConstraintScope =
|
||||
| { type: 'global' }
|
||||
| { type: 'employee'; employee_id: string }
|
||||
| { type: 'role'; role: string }
|
||||
| { type: 'period'; period_id: string }
|
||||
|
||||
export interface ConstraintJSON {
|
||||
type: ConstraintType
|
||||
scope: ConstraintScope
|
||||
params: Record<string, unknown>
|
||||
hard: boolean
|
||||
weight?: number
|
||||
natural_language_summary: string
|
||||
}
|
||||
|
||||
export interface ParsedConstraintResult {
|
||||
constraints: ConstraintJSON[]
|
||||
ambiguities: string[]
|
||||
}
|
||||
95
shared/types/pocketbase.ts
Normal file
95
shared/types/pocketbase.ts
Normal file
@@ -0,0 +1,95 @@
|
||||
export interface Organization {
|
||||
id: string
|
||||
name: string
|
||||
slug: string
|
||||
timezone: string
|
||||
industry: string
|
||||
owner: string
|
||||
plan: 'free' | 'pro' | 'business'
|
||||
plan_employee_limit: number
|
||||
plan_history_months: number
|
||||
stripe_customer_id: string
|
||||
stripe_subscription_id: string
|
||||
stripe_subscription_status: string
|
||||
trial_ends_at: string
|
||||
created: string
|
||||
updated: string
|
||||
}
|
||||
|
||||
export interface PBEmployee {
|
||||
id: string
|
||||
org_id: string
|
||||
name: string
|
||||
email: string
|
||||
employee_number: string
|
||||
roles: string[]
|
||||
skills: string[]
|
||||
employment_type: string
|
||||
weekly_hours_target: number
|
||||
max_weekly_hours: number
|
||||
available_periods: string[]
|
||||
unavailable_dates: string[]
|
||||
notes: string
|
||||
active: boolean
|
||||
created: string
|
||||
updated: string
|
||||
}
|
||||
|
||||
export interface PBConstraint {
|
||||
id: string
|
||||
org_id: string
|
||||
label: string
|
||||
source_text: string
|
||||
constraint_json: import('./constraint').ConstraintJSON
|
||||
scope: string
|
||||
scope_ref: string
|
||||
category: string
|
||||
hard: boolean
|
||||
weight: number
|
||||
active: boolean
|
||||
source: string
|
||||
template_id: string
|
||||
created: string
|
||||
updated: string
|
||||
}
|
||||
|
||||
export interface PBScheduleRun {
|
||||
id: string
|
||||
org_id: string
|
||||
name: string
|
||||
period_start: string
|
||||
period_end: string
|
||||
framework_snapshot: unknown
|
||||
constraints_snapshot: unknown
|
||||
employees_snapshot: unknown
|
||||
status: 'pending' | 'solving' | 'solved' | 'infeasible' | 'error'
|
||||
solver_duration_ms: number
|
||||
objective_value: number
|
||||
infeasibility_hints: unknown
|
||||
result: unknown
|
||||
created_by: string
|
||||
created: string
|
||||
updated: string
|
||||
}
|
||||
|
||||
export interface LegalTemplate {
|
||||
id: string
|
||||
region: string
|
||||
law_name: string
|
||||
label: string
|
||||
description: string
|
||||
constraint_json: import('./constraint').ConstraintJSON
|
||||
category: string
|
||||
mandatory: boolean
|
||||
sort_order: number
|
||||
}
|
||||
|
||||
export interface ShiftFramework {
|
||||
id: string
|
||||
org_id: string
|
||||
periods: import('./schedule').Period[]
|
||||
shifts: import('./schedule').Shift[]
|
||||
scheduling_horizon_days: number
|
||||
created: string
|
||||
updated: string
|
||||
}
|
||||
59
shared/types/schedule.ts
Normal file
59
shared/types/schedule.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
export interface ShiftAssignment {
|
||||
employee_id: string
|
||||
employee_name: string
|
||||
shift_id: string
|
||||
shift_name: string
|
||||
period_id: string
|
||||
date: string // ISO date
|
||||
start_time: string
|
||||
end_time: string
|
||||
}
|
||||
|
||||
export interface SolveResult {
|
||||
status: 'solved' | 'infeasible' | 'error'
|
||||
assignments: ShiftAssignment[]
|
||||
objective_value?: number
|
||||
duration_ms?: number
|
||||
infeasibility_hints?: Array<{ constraint_id?: string; description: string }>
|
||||
}
|
||||
|
||||
export interface SolveInput {
|
||||
organization_id: string
|
||||
period_start: string
|
||||
period_end: string
|
||||
framework: {
|
||||
periods: Period[]
|
||||
shifts: Shift[]
|
||||
}
|
||||
employees: Employee[]
|
||||
constraints: Array<{ id: string; constraint_json: import('./constraint').ConstraintJSON; hard: boolean; weight?: number }>
|
||||
}
|
||||
|
||||
export interface Period {
|
||||
id: string
|
||||
name: string
|
||||
start_time: string
|
||||
end_time: string
|
||||
color: string
|
||||
}
|
||||
|
||||
export interface Shift {
|
||||
id: string
|
||||
period_id: string
|
||||
name: string
|
||||
duration_hours: number
|
||||
workers_required: number
|
||||
days_applicable: number[] // 0=Mon...6=Sun, empty = all days
|
||||
}
|
||||
|
||||
export interface Employee {
|
||||
id: string
|
||||
name: string
|
||||
roles: string[]
|
||||
skills: string[]
|
||||
employment_type: 'full_time' | 'part_time' | 'mini_job'
|
||||
weekly_hours_target: number
|
||||
max_weekly_hours: number
|
||||
available_periods: string[]
|
||||
unavailable_dates: string[]
|
||||
}
|
||||
Reference in New Issue
Block a user