# anamikasharma1509/virelia_be_proj architecture

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

- Interactive diagram: https://gitdiagram.com/anamikasharma1509/virelia_be_proj
- Repository: https://github.com/anamikasharma1509/virelia_be_proj

## Overview

Virelia is a role-based guided-practice platform: patients complete assigned assessments, practice self-paced scenarios, reflect on sessions, and view approved reports; administrators manage patients, assessments, assignments, scenarios, videos, and report review. The React portals call a FastAPI API backed by PostgreSQL, with local media storage and optional AI drafting. Groups distinguish user experience, domain workflows, platform services, and persistence/analysis. Unsampled route implementations are represented where the tree and README establish capabilities; those paths and links are documented rather than source-inspected.

Main entry points: [`backend/app/main.py`](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/main.py) (API router), [`frontend/src/routes/AppRoutes.tsx`](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/frontend/src/routes/AppRoutes.tsx) (Role portals), [`backend/app/db/session.py`](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/db/session.py) (Database sessions), [`frontend/src/api/client.ts`](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/frontend/src/api/client.ts) (API client)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Web experience"]
  node_web["Role portals<br/>[AppRoutes.tsx]"]
  node_auth_ui["Login and signup<br/>[LoginPage.tsx]"]
  node_auth_state["Auth context<br/>[AuthContext.tsx]"]
  node_patient_assess["Assessment taking"]
  node_patient_practice["Guided practice"]
  node_session_player["Scenario player"]
  node_patient_reports["Patient reports<br/>[PatientReports.tsx]"]
  node_admin_portal["Admin workflows"]
  node_api_client["API client<br/>[client.ts]"]
end

subgraph group_workflows["Practice workflows"]
  node_auth_api["Authentication<br/>[auth.py]"]
  node_assessment_api["Assessments<br/>[assessments.py]"]
  node_assignment_api["Assignments<br/>[assignments.py]"]
  node_submission_api["Submission review<br/>[submissions.py]"]
  node_scenario_api["Scenario catalog<br/>[scenarios.py]"]
  node_session_api["Exposure sessions<br/>[sessions.py]"]
  node_video_api["Video streaming<br/>[videos.py]"]
  node_report_api["Reports<br/>[reports.py]"]
  node_admin_api["Patient management<br/>[admin.py]"]
end

subgraph group_platform["Platform services"]
  node_api_entry["API router<br/>[main.py]"]
  node_db_session["Database sessions<br/>[session.py]"]
  node_security["Security and roles<br/>[security.py]"]
end

subgraph group_data["Data and analysis"]
  node_postgres[("PostgreSQL")]
  node_media[("Local media storage<br/>[local_storage.py]")]
  node_ai_service["AI drafting service<br/>[service.py]"]
  node_fallback["Local AI fallback<br/>[fallback.py]"]
end

node_patient(("Patient"))
node_admin(("Administrator"))
node_external_ai(("OpenAI-compatible API"))

node_patient -->|"uses portal"| node_web
node_admin -->|"uses portal"| node_web
node_web -->|"routes to"| node_auth_ui
node_auth_ui -->|"authenticates via"| node_auth_state
node_auth_state -->|"calls auth API"| node_api_client
node_web -->|"routes to"| node_patient_assess
node_web -->|"routes to"| node_patient_practice
node_web -->|"routes to"| node_session_player
node_web -->|"routes to"| node_patient_reports
node_web -->|"routes to"| node_admin_portal
node_patient_assess -.->|"submits answers"| node_api_client
node_patient_practice -.->|"loads scenarios"| node_api_client
node_session_player -->|"records session"| node_api_client
node_patient_reports -.->|"loads reports"| node_api_client
node_admin_portal -->|"manages workflows"| node_api_client
node_api_client -->|"sends API requests"| node_api_entry
node_api_entry -->|"registers router"| node_auth_api
node_api_entry -->|"registers router"| node_assessment_api
node_api_entry -->|"registers router"| node_assignment_api
node_api_entry -->|"registers router"| node_submission_api
node_api_entry -->|"registers router"| node_scenario_api
node_api_entry -->|"registers router"| node_session_api
node_api_entry -->|"registers router"| node_video_api
node_api_entry -->|"registers router"| node_report_api
node_api_entry -->|"registers router"| node_admin_api
node_auth_api -->|"queries users"| node_db_session
node_auth_api -->|"verifies credentials"| node_security
node_assessment_api -.->|"uses database"| node_db_session
node_assignment_api -.->|"uses database"| node_db_session
node_submission_api -.->|"uses database"| node_db_session
node_scenario_api -.->|"uses database"| node_db_session
node_session_api -->|"queries and writes"| node_db_session
node_session_api -->|"requests summary"| node_ai_service
node_video_api -.->|"streams media"| node_media
node_report_api -.->|"uses database"| node_db_session
node_admin_api -->|"queries records"| node_db_session
node_db_session -->|"opens sessions"| node_postgres
node_ai_service -->|"falls back to"| node_fallback
node_ai_service -->|"requests assessment draft"| node_external_ai
node_admin -->|"reviews answers"| node_submission_api
node_admin -->|"approves and releases"| node_report_api
node_patient -->|"completes assessment"| node_patient_assess
node_patient -->|"practices scenario"| node_patient_practice
node_patient -->|"reflects on session"| node_session_player

