# laith-alsurkhi/secure-student-portal architecture

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

- Interactive diagram: https://gitdiagram.com/laith-alsurkhi/secure-student-portal
- Repository: https://github.com/laith-alsurkhi/secure-student-portal

## Overview

The Secure Student Portal serves static browser pages and provides signup/login, authenticated profile management, and admin user, role, and audit-log workflows. The Express server mounts the API routes and applies shared security controls; route handlers enforce access, transform sensitive fields, and use MongoDB models. The source excerpts show the main route and storage relationships, but not the HTML-to-script wiring, so frontend page-to-script links are omitted.

Main entry points: [`backend/server.js`](https://github.com/laith-alsurkhi/secure-student-portal/blob/main/backend/server.js) (Express server), [`backend/database.js`](https://github.com/laith-alsurkhi/secure-student-portal/blob/main/backend/database.js) (MongoDB models), [`backend/routes/admin.js`](https://github.com/laith-alsurkhi/secure-student-portal/blob/main/backend/routes/admin.js) (Admin operations), [`backend/routes/auth.js`](https://github.com/laith-alsurkhi/secure-student-portal/blob/main/backend/routes/auth.js) (Signup and login)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Browser experience"]
  node_pages["Portal pages"]
  node_client_auth["Session client<br/>[auth.js]"]
  node_client_profile["Profile dashboard<br/>[dashboard.js]"]
  node_client_admin["Admin dashboard<br/>[admin.js]"]
end

subgraph group_runtime["Server and security"]
  node_server["Express server<br/>[server.js]"]
  node_auth_middleware["Session verification<br/>[auth.js]"]
  node_role_middleware["Role authorization<br/>[role.js]"]
end

subgraph group_workflows["Portal workflows"]
  node_auth_routes["Signup and login<br/>[auth.js]"]
  node_user_routes["Profile management<br/>[user.js]"]
  node_admin_routes["Admin operations<br/>[admin.js]"]
end

subgraph group_persistence["Data and integrations"]
  node_database[("MongoDB models<br/>[database.js]")]
  node_mongodb[("MongoDB")]
  node_turnstile["Turnstile verification"]
end

node_visitor(("Portal user"))

node_visitor -->|"uses"| node_pages
node_server -->|"serves"| node_pages
node_server -->|"mounts"| node_auth_routes
node_server -->|"mounts"| node_user_routes
node_server -->|"mounts"| node_admin_routes
node_client_auth -->|"requests API"| node_server
node_client_profile -->|"requests profile"| node_server
node_client_admin -->|"requests admin API"| node_server
node_auth_routes -->|"reads and writes"| node_database
node_auth_routes -->|"verifies challenge"| node_turnstile
node_user_routes -->|"protects routes"| node_auth_middleware
node_user_routes -->|"reads and writes"| node_database
node_admin_routes -->|"protects routes"| node_auth_middleware
node_admin_routes -->|"checks role"| node_role_middleware
node_admin_routes -->|"reads and writes"| node_database
node_auth_middleware -->|"loads user"| node_database
node_database -->|"connects"| node_mongodb

click node_pages "https://github.com/laith-alsurkhi/secure-student-portal/tree/main/frontend"
click node_client_auth "https://github.com/laith-alsurkhi/secure-student-portal/blob/main/frontend/js/auth.js"
click node_client_profile "https://github.com/laith-alsurkhi/secure-student-portal/blob/main/frontend/js/dashboard.js"
click node_client_admin "https://github.com/laith-alsurkhi/secure-student-portal/blob/main/frontend/js/admin.js"
click node_server "https://github.com/laith-alsurkhi/secure-student-portal/blob/main/backend/server.js"
click node_auth_routes "https://github.com/laith-alsurkhi/secure-student-portal/blob/main/backend/routes/auth.js"
click node_user_routes "https://github.com/laith-alsurkhi/secure-student-portal/blob/main/backend/routes/user.js"
click node_admin_routes "https://github.com/laith-alsurkhi/secure-student-portal/blob/main/backend/routes/admin.js"
click node_auth_middleware "https://github.com/laith-alsurkhi/secure-student-portal/blob/main/backend/middleware/auth.js"
click node_role_middleware "https://github.com/laith-alsurkhi/secure-student-portal/blob/main/backend/middleware/role.js"
click node_database "https://github.com/laith-alsurkhi/secure-student-portal/blob/main/backend/database.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_pages,node_client_auth,node_client_profile,node_client_admin,node_visitor toneBlue
class node_server,node_auth_middleware,node_role_middleware toneAmber
class node_auth_routes,node_user_routes,node_admin_routes toneMint
class node_database,node_mongodb,node_turnstile toneRose
```

## Components

### Browser experience

- [Portal pages](https://github.com/laith-alsurkhi/secure-student-portal/tree/main/frontend): `frontend`
- [Session client](https://github.com/laith-alsurkhi/secure-student-portal/blob/main/frontend/js/auth.js): `frontend/js/auth.js`
- [Profile dashboard](https://github.com/laith-alsurkhi/secure-student-portal/blob/main/frontend/js/dashboard.js): `frontend/js/dashboard.js`
- [Admin dashboard](https://github.com/laith-alsurkhi/secure-student-portal/blob/main/frontend/js/admin.js): `frontend/js/admin.js`

### Server and security

- [Express server](https://github.com/laith-alsurkhi/secure-student-portal/blob/main/backend/server.js): `backend/server.js`
- [Session verification](https://github.com/laith-alsurkhi/secure-student-portal/blob/main/backend/middleware/auth.js): `backend/middleware/auth.js`
- [Role authorization](https://github.com/laith-alsurkhi/secure-student-portal/blob/main/backend/middleware/role.js): `backend/middleware/role.js`

### Portal workflows

- [Signup and login](https://github.com/laith-alsurkhi/secure-student-portal/blob/main/backend/routes/auth.js): `backend/routes/auth.js`
- [Profile management](https://github.com/laith-alsurkhi/secure-student-portal/blob/main/backend/routes/user.js): `backend/routes/user.js`
- [Admin operations](https://github.com/laith-alsurkhi/secure-student-portal/blob/main/backend/routes/admin.js): `backend/routes/admin.js`

### Data and integrations

- [MongoDB models](https://github.com/laith-alsurkhi/secure-student-portal/blob/main/backend/database.js): `backend/database.js`
- **MongoDB**
- **Turnstile verification**

### Other components

- **Portal user**

## Connections

- Portal user → Portal pages: uses (evidence: `README.md`)
- Express server → Portal pages: serves (evidence: `backend/server.js`)
- Express server → Signup and login: mounts (evidence: `backend/server.js`)
- Express server → Profile management: mounts (evidence: `backend/server.js`)
- Express server → Admin operations: mounts (evidence: `backend/server.js`)
- Session client → Express server: requests API (evidence: `frontend/js/auth.js`)
- Profile dashboard → Express server: requests profile (evidence: `frontend/js/dashboard.js`)
- Admin dashboard → Express server: requests admin API (evidence: `frontend/js/admin.js`)
- Signup and login → MongoDB models: reads and writes (evidence: `backend/routes/auth.js`)
- Signup and login → Turnstile verification: verifies challenge (evidence: `backend/routes/auth.js`)
- Profile management → Session verification: protects routes (evidence: `backend/routes/user.js`)
- Profile management → MongoDB models: reads and writes (evidence: `backend/routes/user.js`)
- Admin operations → Session verification: protects routes (evidence: `backend/routes/admin.js`)
- Admin operations → Role authorization: checks role (evidence: `backend/routes/admin.js`)
- Admin operations → MongoDB models: reads and writes (evidence: `backend/routes/admin.js`)
- Session verification → MongoDB models: loads user (evidence: `backend/middleware/auth.js`)
- MongoDB models → MongoDB: connects (evidence: `backend/database.js`)
