# apurvv28/samayvidya architecture

> Architecture diagram of the GitHub repository apurvv28/samayvidya, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/apurvv28/samayvidya
- Repository: https://github.com/apurvv28/samayvidya

## Overview

SamayVidya is an academic timetable management product. Coordinators configure academic resources and request generation through the role-based dashboard; the API invokes scheduling and validation, stores timetable versions, and exposes them for viewing, adjustment, analytics, and PDF export. The README documents the six-agent workflow and Bedrock-assisted planning, but the supplied excerpts do not expose every agent stage or the detailed router-to-service calls, so those links are documented rather than inferred from names. The map also preserves the role dashboards and supporting domain capabilities.

Main entry points: [`backend/app/main.py`](https://github.com/apurvv28/samayvidya/blob/master/backend/app/main.py) (FastAPI application), [`ui/app/dashboard/coordinator/page.js`](https://github.com/apurvv28/samayvidya/blob/master/ui/app/dashboard/coordinator/page.js) (Role dashboards), [`backend/app/routers/agent_routes.py`](https://github.com/apurvv28/samayvidya/blob/master/backend/app/routers/agent_routes.py) (Generation endpoints), [`backend/app/services/timetable_critic_agent.py`](https://github.com/apurvv28/samayvidya/blob/master/backend/app/services/timetable_critic_agent.py) (Schedule critic)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_ui["Role-based application"]
  node_dashboards["Role dashboards<br/>[page.js]"]
  node_auth_ui["UI authentication<br/>[AuthContext.js]"]
  node_timetable_view["Timetable viewer<br/>[TimetableViewer.js]"]
  node_resource_ui["Resource management<br/>[ManageResources.js]"]
  node_agent_ui["Generation controls"]
end

subgraph group_api["API and domain operations"]
  node_api["FastAPI application<br/>[main.py]"]
  node_auth_api["Authentication and roles<br/>[auth.py]"]
  node_academic["Academic resources"]
  node_generation_api["Generation endpoints<br/>[agent_routes.py]"]
  node_version_api["Timetable versions"]
  node_adjustments["Manual adjustments"]
  node_leave_events["Leave and events"]
  node_analytics_pdf["Analytics and PDF"]
  node_pdf_export["PDF export<br/>[pdf.py]"]
end

subgraph group_schedule["Scheduling and validation"]
  node_orchestrator["Scheduling orchestrator"]
  node_load_agents["Load planning"]
  node_critic["Schedule critic"]
  node_validator["Constraint validation"]
  node_conflict_audit["Conflict audit"]
  node_issue_resolver["Issue resolution"]
end

subgraph group_data["Persistence and integrations"]
  node_supabase_client["Supabase access<br/>[supabase_client.py]"]
  node_database[("Supabase database")]
  node_bedrock{{"AWS Bedrock"}}
end

node_coordinator(("Coordinator"))

node_coordinator -->|"uses"| node_dashboards
node_dashboards -->|"opens generation"| node_agent_ui
node_dashboards -->|"manages resources"| node_resource_ui
node_dashboards -->|"views schedules"| node_timetable_view
node_dashboards -->|"uses identity"| node_auth_ui
node_agent_ui -.->|"requests generation"| node_api
node_resource_ui -.->|"manages resources"| node_api
node_timetable_view -.->|"loads schedules"| node_api
node_api -.->|"validates requests"| node_auth_api
node_api -->|"routes generation"| node_generation_api
node_api -->|"routes versions"| node_version_api
node_generation_api -->|"invokes scheduling"| node_orchestrator
node_generation_api -->|"uses load planning"| node_load_agents
node_generation_api -->|"uses critic"| node_critic
node_orchestrator -.->|"plans passes"| node_bedrock
node_orchestrator -->|"reads and writes"| node_database
node_critic -->|"checks constraints"| node_validator
node_critic -->|"audits conflicts"| node_conflict_audit
node_issue_resolver -->|"rechecks fixes"| node_validator
node_issue_resolver -->|"consults critic"| node_critic
node_version_api -->|"audits versions"| node_conflict_audit
node_version_api -.->|"accesses data"| node_supabase_client
node_supabase_client -->|"connects"| node_database
node_adjustments -.->|"serves adjustments"| node_api
node_leave_events -.->|"serves domain APIs"| node_api
node_analytics_pdf -.->|"serves reports"| node_api
node_pdf_export -->|"reads timetable data"| node_supabase_client
node_analytics_pdf -.->|"includes export"| node_pdf_export

click node_dashboards "https://github.com/apurvv28/samayvidya/blob/master/ui/app/dashboard/coordinator/page.js"
click node_auth_ui "https://github.com/apurvv28/samayvidya/blob/master/ui/app/context/AuthContext.js"
click node_timetable_view "https://github.com/apurvv28/samayvidya/blob/master/ui/app/components/Dashboard/TimetableViewer.js"
click node_resource_ui "https://github.com/apurvv28/samayvidya/blob/master/ui/app/components/Dashboard/ManageResources.js"
click node_agent_ui "https://github.com/apurvv28/samayvidya/blob/master/ui/app/components/Dashboard/AgentOrchestrator.js"
click node_api "https://github.com/apurvv28/samayvidya/blob/master/backend/app/main.py"
click node_auth_api "https://github.com/apurvv28/samayvidya/blob/master/backend/app/dependencies/auth.py"
click node_academic "https://github.com/apurvv28/samayvidya/tree/master/backend/app/routers"
click node_generation_api "https://github.com/apurvv28/samayvidya/blob/master/backend/app/routers/agent_routes.py"
click node_version_api "https://github.com/apurvv28/samayvidya/blob/master/backend/app/routers/timetable_versions.py"
click node_adjustments "https://github.com/apurvv28/samayvidya/blob/master/backend/app/routers/slot_adjustments.py"
click node_leave_events "https://github.com/apurvv28/samayvidya/tree/master/backend/app/routers"
click node_analytics_pdf "https://github.com/apurvv28/samayvidya/tree/master/backend/app/routers"
click node_orchestrator "https://github.com/apurvv28/samayvidya/blob/master/backend/app/services/timetable_orchestrator.py"
click node_load_agents "https://github.com/apurvv28/samayvidya/blob/master/backend/app/services/load_management_agents.py"
click node_critic "https://github.com/apurvv28/samayvidya/blob/master/backend/app/services/timetable_critic_agent.py"
click node_validator "https://github.com/apurvv28/samayvidya/blob/master/backend/app/services/timetable_constraint_validator.py"
click node_conflict_audit "https://github.com/apurvv28/samayvidya/blob/master/backend/app/services/timetable_conflict_audit.py"
click node_issue_resolver "https://github.com/apurvv28/samayvidya/blob/master/backend/app/services/timetable_issue_resolver.py"
click node_supabase_client "https://github.com/apurvv28/samayvidya/blob/master/backend/app/supabase_client.py"
click node_pdf_export "https://github.com/apurvv28/samayvidya/blob/master/backend/app/routers/pdf.py"

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_dashboards,node_auth_ui,node_timetable_view,node_resource_ui,node_agent_ui toneBlue
class node_api,node_auth_api,node_academic,node_generation_api,node_version_api,node_adjustments,node_leave_events,node_analytics_pdf,node_pdf_export toneAmber
class node_orchestrator,node_load_agents,node_critic,node_validator,node_conflict_audit,node_issue_resolver toneMint
class node_supabase_client,node_database,node_bedrock toneRose
class node_coordinator toneIndigo
```

## Components

### Role-based application

- [Role dashboards](https://github.com/apurvv28/samayvidya/blob/master/ui/app/dashboard/coordinator/page.js): `ui/app/dashboard/coordinator/page.js`
- [UI authentication](https://github.com/apurvv28/samayvidya/blob/master/ui/app/context/AuthContext.js): `ui/app/context/AuthContext.js`
- [Timetable viewer](https://github.com/apurvv28/samayvidya/blob/master/ui/app/components/Dashboard/TimetableViewer.js): `ui/app/components/Dashboard/TimetableViewer.js`
- [Resource management](https://github.com/apurvv28/samayvidya/blob/master/ui/app/components/Dashboard/ManageResources.js): `ui/app/components/Dashboard/ManageResources.js`
- [Generation controls](https://github.com/apurvv28/samayvidya/blob/master/ui/app/components/Dashboard/AgentOrchestrator.js): `ui/app/components/Dashboard/AgentOrchestrator.js`

### API and domain operations

- [FastAPI application](https://github.com/apurvv28/samayvidya/blob/master/backend/app/main.py): `backend/app/main.py`
- [Authentication and roles](https://github.com/apurvv28/samayvidya/blob/master/backend/app/dependencies/auth.py): `backend/app/dependencies/auth.py`
- [Academic resources](https://github.com/apurvv28/samayvidya/tree/master/backend/app/routers): `backend/app/routers`
- [Generation endpoints](https://github.com/apurvv28/samayvidya/blob/master/backend/app/routers/agent_routes.py): `backend/app/routers/agent_routes.py`
- [Timetable versions](https://github.com/apurvv28/samayvidya/blob/master/backend/app/routers/timetable_versions.py): `backend/app/routers/timetable_versions.py`
- [Manual adjustments](https://github.com/apurvv28/samayvidya/blob/master/backend/app/routers/slot_adjustments.py): `backend/app/routers/slot_adjustments.py`
- [Leave and events](https://github.com/apurvv28/samayvidya/tree/master/backend/app/routers): `backend/app/routers`
- [Analytics and PDF](https://github.com/apurvv28/samayvidya/tree/master/backend/app/routers): `backend/app/routers`
- [PDF export](https://github.com/apurvv28/samayvidya/blob/master/backend/app/routers/pdf.py): `backend/app/routers/pdf.py`

### Scheduling and validation

- [Scheduling orchestrator](https://github.com/apurvv28/samayvidya/blob/master/backend/app/services/timetable_orchestrator.py): `backend/app/services/timetable_orchestrator.py`
- [Load planning](https://github.com/apurvv28/samayvidya/blob/master/backend/app/services/load_management_agents.py): `backend/app/services/load_management_agents.py`
- [Schedule critic](https://github.com/apurvv28/samayvidya/blob/master/backend/app/services/timetable_critic_agent.py): `backend/app/services/timetable_critic_agent.py`
- [Constraint validation](https://github.com/apurvv28/samayvidya/blob/master/backend/app/services/timetable_constraint_validator.py): `backend/app/services/timetable_constraint_validator.py`
- [Conflict audit](https://github.com/apurvv28/samayvidya/blob/master/backend/app/services/timetable_conflict_audit.py): `backend/app/services/timetable_conflict_audit.py`
- [Issue resolution](https://github.com/apurvv28/samayvidya/blob/master/backend/app/services/timetable_issue_resolver.py): `backend/app/services/timetable_issue_resolver.py`

### Persistence and integrations

- [Supabase access](https://github.com/apurvv28/samayvidya/blob/master/backend/app/supabase_client.py): `backend/app/supabase_client.py`
- **Supabase database**
- **AWS Bedrock**

### Other components

- **Coordinator**

## Connections

- Coordinator → Role dashboards: uses (evidence: `README.md`)
- Role dashboards → Generation controls: opens generation (evidence: `ui/app/dashboard/coordinator/page.js`)
- Role dashboards → Resource management: manages resources (evidence: `ui/app/dashboard/coordinator/page.js`)
- Role dashboards → Timetable viewer: views schedules (evidence: `ui/app/dashboard/coordinator/page.js`)
- Role dashboards → UI authentication: uses identity (evidence: `ui/app/dashboard/coordinator/page.js`)
- Generation controls → FastAPI application: requests generation (evidence: `README.md`)
- Resource management → FastAPI application: manages resources (evidence: `README.md`)
- Timetable viewer → FastAPI application: loads schedules (evidence: `README.md`)
- FastAPI application → Authentication and roles: validates requests (evidence: `backend/app/main.py`)
- FastAPI application → Generation endpoints: routes generation (evidence: `backend/app/main.py`)
- FastAPI application → Timetable versions: routes versions (evidence: `backend/app/main.py`)
- Generation endpoints → Scheduling orchestrator: invokes scheduling (evidence: `backend/app/routers/agent_routes.py`)
- Generation endpoints → Load planning: uses load planning (evidence: `backend/app/routers/agent_routes.py`)
- Generation endpoints → Schedule critic: uses critic (evidence: `backend/app/routers/agent_routes.py`)
- Scheduling orchestrator → AWS Bedrock: plans passes (evidence: `README.md`)
- Scheduling orchestrator → Supabase database: reads and writes (evidence: `backend/app/services/timetable_orchestrator.py`)
- Schedule critic → Constraint validation: checks constraints (evidence: `backend/app/services/timetable_critic_agent.py`)
- Schedule critic → Conflict audit: audits conflicts (evidence: `backend/app/services/timetable_critic_agent.py`)
- Issue resolution → Constraint validation: rechecks fixes (evidence: `backend/app/services/timetable_issue_resolver.py`)
- Issue resolution → Schedule critic: consults critic (evidence: `backend/app/services/timetable_issue_resolver.py`)
- Timetable versions → Conflict audit: audits versions (evidence: `backend/app/routers/timetable_versions.py`)
- Timetable versions → Supabase access: accesses data (evidence: `backend/app/routers/timetable_versions.py`)
- Supabase access → Supabase database: connects (evidence: `backend/app/supabase_client.py`)
- Manual adjustments → FastAPI application: serves adjustments (evidence: `backend/app/main.py`)
- Leave and events → FastAPI application: serves domain APIs (evidence: `backend/app/main.py`)
- Analytics and PDF → FastAPI application: serves reports (evidence: `backend/app/main.py`)
- PDF export → Supabase access: reads timetable data (evidence: `backend/app/routers/pdf.py`)
- Analytics and PDF → PDF export: includes export (evidence: `backend/app/routers/pdf.py`)
