# kirawat1/co_project architecture

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

- Interactive diagram: https://gitdiagram.com/kirawat1/co_project
- Repository: https://github.com/kirawat1/co_project

## Overview

This is a role-based co-operative education management system for students, teachers, and staff. Students maintain profiles, apply for placements, submit required documents, and coordinate supervision; teachers review applications and documents and manage supervision; staff administer periods, companies, letters, and system-wide operations. The React application sends requests to an Express API, whose routes apply authentication and dispatch to domain controllers backed by Prisma/MySQL. The README documents the principal workflows and KKU SSO; excerpts show selected routing, persistence, and registration integration, but not every subsystem’s internal wiring.

Main entry points: [`backend/config/prismaClient.js`](https://github.com/kirawat1/co_project/blob/main/backend/config/prismaClient.js) (Prisma data access), [`backend/server.js`](https://github.com/kirawat1/co_project/blob/main/backend/server.js) (Express API server), [`backend/routes/studentRoutes.js`](https://github.com/kirawat1/co_project/blob/main/backend/routes/studentRoutes.js) (Student routes), [`Frontend/src/App.tsx`](https://github.com/kirawat1/co_project/blob/main/Frontend/src/App.tsx) (Role-based app entry)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Web application"]
  node_web_entry["Role-based app entry<br/>[App.tsx]"]
  node_student_ui["Student workspace<br/>[S_App.tsx]"]
  node_teacher_ui["Teacher workspace<br/>[T_App.tsx]"]
  node_staff_ui["Staff workspace<br/>[A_App.tsx]"]
  node_web_api["API request client<br/>[apiFetch.ts]"]
end

subgraph group_api["API and identity"]
  node_express["Express API server<br/>[server.js]"]
  node_auth_routes["Authentication routes<br/>[authRoutes.js]"]
  node_auth_logic["Authentication controller<br/>[authController.js]"]
  node_auth_guard["Token and role guards<br/>[authMiddleware.js]"]
  node_student_routes["Student routes<br/>[studentRoutes.js]"]
  node_coop_routes["Co-op routes<br/>[coopRoutes.js]"]
  node_admin_routes["Admin routes<br/>[adminRoutes.js]"]
  node_supervision_routes["Supervision routes"]
end

subgraph group_coop["Co-op operations"]
  node_student_domain["Student profiles and sync"]
  node_coop_domain["Applications and documents<br/>[docController.js]"]
  node_admin_docs["Staff document review"]
  node_periods["Co-op period management"]
  node_teacher_domain["Teacher review"]
  node_config["Program configuration"]
end

subgraph group_supervision["Supervision"]
  node_supervision_domain["Supervision scheduling"]
  node_supervision_eval["Supervision evaluation"]
end

subgraph group_data["Persistence and integrations"]
  node_prisma["Prisma data access<br/>[prismaClient.js]"]
  node_mysql[("MySQL database")]
  node_kku_reg["KKU registration API"]
  node_kku_service["Registration service<br/>[kkuRegService.js]"]
end

node_users(("Student, teacher, staff"))

node_users -->|"use"| node_web_entry
node_web_entry -->|"selects role app"| node_student_ui
node_web_entry -->|"selects role app"| node_teacher_ui
node_web_entry -->|"selects role app"| node_staff_ui
node_student_ui -.->|"requests data"| node_web_api
node_teacher_ui -.->|"requests data"| node_web_api
node_staff_ui -.->|"requests data"| node_web_api
node_web_api -.->|"calls API"| node_express
node_express -->|"mounts routes"| node_auth_routes
node_express -->|"mounts routes"| node_student_routes
node_express -->|"mounts routes"| node_coop_routes
node_express -->|"mounts routes"| node_admin_routes
node_express -->|"mounts routes"| node_supervision_routes
node_auth_routes -->|"dispatches to"| node_auth_logic
node_student_routes -->|"checks access"| node_auth_guard
node_student_routes -->|"dispatches to"| node_student_domain
node_student_routes -->|"dispatches to"| node_coop_domain
node_student_routes -->|"dispatches to"| node_periods
node_coop_routes -->|"checks access"| node_auth_guard
node_coop_routes -->|"dispatches to"| node_coop_domain
node_admin_routes -->|"dispatches to"| node_admin_docs
node_admin_routes -->|"dispatches to"| node_periods
node_admin_routes -->|"dispatches to"| node_config
node_supervision_routes -->|"dispatches to"| node_supervision_domain
node_supervision_routes -->|"dispatches to"| node_supervision_eval
node_supervision_routes -->|"dispatches to"| node_config
node_auth_routes -.->|"guards requests"| node_auth_guard
node_student_domain -->|"reads and writes"| node_prisma
node_coop_domain -->|"reads and writes"| node_prisma
node_admin_docs -->|"reads and writes"| node_prisma
node_teacher_domain -->|"reads and writes"| node_prisma
node_supervision_domain -->|"reads and writes"| node_prisma
node_config -->|"reads and writes"| node_prisma
node_prisma -.->|"persists records"| node_mysql
node_student_domain -->|"syncs student data"| node_kku_service
node_kku_service -->|"requests registration data"| node_kku_reg
node_users -->|"sign in"| node_auth_logic
node_users -->|"sync profile"| node_student_domain
node_users -->|"submit documents"| node_coop_domain
node_users -->|"review applications"| node_teacher_domain
node_users -->|"coordinate visits"| node_supervision_domain
node_users -->|"manage periods"| node_periods
node_users -->|"issue letters"| node_admin_docs

click node_web_entry "https://github.com/kirawat1/co_project/blob/main/Frontend/src/App.tsx"
click node_student_ui "https://github.com/kirawat1/co_project/blob/main/Frontend/src/components/S_App.tsx"
click node_teacher_ui "https://github.com/kirawat1/co_project/blob/main/Frontend/src/components/T_App.tsx"
click node_staff_ui "https://github.com/kirawat1/co_project/blob/main/Frontend/src/components/A_App.tsx"
click node_web_api "https://github.com/kirawat1/co_project/blob/main/Frontend/src/utils/apiFetch.ts"
click node_express "https://github.com/kirawat1/co_project/blob/main/backend/server.js"
click node_auth_routes "https://github.com/kirawat1/co_project/blob/main/backend/routes/authRoutes.js"
click node_auth_logic "https://github.com/kirawat1/co_project/blob/main/backend/controllers/authController.js"
click node_auth_guard "https://github.com/kirawat1/co_project/blob/main/backend/middlewares/authMiddleware.js"
click node_student_routes "https://github.com/kirawat1/co_project/blob/main/backend/routes/studentRoutes.js"
click node_coop_routes "https://github.com/kirawat1/co_project/blob/main/backend/routes/coopRoutes.js"
click node_admin_routes "https://github.com/kirawat1/co_project/blob/main/backend/routes/adminRoutes.js"
click node_supervision_routes "https://github.com/kirawat1/co_project/blob/main/backend/routes/supervisionRoutes.js"
click node_student_domain "https://github.com/kirawat1/co_project/blob/main/backend/controllers/studentController.js"
click node_coop_domain "https://github.com/kirawat1/co_project/blob/main/backend/controllers/docController.js"
click node_admin_docs "https://github.com/kirawat1/co_project/blob/main/backend/controllers/adminDocController.js"
click node_periods "https://github.com/kirawat1/co_project/blob/main/backend/controllers/coopPeriodController.js"
click node_teacher_domain "https://github.com/kirawat1/co_project/blob/main/backend/controllers/teacherController.js"
click node_supervision_domain "https://github.com/kirawat1/co_project/blob/main/backend/controllers/supervisionController.js"
click node_supervision_eval "https://github.com/kirawat1/co_project/blob/main/backend/controllers/supervisionEvalController.js"
click node_config "https://github.com/kirawat1/co_project/blob/main/backend/controllers/configController.js"
click node_prisma "https://github.com/kirawat1/co_project/blob/main/backend/config/prismaClient.js"
click node_kku_service "https://github.com/kirawat1/co_project/blob/main/backend/services/kkuRegService.js"

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_entry,node_student_ui,node_teacher_ui,node_staff_ui,node_web_api toneBlue
class node_express,node_auth_routes,node_auth_logic,node_auth_guard,node_student_routes,node_coop_routes,node_admin_routes,node_supervision_routes toneAmber
class node_student_domain,node_coop_domain,node_admin_docs,node_periods,node_teacher_domain,node_config toneMint
class node_supervision_domain,node_supervision_eval toneRose
class node_prisma,node_mysql,node_kku_reg,node_kku_service,node_users toneIndigo
```

## Components

### Web application

- [Role-based app entry](https://github.com/kirawat1/co_project/blob/main/Frontend/src/App.tsx): `Frontend/src/App.tsx`
- [Student workspace](https://github.com/kirawat1/co_project/blob/main/Frontend/src/components/S_App.tsx): `Frontend/src/components/S_App.tsx`
- [Teacher workspace](https://github.com/kirawat1/co_project/blob/main/Frontend/src/components/T_App.tsx): `Frontend/src/components/T_App.tsx`
- [Staff workspace](https://github.com/kirawat1/co_project/blob/main/Frontend/src/components/A_App.tsx): `Frontend/src/components/A_App.tsx`
- [API request client](https://github.com/kirawat1/co_project/blob/main/Frontend/src/utils/apiFetch.ts): `Frontend/src/utils/apiFetch.ts`

### API and identity

- [Express API server](https://github.com/kirawat1/co_project/blob/main/backend/server.js): `backend/server.js`
- [Authentication routes](https://github.com/kirawat1/co_project/blob/main/backend/routes/authRoutes.js): `backend/routes/authRoutes.js`
- [Authentication controller](https://github.com/kirawat1/co_project/blob/main/backend/controllers/authController.js): `backend/controllers/authController.js`
- [Token and role guards](https://github.com/kirawat1/co_project/blob/main/backend/middlewares/authMiddleware.js): `backend/middlewares/authMiddleware.js`
- [Student routes](https://github.com/kirawat1/co_project/blob/main/backend/routes/studentRoutes.js): `backend/routes/studentRoutes.js`
- [Co-op routes](https://github.com/kirawat1/co_project/blob/main/backend/routes/coopRoutes.js): `backend/routes/coopRoutes.js`
- [Admin routes](https://github.com/kirawat1/co_project/blob/main/backend/routes/adminRoutes.js): `backend/routes/adminRoutes.js`
- [Supervision routes](https://github.com/kirawat1/co_project/blob/main/backend/routes/supervisionRoutes.js): `backend/routes/supervisionRoutes.js`

### Co-op operations

- [Student profiles and sync](https://github.com/kirawat1/co_project/blob/main/backend/controllers/studentController.js): `backend/controllers/studentController.js`
- [Applications and documents](https://github.com/kirawat1/co_project/blob/main/backend/controllers/docController.js): `backend/controllers/docController.js`
- [Staff document review](https://github.com/kirawat1/co_project/blob/main/backend/controllers/adminDocController.js): `backend/controllers/adminDocController.js`
- [Co-op period management](https://github.com/kirawat1/co_project/blob/main/backend/controllers/coopPeriodController.js): `backend/controllers/coopPeriodController.js`
- [Teacher review](https://github.com/kirawat1/co_project/blob/main/backend/controllers/teacherController.js): `backend/controllers/teacherController.js`
- [Program configuration](https://github.com/kirawat1/co_project/blob/main/backend/controllers/configController.js): `backend/controllers/configController.js`

### Supervision

- [Supervision scheduling](https://github.com/kirawat1/co_project/blob/main/backend/controllers/supervisionController.js): `backend/controllers/supervisionController.js`
- [Supervision evaluation](https://github.com/kirawat1/co_project/blob/main/backend/controllers/supervisionEvalController.js): `backend/controllers/supervisionEvalController.js`

### Persistence and integrations

- [Prisma data access](https://github.com/kirawat1/co_project/blob/main/backend/config/prismaClient.js): `backend/config/prismaClient.js`
- **MySQL database**
- **KKU registration API**
- [Registration service](https://github.com/kirawat1/co_project/blob/main/backend/services/kkuRegService.js): `backend/services/kkuRegService.js`

### Other components

- **Student, teacher, staff**

## Connections

- Student, teacher, staff → Role-based app entry: use (evidence: `Frontend/src/App.tsx`)
- Role-based app entry → Student workspace: selects role app (evidence: `Frontend/src/App.tsx`)
- Role-based app entry → Teacher workspace: selects role app (evidence: `Frontend/src/App.tsx`)
- Role-based app entry → Staff workspace: selects role app (evidence: `Frontend/src/App.tsx`)
- Student workspace → API request client: requests data
- Teacher workspace → API request client: requests data
- Staff workspace → API request client: requests data
- API request client → Express API server: calls API
- Express API server → Authentication routes: mounts routes (evidence: `backend/server.js`)
- Express API server → Student routes: mounts routes (evidence: `backend/server.js`)
- Express API server → Co-op routes: mounts routes (evidence: `backend/server.js`)
- Express API server → Admin routes: mounts routes (evidence: `backend/server.js`)
- Express API server → Supervision routes: mounts routes (evidence: `backend/server.js`)
- Authentication routes → Authentication controller: dispatches to (evidence: `backend/controllers/authController.js`)
- Student routes → Token and role guards: checks access (evidence: `backend/routes/studentRoutes.js`)
- Student routes → Student profiles and sync: dispatches to (evidence: `backend/routes/studentRoutes.js`)
- Student routes → Applications and documents: dispatches to (evidence: `backend/routes/studentRoutes.js`)
- Student routes → Co-op period management: dispatches to (evidence: `backend/routes/studentRoutes.js`)
- Co-op routes → Token and role guards: checks access (evidence: `backend/routes/coopRoutes.js`)
- Co-op routes → Applications and documents: dispatches to (evidence: `backend/routes/coopRoutes.js`)
- Admin routes → Staff document review: dispatches to (evidence: `backend/routes/adminRoutes.js`)
- Admin routes → Co-op period management: dispatches to (evidence: `backend/routes/adminRoutes.js`)
- Admin routes → Program configuration: dispatches to (evidence: `backend/routes/adminRoutes.js`)
- Supervision routes → Supervision scheduling: dispatches to (evidence: `backend/routes/supervisionRoutes.js`)
- Supervision routes → Supervision evaluation: dispatches to (evidence: `backend/routes/supervisionRoutes.js`)
- Supervision routes → Program configuration: dispatches to (evidence: `backend/routes/supervisionRoutes.js`)
- Authentication routes → Token and role guards: guards requests
- Student profiles and sync → Prisma data access: reads and writes (evidence: `backend/controllers/studentController.js`)
- Applications and documents → Prisma data access: reads and writes (evidence: `backend/controllers/docController.js`)
- Staff document review → Prisma data access: reads and writes (evidence: `backend/controllers/adminDocController.js`)
- Teacher review → Prisma data access: reads and writes (evidence: `backend/controllers/teacherController.js`)
- Supervision scheduling → Prisma data access: reads and writes (evidence: `backend/controllers/supervisionController.js`)
- Program configuration → Prisma data access: reads and writes (evidence: `backend/controllers/configController.js`)
- Prisma data access → MySQL database: persists records
- Student profiles and sync → Registration service: syncs student data (evidence: `backend/controllers/studentController.js`)
- Registration service → KKU registration API: requests registration data (evidence: `backend/services/kkuRegService.js`)
- Student, teacher, staff → Authentication controller: sign in (evidence: `README.md`)
- Student, teacher, staff → Student profiles and sync: sync profile (evidence: `README.md`)
- Student, teacher, staff → Applications and documents: submit documents (evidence: `README.md`)
- Student, teacher, staff → Teacher review: review applications (evidence: `README.md`)
- Student, teacher, staff → Supervision scheduling: coordinate visits (evidence: `README.md`)
- Student, teacher, staff → Co-op period management: manage periods (evidence: `README.md`)
- Student, teacher, staff → Staff document review: issue letters (evidence: `README.md`)
