# prateekkiran/aba-genius-scheduler architecture

> Architecture diagram of the GitHub repository prateekkiran/aba-genius-scheduler, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-07-18). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/prateekkiran/aba-genius-scheduler
- Repository: https://github.com/prateekkiran/aba-genius-scheduler

## Overview

#### 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: [`src/contexts/SchedulerContext.tsx`](https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/contexts/SchedulerContext.tsx) (Scheduler context), [`src/engine/cspSolver.ts`](https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/engine/cspSolver.ts) (Single-week solver), [`src/App.tsx`](https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/App.tsx) (App routing), [`src/pages/Index.tsx`](https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/pages/Index.tsx) (Scheduling workspace)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Admin UI"]
  node_app["App routing<br/>React Router shell<br/>[App.tsx]"]
  node_layout["Admin layout<br/>shared UI shell<br/>[AppLayout.tsx]"]
  node_sidebar["Area navigation<br/>sidebar<br/>[AppSidebar.tsx]"]
  node_workspace["Scheduling workspace<br/>scheduler page<br/>[Index.tsx]"]
  node_generation["Generation wizard<br/>four-stage workflow<br/>[Step1Scope.tsx]"]
  node_results["Solver results<br/>acceptance workspace"]
  node_schedule["Schedule editor<br/>calendar UI<br/>[ScheduleView.tsx]"]
  node_diagnostics["Violations and diagnostics<br/>constraint UI"]
end

subgraph group_state["Scheduler State"]
  node_scheduler_context{{"Scheduler context<br/>state orchestration"}}
  node_sessions_state["Session state<br/>mutation state hook"]
  node_suggestions_state["Suggestion state<br/>generated state hook"]
  node_mock_data[("Mock domain records<br/>in-memory data<br/>[mockData.ts]")]
end

subgraph group_engine["Scheduling Engine"]
  node_solver{{"Single-week solver<br/>constraint solver<br/>[cspSolver.ts]"}}
  node_filtration["Eligibility gates<br/>hard candidate filter"]
  node_rules["Rule evaluation<br/>hard and soft rules<br/>[ruleEngine.ts]"]
  node_scoring["Objective scoring<br/>weighted ranking<br/>[scoringEngine.ts]"]
  node_multiweek["Multi-week solver<br/>planning solver<br/>[multiWeekSolver.ts]"]
end

subgraph group_operations["Operational Projections"]
  node_optimization["Optimization projection<br/>KPI and action page"]
  node_compliance["Compliance audit<br/>audit projection<br/>[CompliancePage.tsx]"]
  node_credential_audit[("Credential audit store<br/>localStorage audit log<br/>[credentialAudit.ts]")]
end

node_main(("Vite bootstrap<br/>React entry<br/>[main.tsx]"))

node_main -->|"boots"| node_app
node_app -->|"renders"| node_layout
node_layout -->|"includes"| node_sidebar
node_layout -->|"hosts route"| node_workspace
node_app -->|"routes to"| node_optimization
node_app -->|"routes to"| node_compliance
node_workspace -->|"starts generation"| node_generation
node_workspace -->|"edits sessions"| node_schedule
node_workspace -->|"surfaces constraints"| node_diagnostics
node_generation -->|"submits inputs"| node_scheduler_context
node_results -->|"accepts suggestions"| node_scheduler_context
node_schedule -->|"mutates sessions"| node_scheduler_context
node_diagnostics -->|"reads violations"| node_scheduler_context
node_scheduler_context -->|"composes"| node_sessions_state
node_scheduler_context -->|"composes"| node_suggestions_state
node_scheduler_context -->|"uses records"| node_mock_data
node_scheduler_context -->|"runs planning"| node_multiweek
node_multiweek -->|"repeats weekly solve"| node_solver
node_solver -->|"filters candidates"| node_filtration
node_solver -->|"evaluates rules"| node_rules
node_solver -->|"ranks feasible candidates"| node_scoring
node_solver -->|"returns suggestions"| node_suggestions_state
node_optimization -->|"reads data and prefills"| node_scheduler_context
node_compliance -->|"displays and exports"| node_credential_audit