click node_web "https://github.com/anamikasharma1509/virelia_be_proj/blob/main/frontend/src/routes/AppRoutes.tsx"
click node_auth_ui "https://github.com/anamikasharma1509/virelia_be_proj/blob/main/frontend/src/pages/auth/LoginPage.tsx"
click node_auth_state "https://github.com/anamikasharma1509/virelia_be_proj/blob/main/frontend/src/context/AuthContext.tsx"
click node_patient_assess "https://github.com/anamikasharma1509/virelia_be_proj/blob/main/frontend/src/pages/patient/AssessmentTakingPage.tsx"
click node_patient_practice "https://github.com/anamikasharma1509/virelia_be_proj/blob/main/frontend/src/pages/patient/GuidedPracticePage.tsx"
click node_session_player "https://github.com/anamikasharma1509/virelia_be_proj/blob/main/frontend/src/pages/patient/ScenarioSessionPlayer.tsx"
click node_patient_reports "https://github.com/anamikasharma1509/virelia_be_proj/blob/main/frontend/src/pages/patient/PatientReports.tsx"
click node_admin_portal "https://github.com/anamikasharma1509/virelia_be_proj/blob/main/frontend/src/pages/admin/AdminAssessments.tsx"
click node_api_client "https://github.com/anamikasharma1509/virelia_be_proj/blob/main/frontend/src/api/client.ts"
click node_api_entry "https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/main.py"
click node_auth_api "https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/api/auth.py"
click node_assessment_api "https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/api/assessments.py"
click node_assignment_api "https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/api/assignments.py"
click node_submission_api "https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/api/submissions.py"
click node_scenario_api "https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/api/scenarios.py"
click node_session_api "https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/api/sessions.py"
click node_video_api "https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/api/videos.py"
click node_report_api "https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/api/reports.py"
click node_admin_api "https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/api/admin.py"
click node_db_session "https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/db/session.py"
click node_security "https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/core/security.py"
click node_media "https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/storage/local_storage.py"
click node_ai_service "https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/ai/service.py"
click node_fallback "https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/ai/fallback.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_web,node_auth_ui,node_auth_state,node_patient_assess,node_patient_practice,node_session_player,node_patient_reports,node_admin_portal,node_api_client toneBlue
class node_auth_api,node_assessment_api,node_assignment_api,node_submission_api,node_scenario_api,node_session_api,node_video_api,node_report_api,node_admin_api toneAmber
class node_api_entry,node_db_session,node_security,node_external_ai toneMint
class node_postgres,node_media,node_ai_service,node_fallback toneRose
class node_patient,node_admin toneIndigo
```

## Components

### Web experience

- [Role portals](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/frontend/src/routes/AppRoutes.tsx): `frontend/src/routes/AppRoutes.tsx`
- [Login and signup](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/frontend/src/pages/auth/LoginPage.tsx): `frontend/src/pages/auth/LoginPage.tsx`
- [Auth context](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/frontend/src/context/AuthContext.tsx): `frontend/src/context/AuthContext.tsx`
- [Assessment taking](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/frontend/src/pages/patient/AssessmentTakingPage.tsx): `frontend/src/pages/patient/AssessmentTakingPage.tsx`
- [Guided practice](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/frontend/src/pages/patient/GuidedPracticePage.tsx): `frontend/src/pages/patient/GuidedPracticePage.tsx`
- [Scenario player](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/frontend/src/pages/patient/ScenarioSessionPlayer.tsx): `frontend/src/pages/patient/ScenarioSessionPlayer.tsx`
- [Patient reports](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/frontend/src/pages/patient/PatientReports.tsx): `frontend/src/pages/patient/PatientReports.tsx`
- [Admin workflows](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/frontend/src/pages/admin/AdminAssessments.tsx): `frontend/src/pages/admin/AdminAssessments.tsx`
- [API client](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/frontend/src/api/client.ts): `frontend/src/api/client.ts`

### Practice workflows

- [Authentication](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/api/auth.py): `backend/app/api/auth.py`
- [Assessments](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/api/assessments.py): `backend/app/api/assessments.py`
- [Assignments](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/api/assignments.py): `backend/app/api/assignments.py`
- [Submission review](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/api/submissions.py): `backend/app/api/submissions.py`
- [Scenario catalog](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/api/scenarios.py): `backend/app/api/scenarios.py`
- [Exposure sessions](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/api/sessions.py): `backend/app/api/sessions.py`
- [Video streaming](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/api/videos.py): `backend/app/api/videos.py`
- [Reports](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/api/reports.py): `backend/app/api/reports.py`
- [Patient management](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/api/admin.py): `backend/app/api/admin.py`

### Platform services

- [API router](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/main.py): `backend/app/main.py`
- [Database sessions](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/db/session.py): `backend/app/db/session.py`
- [Security and roles](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/core/security.py): `backend/app/core/security.py`

### Data and analysis

- **PostgreSQL**
- [Local media storage](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/storage/local_storage.py): `backend/app/storage/local_storage.py`
- [AI drafting service](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/ai/service.py): `backend/app/ai/service.py`
- [Local AI fallback](https://github.com/anamikasharma1509/virelia_be_proj/blob/main/backend/app/ai/fallback.py): `backend/app/ai/fallback.py`

### Other components

- **Patient**
- **Administrator**
- **OpenAI-compatible API**

## Connections

- Patient → Role portals: uses portal
- Administrator → Role portals: uses portal
- Role portals → Login and signup: routes to (evidence: `frontend/src/routes/AppRoutes.tsx`)
- Login and signup → Auth context: authenticates via (evidence: `frontend/src/pages/auth/LoginPage.tsx`)
- Auth context → API client: calls auth API (evidence: `frontend/src/context/AuthContext.tsx`)
- Role portals → Assessment taking: routes to (evidence: `frontend/src/routes/AppRoutes.tsx`)
- Role portals → Guided practice: routes to (evidence: `frontend/src/routes/AppRoutes.tsx`)
- Role portals → Scenario player: routes to (evidence: `frontend/src/routes/AppRoutes.tsx`)
- Role portals → Patient reports: routes to (evidence: `frontend/src/routes/AppRoutes.tsx`)
- Role portals → Admin workflows: routes to (evidence: `frontend/src/routes/AppRoutes.tsx`)
- Assessment taking → API client: submits answers
- Guided practice → API client: loads scenarios
- Scenario player → API client: records session (evidence: `frontend/src/pages/patient/ScenarioSessionPlayer.tsx`)
- Patient reports → API client: loads reports
- Admin workflows → API client: manages workflows (evidence: `frontend/src/pages/admin/AdminAssessments.tsx`)
- API client → API router: sends API requests
- API router → Authentication: registers router (evidence: `backend/app/main.py`)
- API router → Assessments: registers router (evidence: `backend/app/main.py`)
- API router → Assignments: registers router (evidence: `backend/app/main.py`)
- API router → Submission review: registers router (evidence: `backend/app/main.py`)
- API router → Scenario catalog: registers router (evidence: `backend/app/main.py`)
- API router → Exposure sessions: registers router (evidence: `backend/app/main.py`)
- API router → Video streaming: registers router (evidence: `backend/app/main.py`)
- API router → Reports: registers router (evidence: `backend/app/main.py`)
- API router → Patient management: registers router (evidence: `backend/app/main.py`)
- Authentication → Database sessions: queries users (evidence: `backend/app/api/auth.py`)
- Authentication → Security and roles: verifies credentials (evidence: `backend/app/api/auth.py`)
- Assessments → Database sessions: uses database
- Assignments → Database sessions: uses database
- Submission review → Database sessions: uses database
- Scenario catalog → Database sessions: uses database
- Exposure sessions → Database sessions: queries and writes (evidence: `backend/app/api/sessions.py`)
- Exposure sessions → AI drafting service: requests summary (evidence: `backend/app/api/sessions.py`)
- Video streaming → Local media storage: streams media
- Reports → Database sessions: uses database
- Patient management → Database sessions: queries records (evidence: `backend/app/api/admin.py`)
- Database sessions → PostgreSQL: opens sessions (evidence: `backend/app/db/session.py`)
- AI drafting service → Local AI fallback: falls back to (evidence: `backend/app/ai/service.py`)
- AI drafting service → OpenAI-compatible API: requests assessment draft (evidence: `backend/app/ai/service.py`)
- Administrator → Submission review: reviews answers
- Administrator → Reports: approves and releases
- Patient → Assessment taking: completes assessment
- Patient → Guided practice: practices scenario
- Patient → Scenario player: reflects on session
