# kenithlabonite/ocr_frontend architecture

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

- Interactive diagram: https://gitdiagram.com/kenithlabonite/ocr_frontend
- Repository: https://github.com/kenithlabonite/ocr_frontend

## Overview

OCR_Frontend is an ASP.NET Core Razor Pages frontend for an OCR-based document and exam system. Users authenticate, upload and manage PDFs, generate questionnaires, submit answer sheets for grading, and review graded results; profile and administration pages provide account management. Page handlers call a configured backend API, while middleware validates sessions. The excerpts show these interactions for several major flows; other page capabilities are represented from the source tree, with uncertain connections omitted.

Main entry points: [`OCR_Frontend/Middleware/SessionValidationMiddleware.cs`](https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Middleware/SessionValidationMiddleware.cs) (Session validation), [`OCR_Frontend/Helpers/ApiErrorHelper.cs`](https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Helpers/ApiErrorHelper.cs) (API error parsing), [`OCR_Frontend/Program.cs`](https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Program.cs) (Razor app), [`OCR_Frontend/Helpers/AuthCookieHelper.cs`](https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Helpers/AuthCookieHelper.cs) (Auth cookies)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Web runtime"]
  node_program["Razor app<br/>[Program.cs]"]
  node_dashboard["Dashboard"]
  node_api_errors["API error parsing<br/>[ApiErrorHelper.cs]"]
end

subgraph group_identity["Identity and access"]
  node_session_middleware["Session validation"]
  node_session_service["Frontend instance"]
  node_cookies["Auth cookies"]
  node_login["Login<br/>[Login.cshtml.cs]"]
  node_registration["Registration and recovery<br/>[Register.cshtml.cs]"]
end

subgraph group_documents["Documents and exams"]
  node_upload["PDF upload"]
  node_documents_page["Document library"]
  node_questionnaires["Questionnaires"]
  node_generation["Questionnaire generation"]
  node_grading["Exam grading"]
  node_graded_sheets["Graded results"]
end

subgraph group_management["Account management"]
  node_profile["Profile<br/>[Profile.cshtml.cs]"]
  node_admin["Administration<br/>[Admin.cshtml.cs]"]
end

node_browser(("User browser"))
node_backend{{"Backend API"}}

node_browser -->|"requests pages"| node_program
node_program -->|"registers middleware"| node_session_middleware
node_program -->|"configures API client"| node_backend
node_session_middleware -->|"validates session"| node_backend
node_session_middleware -->|"clears cookies"| node_cookies
node_session_middleware -->|"checks instance"| node_session_service
node_login -->|"authenticates"| node_backend
node_login -->|"sets session"| node_cookies
node_registration -->|"parses errors"| node_api_errors
node_upload -->|"uploads PDFs"| node_backend
node_documents_page -->|"manages documents"| node_backend
node_documents_page -->|"attaches auth"| node_cookies
node_generation -->|"generates questionnaire"| node_backend
node_generation -->|"parses errors"| node_api_errors
node_questionnaires -.->|"loads exams"| node_backend
node_grading -->|"submits sheets"| node_backend
node_grading -->|"parses errors"| node_api_errors
node_graded_sheets -->|"loads results"| node_backend
node_profile -->|"reads and updates"| node_backend
node_profile -->|"parses errors"| node_api_errors
node_admin -->|"manages users"| node_backend
node_dashboard -.->|"loads dashboard"| node_backend

