# jinkyborja/essu-docuflow architecture

> Architecture diagram of the GitHub repository jinkyborja/essu-docuflow, 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/jinkyborja/essu-docuflow
- Repository: https://github.com/jinkyborja/essu-docuflow

## Overview

ESSU DocuFlow is a student document-request portal with staff review and release. Students register, submit requests and required files, then track status; staff review submissions, manage document templates and requirements, and approve, reject, or request corrections. Admins use the staff portal for additional management. The map highlights these distinct workflows, relational MySQL data access, Supabase file storage, authentication, and email. Some branches are documented in the README but their detailed route implementations were not sampled, so those links are dashed.

Main entry points: [`src/routes/student`](https://github.com/jinkyborja/essu-docuflow/tree/main/src/routes/student) (Student portal), [`src/routes/staff`](https://github.com/jinkyborja/essu-docuflow/tree/main/src/routes/staff) (Staff portal), [`src/routes/api/requests/[id]/+server.ts`](https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/api/requests/%5Bid%5D/%2Bserver.ts) (Review and decisions), [`src/lib/server/requirements.ts`](https://github.com/jinkyborja/essu-docuflow/blob/main/src/lib/server/requirements.ts) (Requirement data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_portals["Student and staff portals"]
  node_student_portal["Student portal"]
  node_staff_portal["Staff portal"]
  node_request_list["Staff request queue<br/>[+page.server.ts]"]
  node_request_review["Staff request detail<br/>[+page.server.ts]"]
  node_forms_library["Forms library UI"]
  node_file_preview["File preview<br/>[FilePreview.svelte]"]
  node_pdf_viewer["PDF viewer"]
  node_dashboard["Portal dashboards<br/>[+page.server.ts]"]
  node_student_dashboard["Student dashboard<br/>[+page.server.ts]"]
end

subgraph group_workflow["Request workflow"]
  node_request_pages["Request submission<br/>[+page.server.ts]"]
  node_requests_api["Request handling<br/>[+server.ts]"]
  node_request_detail_api["Review and decisions<br/>[+server.ts]"]
  node_request_requirements_api["Requirement uploads<br/>[+server.ts]"]
  node_lifecycle["Request lifecycle"]
  node_documents_api["Document catalog<br/>[+server.ts]"]
  node_forms_api["Forms service<br/>[+server.ts]"]
  node_activity["Activity history<br/>[activity-log.ts]"]
  node_masterlist["Student masterlist<br/>[+server.ts]"]
end

subgraph group_data["Data and files"]
  node_requirements["Requirement data<br/>[requirements.ts]"]
  node_db[("MySQL access<br/>[db.ts]")]
  node_storage_api["Signed file access<br/>[+server.ts]"]
  node_supabase[("Supabase Storage")]
  node_student_files["Student file access<br/>[student-files.ts]"]
end

subgraph group_identity["Identity and messaging"]
  node_signup["Registration<br/>[+server.ts]"]
  node_login["Login and verification<br/>[+server.ts]"]
  node_jwt["Session tokens<br/>[jwt.ts]"]
  node_email["Email delivery<br/>[email.ts]"]
  node_resend["Resend"]
  node_profile["Student profile and ID<br/>[+server.ts]"]
end

node_student(("Student"))
node_staff(("Staff and admin"))

node_student -.->|"uses"| node_student_portal
node_staff -.->|"uses"| node_staff_portal
node_student_portal -.->|"registers via"| node_signup
node_student_portal -.->|"signs in via"| node_login
node_signup -.->|"creates session"| node_jwt
node_login -.->|"signs session"| node_jwt
node_student_portal -.->|"submits through"| node_request_pages
node_request_pages -.->|"creates request"| node_requests_api
node_requests_api -.->|"queries"| node_db
node_requests_api -.->|"loads requirements"| node_requirements
node_request_requirements_api -.->|"writes requirements"| node_requirements
node_request_requirements_api -.->|"uploads files"| node_supabase
node_staff_portal -.->|"lists requests"| node_request_list
node_request_list -.->|"opens review"| node_request_review
node_request_review -.->|"reviews via"| node_request_detail_api
node_request_detail_api -.->|"changes status"| node_lifecycle
node_request_detail_api -.->|"updates records"| node_db
node_request_detail_api -.->|"sends status email"| node_email
node_email -.->|"delivers mail"| node_resend
node_request_detail_api -.->|"records activity"| node_activity
node_staff_portal -.->|"manages documents"| node_documents_api
node_documents_api -.->|"reads and writes"| node_requirements
node_requirements -->|"queries and updates"| node_db
node_staff_portal -.->|"manages forms"| node_forms_library
node_forms_library -.->|"loads and saves"| node_forms_api
node_forms_api -.->|"queries"| node_db
node_student_portal -.->|"opens files"| node_student_files
node_file_preview -->|"gets file URL"| node_student_files
node_file_preview -->|"requests template URL"| node_storage_api
node_file_preview -->|"renders PDF"| node_pdf_viewer
node_student_files -.->|"accesses files"| node_supabase
node_storage_api -.->|"signs downloads"| node_supabase
node_student_portal -.->|"views status"| node_student_dashboard
node_staff_portal -.->|"views metrics"| node_dashboard
node_student_portal -.->|"manages profile"| node_profile
node_signup -.->|"collects student ID"| node_profile
node_staff_portal -.->|"manages students"| node_masterlist

click node_student_portal "https://github.com/jinkyborja/essu-docuflow/tree/main/src/routes/student"
click node_staff_portal "https://github.com/jinkyborja/essu-docuflow/tree/main/src/routes/staff"
click node_signup "https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/api/register/%2Bserver.ts"
click node_login "https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/api/login/%2Bserver.ts"
click node_request_pages "https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/student/request/%2Bpage.server.ts"
click node_requests_api "https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/api/requests/%2Bserver.ts"
click node_request_detail_api "https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/api/requests/%5Bid%5D/%2Bserver.ts"
click node_request_requirements_api "https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/api/requests/%5Bid%5D/requirements/%2Bserver.ts"
click node_lifecycle "https://github.com/jinkyborja/essu-docuflow/blob/main/src/lib/request-lifecycle.ts"
click node_request_list "https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/staff/requests/%2Bpage.server.ts"
click node_request_review "https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/staff/requests/%5Brequest_id%5D/%2Bpage.server.ts"
click node_documents_api "https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/api/documents/%2Bserver.ts"
click node_requirements "https://github.com/jinkyborja/essu-docuflow/blob/main/src/lib/server/requirements.ts"
click node_forms_api "https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/api/forms/%2Bserver.ts"
click node_forms_library "https://github.com/jinkyborja/essu-docuflow/blob/main/src/lib/components/forms/FormsLibrary.svelte"
click node_db "https://github.com/jinkyborja/essu-docuflow/blob/main/src/lib/server/db.ts"
click node_storage_api "https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/api/storage/%2Bserver.ts"
click node_student_files "https://github.com/jinkyborja/essu-docuflow/blob/main/src/lib/student-files.ts"
click node_file_preview "https://github.com/jinkyborja/essu-docuflow/blob/main/src/lib/components/ui/FilePreview.svelte"
click node_pdf_viewer "https://github.com/jinkyborja/essu-docuflow/blob/main/src/lib/components/forms/PdfDocumentViewer.svelte"
click node_jwt "https://github.com/jinkyborja/essu-docuflow/blob/main/src/lib/server/jwt.ts"
click node_email "https://github.com/jinkyborja/essu-docuflow/blob/main/src/lib/server/email.ts"
click node_activity "https://github.com/jinkyborja/essu-docuflow/blob/main/src/lib/server/activity-log.ts"
click node_dashboard "https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/staff/dashboard/%2Bpage.server.ts"
click node_student_dashboard "https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/student/dashboard/%2Bpage.server.ts"
click node_profile "https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/api/profile/%2Bserver.ts"
click node_masterlist "https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/api/masterlist/%2Bserver.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_student_portal,node_staff_portal,node_request_list,node_request_review,node_forms_library,node_file_preview,node_pdf_viewer,node_dashboard,node_student_dashboard toneBlue
class node_request_pages,node_requests_api,node_request_detail_api,node_request_requirements_api,node_lifecycle,node_documents_api,node_forms_api,node_activity,node_masterlist toneAmber
class node_requirements,node_db,node_storage_api,node_supabase,node_student_files toneMint
class node_signup,node_login,node_jwt,node_email,node_resend,node_profile toneRose
class node_student,node_staff toneIndigo
```

## Components

### Student and staff portals

- [Student portal](https://github.com/jinkyborja/essu-docuflow/tree/main/src/routes/student): `src/routes/student`
- [Staff portal](https://github.com/jinkyborja/essu-docuflow/tree/main/src/routes/staff): `src/routes/staff`
- [Staff request queue](https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/staff/requests/%2Bpage.server.ts): `src/routes/staff/requests/+page.server.ts`
- [Staff request detail](https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/staff/requests/%5Brequest_id%5D/%2Bpage.server.ts): `src/routes/staff/requests/[request_id]/+page.server.ts`
- [Forms library UI](https://github.com/jinkyborja/essu-docuflow/blob/main/src/lib/components/forms/FormsLibrary.svelte): `src/lib/components/forms/FormsLibrary.svelte`
- [File preview](https://github.com/jinkyborja/essu-docuflow/blob/main/src/lib/components/ui/FilePreview.svelte): `src/lib/components/ui/FilePreview.svelte`
- [PDF viewer](https://github.com/jinkyborja/essu-docuflow/blob/main/src/lib/components/forms/PdfDocumentViewer.svelte): `src/lib/components/forms/PdfDocumentViewer.svelte`
- [Portal dashboards](https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/staff/dashboard/%2Bpage.server.ts): `src/routes/staff/dashboard/+page.server.ts`
- [Student dashboard](https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/student/dashboard/%2Bpage.server.ts): `src/routes/student/dashboard/+page.server.ts`

### Request workflow

- [Request submission](https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/student/request/%2Bpage.server.ts): `src/routes/student/request/+page.server.ts`
- [Request handling](https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/api/requests/%2Bserver.ts): `src/routes/api/requests/+server.ts`
- [Review and decisions](https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/api/requests/%5Bid%5D/%2Bserver.ts): `src/routes/api/requests/[id]/+server.ts`
- [Requirement uploads](https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/api/requests/%5Bid%5D/requirements/%2Bserver.ts): `src/routes/api/requests/[id]/requirements/+server.ts`
- [Request lifecycle](https://github.com/jinkyborja/essu-docuflow/blob/main/src/lib/request-lifecycle.ts): `src/lib/request-lifecycle.ts`
- [Document catalog](https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/api/documents/%2Bserver.ts): `src/routes/api/documents/+server.ts`
- [Forms service](https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/api/forms/%2Bserver.ts): `src/routes/api/forms/+server.ts`
- [Activity history](https://github.com/jinkyborja/essu-docuflow/blob/main/src/lib/server/activity-log.ts): `src/lib/server/activity-log.ts`
- [Student masterlist](https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/api/masterlist/%2Bserver.ts): `src/routes/api/masterlist/+server.ts`

### Data and files

- [Requirement data](https://github.com/jinkyborja/essu-docuflow/blob/main/src/lib/server/requirements.ts): `src/lib/server/requirements.ts`
- [MySQL access](https://github.com/jinkyborja/essu-docuflow/blob/main/src/lib/server/db.ts): `src/lib/server/db.ts`
- [Signed file access](https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/api/storage/%2Bserver.ts): `src/routes/api/storage/+server.ts`
- **Supabase Storage**
- [Student file access](https://github.com/jinkyborja/essu-docuflow/blob/main/src/lib/student-files.ts): `src/lib/student-files.ts`

### Identity and messaging

- [Registration](https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/api/register/%2Bserver.ts): `src/routes/api/register/+server.ts`
- [Login and verification](https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/api/login/%2Bserver.ts): `src/routes/api/login/+server.ts`
- [Session tokens](https://github.com/jinkyborja/essu-docuflow/blob/main/src/lib/server/jwt.ts): `src/lib/server/jwt.ts`
- [Email delivery](https://github.com/jinkyborja/essu-docuflow/blob/main/src/lib/server/email.ts): `src/lib/server/email.ts`
- **Resend**
- [Student profile and ID](https://github.com/jinkyborja/essu-docuflow/blob/main/src/routes/api/profile/%2Bserver.ts): `src/routes/api/profile/+server.ts`

### Other components

- **Student**
- **Staff and admin**

## Connections

- Student → Student portal: uses
- Staff and admin → Staff portal: uses
- Student portal → Registration: registers via
- Student portal → Login and verification: signs in via
- Registration → Session tokens: creates session
- Login and verification → Session tokens: signs session
- Student portal → Request submission: submits through
- Request submission → Request handling: creates request
- Request handling → MySQL access: queries
- Request handling → Requirement data: loads requirements
- Requirement uploads → Requirement data: writes requirements
- Requirement uploads → Supabase Storage: uploads files
- Staff portal → Staff request queue: lists requests
- Staff request queue → Staff request detail: opens review
- Staff request detail → Review and decisions: reviews via
- Review and decisions → Request lifecycle: changes status
- Review and decisions → MySQL access: updates records
- Review and decisions → Email delivery: sends status email
- Email delivery → Resend: delivers mail
- Review and decisions → Activity history: records activity
- Staff portal → Document catalog: manages documents
- Document catalog → Requirement data: reads and writes
- Requirement data → MySQL access: queries and updates (evidence: `src/lib/server/requirements.ts`)
- Staff portal → Forms library UI: manages forms
- Forms library UI → Forms service: loads and saves
- Forms service → MySQL access: queries
- Student portal → Student file access: opens files
- File preview → Student file access: gets file URL (evidence: `src/lib/components/ui/FilePreview.svelte`)
- File preview → Signed file access: requests template URL (evidence: `src/lib/components/ui/FilePreview.svelte`)
- File preview → PDF viewer: renders PDF (evidence: `src/lib/components/ui/FilePreview.svelte`)
- Student file access → Supabase Storage: accesses files
- Signed file access → Supabase Storage: signs downloads
- Student portal → Student dashboard: views status
- Staff portal → Portal dashboards: views metrics
- Student portal → Student profile and ID: manages profile
- Registration → Student profile and ID: collects student ID
- Staff portal → Student masterlist: manages students