click node_main "https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/main.tsx"
click node_app "https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/App.tsx"
click node_layout "https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/components/layout/AppLayout.tsx"
click node_sidebar "https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/components/layout/AppSidebar.tsx"
click node_workspace "https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/pages/Index.tsx"
click node_generation "https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/components/scheduler/generate/Step1Scope.tsx"
click node_results "https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/components/scheduler/generate/ResultsWorkspace.tsx"
click node_schedule "https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/components/scheduler/ScheduleView.tsx"
click node_diagnostics "https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/components/scheduler/ViolationsPanel.tsx"
click node_scheduler_context "https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/contexts/SchedulerContext.tsx"
click node_sessions_state "https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/contexts/hooks/useSessionsState.ts"
click node_suggestions_state "https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/contexts/hooks/useSuggestionsState.ts"
click node_mock_data "https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/data/mockData.ts"
click node_solver "https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/engine/cspSolver.ts"
click node_filtration "https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/engine/filtrationEngine.ts"
click node_rules "https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/engine/ruleEngine.ts"
click node_scoring "https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/engine/scoringEngine.ts"
click node_multiweek "https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/engine/multiWeekSolver.ts"
click node_optimization "https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/pages/OptimizationPage.tsx"
click node_compliance "https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/pages/CompliancePage.tsx"
click node_credential_audit "https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/lib/credentialAudit.ts"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_app,node_layout,node_sidebar,node_workspace,node_generation,node_results,node_schedule,node_diagnostics toneBlue
class node_scheduler_context,node_sessions_state,node_suggestions_state,node_mock_data toneAmber
class node_solver,node_filtration,node_rules,node_scoring,node_multiweek toneMint
class node_optimization,node_compliance,node_credential_audit toneRose
class node_main toneNeutral
```

## Components

### Admin UI

- [App routing](https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/App.tsx): React Router shell · `src/App.tsx`
- [Admin layout](https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/components/layout/AppLayout.tsx): shared UI shell · `src/components/layout/AppLayout.tsx`
- [Area navigation](https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/components/layout/AppSidebar.tsx): sidebar · `src/components/layout/AppSidebar.tsx`
- [Scheduling workspace](https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/pages/Index.tsx): scheduler page · `src/pages/Index.tsx`
- [Generation wizard](https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/components/scheduler/generate/Step1Scope.tsx): four-stage workflow · Scope, strategy, constraints, and review inputs. · `src/components/scheduler/generate/Step1Scope.tsx`
- [Solver results](https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/components/scheduler/generate/ResultsWorkspace.tsx): acceptance workspace · `src/components/scheduler/generate/ResultsWorkspace.tsx`
- [Schedule editor](https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/components/scheduler/ScheduleView.tsx): calendar UI · `src/components/scheduler/ScheduleView.tsx`
- [Violations and diagnostics](https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/components/scheduler/ViolationsPanel.tsx): constraint UI · `src/components/scheduler/ViolationsPanel.tsx`

### Scheduler State

- [Scheduler context](https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/contexts/SchedulerContext.tsx): state orchestration · Composes sessions, suggestions, rules, and solver-run state. · `src/contexts/SchedulerContext.tsx`
- [Session state](https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/contexts/hooks/useSessionsState.ts): mutation state hook · `src/contexts/hooks/useSessionsState.ts`
- [Suggestion state](https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/contexts/hooks/useSuggestionsState.ts): generated state hook · `src/contexts/hooks/useSuggestionsState.ts`
- [Mock domain records](https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/data/mockData.ts): in-memory data · No backend or durable application database. · `src/data/mockData.ts`

### Scheduling Engine

- [Single-week solver](https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/engine/cspSolver.ts): constraint solver · Assembles ranked feasible session suggestions. · `src/engine/cspSolver.ts`
- [Eligibility gates](https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/engine/filtrationEngine.ts): hard candidate filter · Rejects credential, authorization, and conflict failures. · `src/engine/filtrationEngine.ts`
- [Rule evaluation](https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/engine/ruleEngine.ts): hard and soft rules · `src/engine/ruleEngine.ts`
- [Objective scoring](https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/engine/scoringEngine.ts): weighted ranking · Scores continuity, fit, route, balance, compactness, authorization, and stability. · `src/engine/scoringEngine.ts`
- [Multi-week solver](https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/engine/multiWeekSolver.ts): planning solver · Carries commitments through up to eight weekly solves. · `src/engine/multiWeekSolver.ts`

### Operational Projections

- [Optimization projection](https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/pages/OptimizationPage.tsx): KPI and action page · Recommendations can prefill scheduling workflows. · `src/pages/OptimizationPage.tsx`
- [Compliance audit](https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/pages/CompliancePage.tsx): audit projection · Displays and exports local credential audit records. · `src/pages/CompliancePage.tsx`
- [Credential audit store](https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/lib/credentialAudit.ts): localStorage audit log · Append-only records with implementation-defined cap. · `src/lib/credentialAudit.ts`

### Other components

- [Vite bootstrap](https://github.com/prateekkiran/aba-genius-scheduler/blob/main/src/main.tsx): React entry · `src/main.tsx`

## Connections

- 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