click node_program "https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Program.cs"
click node_session_middleware "https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Middleware/SessionValidationMiddleware.cs"
click node_session_service "https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Services/FrontendSessionService.cs"
click node_cookies "https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Helpers/AuthCookieHelper.cs"
click node_login "https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Pages/Login.cshtml.cs"
click node_registration "https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Pages/Register.cshtml.cs"
click node_upload "https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Pages/UploadPdf.cshtml.cs"
click node_documents_page "https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Pages/Documents.cshtml.cs"
click node_questionnaires "https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Pages/Questionnaires.cshtml.cs"
click node_generation "https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Pages/GenerateQuestionnaire.cshtml.cs"
click node_grading "https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Pages/GradeExam.cshtml.cs"
click node_graded_sheets "https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Pages/GradedSheets.cshtml.cs"
click node_profile "https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Pages/Profile.cshtml.cs"
click node_admin "https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Pages/Admin.cshtml.cs"
click node_dashboard "https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Pages/Dashboard.cshtml.cs"
click node_api_errors "https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Helpers/ApiErrorHelper.cs"

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_program,node_dashboard,node_api_errors,node_browser toneBlue
class node_session_middleware,node_session_service,node_cookies,node_login,node_registration toneAmber
class node_upload,node_documents_page,node_questionnaires,node_generation,node_grading,node_graded_sheets,node_backend toneMint
class node_profile,node_admin toneRose
```

## Components

### Web runtime

- [Razor app](https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Program.cs): `OCR_Frontend/Program.cs`
- [Dashboard](https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Pages/Dashboard.cshtml.cs): `OCR_Frontend/Pages/Dashboard.cshtml.cs`
- [API error parsing](https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Helpers/ApiErrorHelper.cs): `OCR_Frontend/Helpers/ApiErrorHelper.cs`

### Identity and access

- [Session validation](https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Middleware/SessionValidationMiddleware.cs): `OCR_Frontend/Middleware/SessionValidationMiddleware.cs`
- [Frontend instance](https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Services/FrontendSessionService.cs): `OCR_Frontend/Services/FrontendSessionService.cs`
- [Auth cookies](https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Helpers/AuthCookieHelper.cs): `OCR_Frontend/Helpers/AuthCookieHelper.cs`
- [Login](https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Pages/Login.cshtml.cs): `OCR_Frontend/Pages/Login.cshtml.cs`
- [Registration and recovery](https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Pages/Register.cshtml.cs): `OCR_Frontend/Pages/Register.cshtml.cs`

### Documents and exams

- [PDF upload](https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Pages/UploadPdf.cshtml.cs): `OCR_Frontend/Pages/UploadPdf.cshtml.cs`
- [Document library](https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Pages/Documents.cshtml.cs): `OCR_Frontend/Pages/Documents.cshtml.cs`
- [Questionnaires](https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Pages/Questionnaires.cshtml.cs): `OCR_Frontend/Pages/Questionnaires.cshtml.cs`
- [Questionnaire generation](https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Pages/GenerateQuestionnaire.cshtml.cs): `OCR_Frontend/Pages/GenerateQuestionnaire.cshtml.cs`
- [Exam grading](https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Pages/GradeExam.cshtml.cs): `OCR_Frontend/Pages/GradeExam.cshtml.cs`
- [Graded results](https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Pages/GradedSheets.cshtml.cs): `OCR_Frontend/Pages/GradedSheets.cshtml.cs`

### Account management

- [Profile](https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Pages/Profile.cshtml.cs): `OCR_Frontend/Pages/Profile.cshtml.cs`
- [Administration](https://github.com/kenithlabonite/ocr_frontend/blob/main/OCR_Frontend/Pages/Admin.cshtml.cs): `OCR_Frontend/Pages/Admin.cshtml.cs`

### Other components

- **User browser**
- **Backend API**

## Connections

- User browser → Razor app: requests pages (evidence: `OCR_Frontend/Program.cs`)
- Razor app → Session validation: registers middleware (evidence: `OCR_Frontend/Program.cs`)
- Razor app → Backend API: configures API client (evidence: `OCR_Frontend/Program.cs`)
- Session validation → Backend API: validates session (evidence: `OCR_Frontend/Middleware/SessionValidationMiddleware.cs`)
- Session validation → Auth cookies: clears cookies (evidence: `OCR_Frontend/Middleware/SessionValidationMiddleware.cs`)
- Session validation → Frontend instance: checks instance (evidence: `OCR_Frontend/Middleware/SessionValidationMiddleware.cs`)
- Login → Backend API: authenticates (evidence: `OCR_Frontend/Pages/Login.cshtml.cs`)
- Login → Auth cookies: sets session (evidence: `OCR_Frontend/Pages/Login.cshtml.cs`)
- Registration and recovery → API error parsing: parses errors (evidence: `OCR_Frontend/Pages/Register.cshtml.cs`)
- PDF upload → Backend API: uploads PDFs (evidence: `OCR_Frontend/Pages/UploadPdf.cshtml.cs`)
- Document library → Backend API: manages documents (evidence: `OCR_Frontend/Pages/Documents.cshtml.cs`)
- Document library → Auth cookies: attaches auth (evidence: `OCR_Frontend/Pages/Documents.cshtml.cs`)
- Questionnaire generation → Backend API: generates questionnaire (evidence: `OCR_Frontend/Pages/GenerateQuestionnaire.cshtml.cs`)
- Questionnaire generation → API error parsing: parses errors (evidence: `OCR_Frontend/Pages/GenerateQuestionnaire.cshtml.cs`)
- Questionnaires → Backend API: loads exams
- Exam grading → Backend API: submits sheets (evidence: `OCR_Frontend/Pages/GradeExam.cshtml.cs`)
- Exam grading → API error parsing: parses errors (evidence: `OCR_Frontend/Pages/GradeExam.cshtml.cs`)
- Graded results → Backend API: loads results (evidence: `OCR_Frontend/Pages/GradedSheets.cshtml.cs`)
- Profile → Backend API: reads and updates (evidence: `OCR_Frontend/Pages/Profile.cshtml.cs`)
- Profile → API error parsing: parses errors (evidence: `OCR_Frontend/Pages/Profile.cshtml.cs`)
- Administration → Backend API: manages users (evidence: `OCR_Frontend/Pages/Admin.cshtml.cs`)
- Dashboard → Backend API: loads dashboard
