How prateekkiran/aba-genius-scheduler works
Purpose and Entry Points
ABA Smart Scheduler is a frontend-only React prototype for ABA clinic scheduling. It generates and validates therapist-client sessions against authorization, credential, availability, continuity, travel, and workload constraints. Application bootstrapping is in src/main.tsx; routing and top-level page composition are in src/App.tsx; the primary scheduling workspace is src/pages/Index.tsx.
Application Shell and Navigation
The admin UI is organized around a shared layout with schedule, rules, clients, therapists, authorizations, optimization, and compliance areas. src/components/layout/AppLayout.tsx and src/components/layout/AppSidebar.tsx establish this boundary. Scheduler-specific UI is concentrated under src/components/scheduler/, while optimization and compliance have dedicated page modules.
Central Scheduler State
src/contexts/SchedulerContext.tsx is the state orchestration boundary between UI and scheduling logic. It composes separate hooks for session mutation, rules, generated suggestions, and recent solver runs: src/contexts/hooks/useSessionsState.ts, src/contexts/hooks/useSuggestionsState.ts, and src/contexts/hooks/useSolverRuns.ts. Consumers access this state through src/contexts/useScheduler.ts.
The prototype uses in-memory/mock domain records from src/data/mockData.ts; there is no backend, authentication service, or durable application database.
Scheduling Engine Pipeline
The pure TypeScript engine in src/engine/ is the core decision system:
• Hard eligibility gates remove invalid therapist-slot candidates for credentials, authorizations, and conflicts in src/engine/filtrationEngine.ts.
• Active hard/soft rules are evaluated in src/engine/ruleEngine.ts.
• Remaining candidates receive weighted objective scores—continuity, fit, route, balance, compactness, authorization use, and recurrence stability—in src/engine/scoringEngine.ts.
• A single-week constraint solve assembles ranked feasible suggestions in src/engine/cspSolver.ts.
• src/engine/multiWeekSolver.ts repeats solving across up to eight weeks, carrying earlier commitments forward.
This is a client-side, deterministic computation boundary: UI submits scope/strategy/constraint inputs; engine returns candidate suggestions, diagnostics, and run results.
Generation and Schedule Operations
The generation wizard is a four-stage workflow: scope, strategy, constraints, and review, implemented by src/components/scheduler/generate/Step1Scope.tsx, src/components/scheduler/generate/Step2Strategy.tsx, and src/components/scheduler/generate/Step4Review.tsx. src/components/scheduler/generate/ResultsWorkspace.tsx presents solver output and acceptance actions.
src/components/scheduler/ScheduleView.tsx is the calendar-facing manual editing surface. Changes pass through centralized session/rule state so violations can be surfaced by src/components/scheduler/ViolationsPanel.tsx and src/components/scheduler/ConstraintDiagnosticsPanel.tsx. Auto-fix outcomes are tracked for undo in src/components/scheduler/AutoFixSummary.tsx.
Recurrence and Compliance Boundaries
Recurring cadence is inferred from historical sessions by src/engine/recurrenceDetection.ts; session recurrence expansion helpers live in src/lib/recurrence.ts. Detected recurring slots can be locally skipped or therapist-overridden via src/components/scheduler/RecurringSlotActions.tsx.
Compliance is a separate operational projection: credential changes are append-only local audit records managed by src/lib/credentialAudit.ts, displayed/exported through src/pages/CompliancePage.tsx and src/pages/compliance/ComplianceTable.tsx. Audit persistence is browser localStorage, capped by the library implementation.
Optimization and Runtime
src/pages/OptimizationPage.tsx translates scheduler data into KPIs, action queues, and recommendations; actionable recommendations can prefill scheduling workflows. Its metric and action derivations are in src/pages/optimization/useOptimizationMetrics.ts and src/pages/optimization/useActionQueues.ts.
Runtime is React 18, TypeScript, and Vite, styled with Tailwind and shadcn/Radix UI. React Router handles navigation; TanStack Query, React Hook Form, and Zod are installed platform dependencies, but no server/API integration is represented in this tree.
Main entry points: SchedulerContext.tsx Scheduler context · cspSolver.ts Single-week solver · App.tsx App routing · Index.tsx Scheduling workspace
Components 21
Admin UI
- App routing
src/App.tsx - Admin layout
src/components/layout/AppLayout.tsx - Area navigation
src/components/layout/AppSidebar.tsx - Scheduling workspace
src/pages/Index.tsx - Generation wizard · Scope, strategy, constraints, and review inputs.
src/components/scheduler/generate/Step1Scope.tsx - Solver results
src/components/scheduler/generate/ResultsWorkspace.tsx - Schedule editor
src/components/scheduler/ScheduleView.tsx - Violations and diagnostics
src/components/scheduler/ViolationsPanel.tsx
Scheduler State
- Scheduler context · Composes sessions, suggestions, rules, and solver-run state.
src/contexts/SchedulerContext.tsx - Session state
src/contexts/hooks/useSessionsState.ts - Suggestion state
src/contexts/hooks/useSuggestionsState.ts - Mock domain records · No backend or durable application database.
src/data/mockData.ts
Scheduling Engine
- Single-week solver · Assembles ranked feasible session suggestions.
src/engine/cspSolver.ts - Eligibility gates · Rejects credential, authorization, and conflict failures.
src/engine/filtrationEngine.ts - Rule evaluation
src/engine/ruleEngine.ts - Objective scoring · Scores continuity, fit, route, balance, compactness, authorization, and stability.
src/engine/scoringEngine.ts - Multi-week solver · Carries commitments through up to eight weekly solves.
src/engine/multiWeekSolver.ts
Operational Projections
- Optimization projection · Recommendations can prefill scheduling workflows.
src/pages/OptimizationPage.tsx - Compliance audit · Displays and exports local credential audit records.
src/pages/CompliancePage.tsx - Credential audit store · Append-only records with implementation-defined cap.
src/lib/credentialAudit.ts
Other components
- Vite bootstrap
src/main.tsx
Connections 24
- Vite bootstrap → App routing: boots
- App routing → Admin layout: renders
- Admin layout → Area navigation: includes
- Admin layout → Scheduling workspace: hosts route
- App routing → Optimization projection: routes to
- App routing → Compliance audit: routes to
- Scheduling workspace → Generation wizard: starts generation
- Scheduling workspace → Schedule editor: edits sessions
- Scheduling workspace → Violations and diagnostics: surfaces constraints
- Generation wizard → Scheduler context: submits inputs
- Solver results → Scheduler context: accepts suggestions
- Schedule editor → Scheduler context: mutates sessions
- Violations and diagnostics → Scheduler context: reads violations
- Scheduler context → Session state: composes
- Scheduler context → Suggestion state: composes
- Scheduler context → Mock domain records: uses records
- Scheduler context → Multi-week solver: runs planning
- Multi-week solver → Single-week solver: repeats weekly solve
- Single-week solver → Eligibility gates: filters candidates
- Single-week solver → Rule evaluation: evaluates rules
- Single-week solver → Objective scoring: ranks feasible candidates
- Single-week solver → Suggestion state: returns suggestions
- Optimization projection → Scheduler context: reads data and prefills
- Compliance audit → Credential audit store: displays and exports