# laylaaza/schoolportaal architecture

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

- Interactive diagram: https://gitdiagram.com/laylaaza/schoolportaal
- Repository: https://github.com/laylaaza/schoolportaal

## Overview

Security Playground is a role-based school portal for students, teachers, and administrators. Users sign in, then reach role-specific dashboards: students view their own records, teachers browse and search student records, and administrators manage users and roles. Server actions handle login, logout, and account mutations; authorization checks protect server-rendered pages and record access. The repository layer serves portal data from MySQL, while password helpers verify and hash credentials. Relationships for unsampled routes are based on the SOURCE INDEX; implementation details beyond the excerpts are not assumed.

Main entry points: [`lib/repository.ts`](https://github.com/laylaaza/schoolportaal/blob/main/lib/repository.ts) (Data repository), [`components/records.tsx`](https://github.com/laylaaza/schoolportaal/blob/main/components/records.tsx) (Record views and access), [`lib/auth.ts`](https://github.com/laylaaza/schoolportaal/blob/main/lib/auth.ts) (Session authorization), [`app/actions.ts`](https://github.com/laylaaza/schoolportaal/blob/main/app/actions.ts) (Server actions)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_experience["Portal experience"]
  node_home["Role redirect<br/>[page.tsx]"]
  node_login_view["Login page<br/>[page.tsx]"]
  node_forms["Login and user forms<br/>[forms.tsx]"]
  node_student_portal["Student portal<br/>[page.tsx]"]
  node_teacher_portal["Teacher portal<br/>[page.tsx]"]
  node_admin_portal["Admin portal<br/>[page.tsx]"]
  node_admin_users["User administration<br/>[page.tsx]"]
  node_add_user["Add user page<br/>[page.tsx]"]
  node_shell["Role-aware shell<br/>[shell.tsx]"]
end

subgraph group_identity["Identity and access"]
  node_auth["Session authorization<br/>[auth.ts]"]
  node_actions["Server actions<br/>[actions.ts]"]
  node_passwords["Password hashing<br/>[passwords.cjs]"]
end

subgraph group_records["School records"]
  node_student_search["Student search form<br/>[student-search.tsx]"]
  node_record_views["Record views and access<br/>[records.tsx]"]
  node_models["Portal data types<br/>[models.ts]"]
end

subgraph group_persistence["Persistence and credentials"]
  node_repository["Data repository<br/>[repository.ts]"]
  node_mysql[("MySQL database<br/>[db.ts]")]
end

node_user(("Portal user"))

node_user -->|"opens portal"| node_home
node_home -->|"checks session"| node_auth
node_home -->|"redirects unauthenticated"| node_login_view
node_user -->|"submits credentials"| node_login_view
node_login_view -->|"renders"| node_forms
node_forms -->|"submits login"| node_actions
node_actions -->|"authenticates and mutates"| node_repository
node_actions -->|"verifies passwords"| node_passwords
node_repository -->|"hashes new passwords"| node_passwords
node_repository -->|"queries and writes"| node_mysql
node_auth -->|"loads session user"| node_repository
node_student_portal -->|"requires student"| node_auth
node_student_portal -->|"loads own record"| node_repository
node_student_portal -->|"renders student data"| node_record_views
node_teacher_portal -->|"requires teacher"| node_auth
node_teacher_portal -->|"renders search"| node_student_search
node_teacher_portal -->|"renders student table"| node_record_views
node_record_views -->|"loads and searches records"| node_repository
node_admin_portal -->|"requires administrator"| node_auth
node_admin_portal -->|"renders user records"| node_record_views
node_admin_users -->|"renders user management"| node_record_views
node_add_user -->|"renders account form"| node_forms
node_forms -->|"uses role types"| node_models
node_record_views -->|"uses student types"| node_models
node_shell -->|"loads student link data"| node_repository
node_actions -->|"checks admin access"| node_auth

click node_home "https://github.com/laylaaza/schoolportaal/blob/main/app/page.tsx"
click node_login_view "https://github.com/laylaaza/schoolportaal/blob/main/app/login/page.tsx"
click node_forms "https://github.com/laylaaza/schoolportaal/blob/main/components/forms.tsx"
click node_student_portal "https://github.com/laylaaza/schoolportaal/blob/main/app/student/page.tsx"
click node_teacher_portal "https://github.com/laylaaza/schoolportaal/blob/main/app/teacher/page.tsx"
click node_admin_portal "https://github.com/laylaaza/schoolportaal/blob/main/app/admin/page.tsx"
click node_admin_users "https://github.com/laylaaza/schoolportaal/blob/main/app/admin/users/page.tsx"
click node_add_user "https://github.com/laylaaza/schoolportaal/blob/main/app/admin/users/new/page.tsx"
click node_shell "https://github.com/laylaaza/schoolportaal/blob/main/components/shell.tsx"
click node_auth "https://github.com/laylaaza/schoolportaal/blob/main/lib/auth.ts"
click node_actions "https://github.com/laylaaza/schoolportaal/blob/main/app/actions.ts"
click node_passwords "https://github.com/laylaaza/schoolportaal/blob/main/lib/passwords.cjs"
click node_student_search "https://github.com/laylaaza/schoolportaal/blob/main/components/student-search.tsx"
click node_record_views "https://github.com/laylaaza/schoolportaal/blob/main/components/records.tsx"
click node_models "https://github.com/laylaaza/schoolportaal/blob/main/lib/models.ts"
click node_repository "https://github.com/laylaaza/schoolportaal/blob/main/lib/repository.ts"
click node_mysql "https://github.com/laylaaza/schoolportaal/blob/main/lib/db.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_home,node_login_view,node_forms,node_student_portal,node_teacher_portal,node_admin_portal,node_admin_users,node_add_user,node_shell,node_user toneBlue
class node_auth,node_actions,node_passwords toneAmber
class node_student_search,node_record_views,node_models toneMint
class node_repository,node_mysql toneRose
```

## Components

### Portal experience

- [Role redirect](https://github.com/laylaaza/schoolportaal/blob/main/app/page.tsx): `app/page.tsx`
- [Login page](https://github.com/laylaaza/schoolportaal/blob/main/app/login/page.tsx): `app/login/page.tsx`
- [Login and user forms](https://github.com/laylaaza/schoolportaal/blob/main/components/forms.tsx): `components/forms.tsx`
- [Student portal](https://github.com/laylaaza/schoolportaal/blob/main/app/student/page.tsx): `app/student/page.tsx`
- [Teacher portal](https://github.com/laylaaza/schoolportaal/blob/main/app/teacher/page.tsx): `app/teacher/page.tsx`
- [Admin portal](https://github.com/laylaaza/schoolportaal/blob/main/app/admin/page.tsx): `app/admin/page.tsx`
- [User administration](https://github.com/laylaaza/schoolportaal/blob/main/app/admin/users/page.tsx): `app/admin/users/page.tsx`
- [Add user page](https://github.com/laylaaza/schoolportaal/blob/main/app/admin/users/new/page.tsx): `app/admin/users/new/page.tsx`
- [Role-aware shell](https://github.com/laylaaza/schoolportaal/blob/main/components/shell.tsx): `components/shell.tsx`

### Identity and access

- [Session authorization](https://github.com/laylaaza/schoolportaal/blob/main/lib/auth.ts): `lib/auth.ts`
- [Server actions](https://github.com/laylaaza/schoolportaal/blob/main/app/actions.ts): `app/actions.ts`
- [Password hashing](https://github.com/laylaaza/schoolportaal/blob/main/lib/passwords.cjs): `lib/passwords.cjs`

### School records

- [Student search form](https://github.com/laylaaza/schoolportaal/blob/main/components/student-search.tsx): `components/student-search.tsx`
- [Record views and access](https://github.com/laylaaza/schoolportaal/blob/main/components/records.tsx): `components/records.tsx`
- [Portal data types](https://github.com/laylaaza/schoolportaal/blob/main/lib/models.ts): `lib/models.ts`

### Persistence and credentials

- [Data repository](https://github.com/laylaaza/schoolportaal/blob/main/lib/repository.ts): `lib/repository.ts`
- [MySQL database](https://github.com/laylaaza/schoolportaal/blob/main/lib/db.ts): `lib/db.ts`

### Other components

- **Portal user**

## Connections

- Portal user → Role redirect: opens portal (evidence: `app/page.tsx`)
- Role redirect → Session authorization: checks session (evidence: `app/page.tsx`)
- Role redirect → Login page: redirects unauthenticated (evidence: `app/page.tsx`)
- Portal user → Login page: submits credentials (evidence: `app/login/page.tsx`)
- Login page → Login and user forms: renders (evidence: `app/login/page.tsx`)
- Login and user forms → Server actions: submits login (evidence: `components/forms.tsx`)
- Server actions → Data repository: authenticates and mutates (evidence: `app/actions.ts`)
- Server actions → Password hashing: verifies passwords (evidence: `app/actions.ts`)
- Data repository → Password hashing: hashes new passwords (evidence: `lib/repository.ts`)
- Data repository → MySQL database: queries and writes (evidence: `lib/repository.ts`)
- Session authorization → Data repository: loads session user (evidence: `lib/auth.ts`)
- Student portal → Session authorization: requires student (evidence: `app/student/page.tsx`)
- Student portal → Data repository: loads own record (evidence: `app/student/page.tsx`)
- Student portal → Record views and access: renders student data (evidence: `app/student/page.tsx`)
- Teacher portal → Session authorization: requires teacher (evidence: `app/teacher/page.tsx`)
- Teacher portal → Student search form: renders search (evidence: `app/teacher/page.tsx`)
- Teacher portal → Record views and access: renders student table (evidence: `app/teacher/page.tsx`)
- Record views and access → Data repository: loads and searches records (evidence: `components/records.tsx`)
- Admin portal → Session authorization: requires administrator (evidence: `app/admin/page.tsx`)
- Admin portal → Record views and access: renders user records (evidence: `app/admin/page.tsx`)
- User administration → Record views and access: renders user management (evidence: `app/admin/users/page.tsx`)
- Add user page → Login and user forms: renders account form (evidence: `app/admin/users/new/page.tsx`)
- Login and user forms → Portal data types: uses role types (evidence: `components/forms.tsx`)
- Record views and access → Portal data types: uses student types (evidence: `components/records.tsx`)
- Role-aware shell → Data repository: loads student link data (evidence: `components/shell.tsx`)
- Server actions → Session authorization: checks admin access (evidence: `app/actions.ts`)
