forge
Explore
Log in

Don't you dare go Hollow

📝 rewrite role-scope-matrix in English with action scope table and guard patterns

Browse files at this commit

143c07a7ec475b01cb3f1a99eeff787093e748aeBurak BoduroğluParent: 340431f
  • docs
    • 📝 rewrite role-scope-matrix in English with action scope table and guard patterns
Show full message
docs: 📝 rewrite role-scope-matrix in English with action scope table and guard patterns
docs/role-scope-matrix.mdmodified+110 -120
@@ -1,126 +1,116 @@
1-# Rol Kapsamı Matrisi
1+# Role Scope Matrix
22
3-## Sayfa Bazında Erişim
3+## Page Access per Role
44
5-| Sayfa / Özellik | Öğrenci | Öğretmen | Müdür | Admin |
5+| Page / Feature | Student | Teacher | Manager | Admin |
66 |---|---|---|---|---|
7-| Ana sayfa `/` | ✅ | ✅ | ✅ | ✅ |
8-| Profil `/profile` | ✅ | ✅ | ✅ | ✅ |
9-| Rehber `/guide` | ✅ | ✅ | ✅ | ✅ |
10-| Notlar `/notes` | ✅ | ✅ | ✅ | ✅ |
11-| Dersler `/courses` | ✅ | ✅ | ✅ | ✅ |
12-| Ders detay `/courses/:id` | ✅ | ✅ | ✅ | ✅ |
13-| Sınavlar `/exams` | ✅ | ✅ | ✅ | ✅ |
14-| Sınav detay `/exams/:id` | ✅ | ✅ | ✅ | ✅ |
15-| Sınav salonu `/exam-room/:id` | ✅ | ❌ | ❌ | ❌ |
16-| Canlı monitör `/exams/:id/live` | ❌ | ✅ | ✅ | ✅ |
17-| Etkinlikler `/events` | ✅ | ✅ | ✅ | ✅ |
18-| Etkinlik detay `/events/:id` | ✅ | ✅ | ✅ | ✅ |
19-| **Karnem `/marks`** | ✅ | ❌ | ❌ | ❌ |
20-| **Yoklamam `/attendance`** | ✅ | ❌ | ❌ | ❌ |
21-| Öğrenci not sorgula `/management/student-marks` | ❌ | ✅ | ✅ | ✅ |
22-| Öğrenci yoklama sorgula `/management/student-attendance` | ❌ | ✅ | ✅ | ✅ |
23-| Mesai `/work` | ❌ | ✅ | ✅ | ✅ |
24-| Ayarlar `/management/settings` | ❌ | ❌ | ✅ | ✅ |
25-| Dönemler `/management/terms` | ❌ | ❌ | ✅ | ✅ |
26-| Kullanıcı yönetimi `/admin/users` | ❌ | ❌ | ❌ | ✅ |
27-
28-## Sidebar’da Ne Görsün?
29-
30-| Sidebar grubu / item | Öğrenci | Öğretmen | Müdür | Admin |
7+| Home `/` | ✅ | ✅ | ✅ | ✅ |
8+| Profile `/profile` | ✅ | ✅ | ✅ | ✅ |
9+| Guide `/guide` | ✅ | ✅ | ✅ | ✅ |
10+| Notes `/notes` | ✅ | ✅ | ✅ | ✅ |
11+| Courses `/courses` | ✅ | ✅ | ✅ | ✅ |
12+| Course detail `/courses/:id` | ✅ | ✅ | ✅ | ✅ |
13+| Exams `/exams` | ✅ | ✅ | ✅ | ✅ |
14+| Exam detail `/exams/:id` | ✅ | ✅ | ✅ | ✅ |
15+| Exam room `/exam-room/:id` | ✅ | ❌ | ❌ | ❌ |
16+| Live monitor `/exams/:id/live` | ❌ | ✅ | ✅ | ✅ |
17+| Events `/events` | ✅ | ✅ | ✅ | ✅ |
18+| Event detail `/events/:id` | ✅ | ✅ | ✅ | ✅ |
19+| **Report card `/marks`** | ✅ | ❌ | ❌ | ❌ |
20+| **My attendance `/attendance`** | ✅ | ❌ | ❌ | ❌ |
21+| Student marks lookup `/management/student-marks` | ❌ | ✅ | ✅ | ✅ |
22+| Student attendance lookup `/management/student-attendance` | ❌ | ✅ | ✅ | ✅ |
23+| Work log `/work` | ❌ | ✅ | ✅ | ✅ |
24+| Staff work log `/management/staff-work` | ❌ | ❌ | ✅ | ✅ |
25+| Settings `/management/settings` | ❌ | ❌ | ✅ | ✅ |
26+| Terms `/management/terms` | ❌ | ❌ | ✅ | ✅ |
27+| User management `/admin/users` | ❌ | ❌ | ❌ | ✅ |
28+
29+## Sidebar Visibility per Role
30+
31+| Sidebar group / item | Student | Teacher | Manager | Admin |
3132 |---|---|---|---|---|
32-| **classes** — Dersler / Sınavlar / Etkinlikler | ✅ | ✅ | ✅ | ✅ |
33-| **grades** — Karnem (`/marks`) | ✅ | ❌ | ❌ | ❌ |
34-| **grades** — Notlar | ✅ | ✅ | ✅ | ✅ |
35-| **students** — Yoklamam (`/attendance`) | ✅ | ❌ | ❌ | ❌ |
36-| **reports** — Öğrenci notları / yoklama / mesai | ❌ | ✅ | ✅ | ✅ |
37-| **settings** — Ayarlar / Dönemler | ❌ | ❌ | ✅ | ✅ |
38-| **admin** — Kullanıcılar | ❌ | ❌ | ❌ | ✅ |
39-
40-## Dashboard Portal Kartları
41-
42-| Kart | Öğrenci | Öğretmen | Müdür | Admin |
33+| **classes** — Courses / Exams / Events | ✅ | ✅ | ✅ | ✅ |
34+| **grades** — Report card (`/marks`) | ✅ | ❌ | ❌ | ❌ |
35+| **grades** — Notes | ✅ | ✅ | ✅ | ✅ |
36+| **students** — My attendance (`/attendance`) | ✅ | ❌ | ❌ | ❌ |
37+| **reports** — Student marks / attendance / work | ❌ | ✅ | ✅ | ✅ |
38+| **reports** — Staff work log | ❌ | ❌ | ✅ | ✅ |
39+| **settings** — Settings / Terms | ❌ | ❌ | ✅ | ✅ |
40+| **admin** — Users | ❌ | ❌ | ❌ | ✅ |
41+
42+## Dashboard Portal Cards per Role
43+
44+| Card | Student | Teacher | Manager | Admin |
4345 |---|---|---|---|---|
44-| Dersler | ✅ (kayıtlı) | ✅ | ✅ | ✅ |
45-| Sınavlar | ✅ (kayıtlı) | ✅ | ✅ | ✅ |
46-| Etkinlikler | ✅ | ✅ (teacher badge) | ✅ | ✅ |
47-| Karnem | ✅ | ❌ | ❌ | ❌ |
48-| Notlar | ✅ | ✅ | ✅ | ✅ |
49-| Öğrenci notları | ❌ | ✅ (teacher badge) | ✅ (teacher badge) | ✅ (teacher badge) |
50-| Öğrenci yoklaması | ❌ | ✅ (teacher badge) | ✅ (teacher badge) | ✅ (teacher badge) |
51-| Mesai | ❌ | ✅ (teacher badge) | ✅ (teacher badge) | ✅ (teacher badge) |
52-| Ayarlar | ❌ | ❌ | ✅ (manager badge) | ✅ (manager badge) |
53-| Dönemler | ❌ | ❌ | ✅ (manager badge) | ✅ (manager badge) |
54-| Kullanıcılar | ❌ | ❌ | ❌ | ✅ (admin badge) |
55-
56-## Tespit Edilen Hatalar
57-
58-| # | Hata | Dosya(lar) | Önem |
59-|---|---|---|---|
60-| 1 | `/marks` her role açık, RouteGuard yok, nav'da herkes görür | `marks-page.tsx`, `router.tsx`, `side-nav.tsx` | YÜKSEK |
61-| 2 | `/attendance` her role açık, RouteGuard yok, nav'da herkes görür | `attendance-page.tsx`, `router.tsx`, `side-nav.tsx` | YÜKSEK |
62-| 3 | `RouteGuard` student-only desteklemiyor (sadece `minRole` var) | `route-guard.tsx` | ORTA |
63-| 4 | `/work`, `/live`, `/settings`, `/terms` `beforeLoad` guard'ı yok (client-side RouteGuard var ama tutarsız) | `router.tsx` | DÜŞÜK |
64-| 5 | Sınav salonu butonu manager/admin'e görünüyor (tıklayınca hata) | `exam-detail-page.tsx` | DÜŞÜK |
65-
66-## Backend Notu
67-
68-Backend README Auth kolonunda:
69-- `GET /marks/me` = **student**
70-- `GET /attendance/me` = **student**
71-- `GET /marks/{user}` = **teacher**
72-- `GET /attendance/{user}` = **teacher**
73-
74-Ancak kodda `*/me` endpoint'leri `CurrentUser` (rol kontrolü yok) ile çalışıyor, `RequireTeacher`/`RequireStudent` değil. README'de `student` yazıp kodda herkese açık olması tutarsız. Bu endpoint'ler ya `RequireStudent` ile korunmalı ya da mevcut davranış (herkese açık) README'e yansıtılmalı.
75-
76----
77-
78-## Known Gaps (English — for backend team)
79-
80-### Contract Mismatches
81-
82-| # | Issue | BE field | FE field | Impact |
83-|---|-------|----------|----------|--------|
84-| 1 | Course term field name mismatch | `term` (string ID) | `term_id` (in FE type, write body is correct for POST/PATCH) | Term column and term filter on courses page almost always show "unassigned". The read response field is `term` but the FE type expects `term_id` |
85-
86-### Role Guard Gaps (FE)
87-
88-| # | Issue | Files | Priority |
89-|---|-------|-------|----------|
90-| 1 | `/marks` page has no student-only guard — any authenticated user can see it | `marks-page.tsx`, `router.tsx`, `side-nav.tsx` | HIGH |
91-| 2 | `/attendance` page has no student-only guard | `attendance-page.tsx`, `router.tsx`, `side-nav.tsx` | HIGH |
92-| 3 | `RouteGuard` only supports `minRole` (hierarchical: teacher→manager→admin); no `exactRole` or student-only mode exists | `route-guard.tsx` | MEDIUM |
93-| 4 | `/work`, `/live`, `/management/settings`, `/management/terms` have client-side `RouteGuard` but no router `beforeLoad` guard | `router.tsx` | LOW |
94-
95-### Missing BE → FE coverage
96-
97-| Endpoint | Purpose | Status |
46+| Courses | ✅ (enrolled count) | ✅ | ✅ | ✅ |
47+| Exams | ✅ (enrolled scope) | ✅ | ✅ | ✅ |
48+| Events | ✅ | ✅ (teacher badge) | ✅ | ✅ |
49+| Report card | ✅ | ❌ | ❌ | ❌ |
50+| Notes | ✅ | ✅ | ✅ | ✅ |
51+| Student marks | ❌ | ✅ (teacher badge) | ✅ (teacher badge) | ✅ (teacher badge) |
52+| Student attendance | ❌ | ✅ (teacher badge) | ✅ (teacher badge) | ✅ (teacher badge) |
53+| Work log | ❌ | ✅ (teacher badge) | ✅ (teacher badge) | ✅ (teacher badge) |
54+| Settings | ❌ | ❌ | ✅ (manager badge) | ✅ (manager badge) |
55+| Terms | ❌ | ❌ | ✅ (manager badge) | ✅ (manager badge) |
56+| Users | ❌ | ❌ | ❌ | ✅ (admin badge) |
57+
58+## Action Scope per Role
59+
60+| Action | Student | Teacher | Manager | Admin |
61+|---|---|---|---|---|
62+| Create / edit / delete own notes | ✅ | ✅ | ✅ | ✅ |
63+| Mark own attendance on events | ✅ | ✅ | ✅ | ✅ |
64+| Mark other users' event attendance | ❌ | ✅ | ✅ | ✅ |
65+| Create / edit / delete events | ❌ | ✅ (creator or manager+) | ✅ | ✅ |
66+| Enroll / unenroll students | ❌ | ✅ (course creator) | ✅ | ✅ |
67+| Edit / delete courses | ❌ | ✅ (course creator) | ✅ | ✅ |
68+| Create / edit / delete course sessions | ❌ | ✅ (course manager) | ✅ | ✅ |
69+| Take session roll call | ❌ | ✅ (session teacher or course manager) | ✅ | ✅ |
70+| Mark session teacher's own presence | ❌ | ❌ | ✅ | ✅ |
71+| Create exams | ❌ | ✅ (course manager) | ✅ | ✅ |
72+| Edit / delete exams | ❌ | ✅ (course manager) | ✅ | ✅ |
73+| Grade students | ❌ | ✅ (course manager) | ✅ | ✅ |
74+| Read exam results / statistics | ❌ | ✅ (course manager) | ✅ | ✅ |
75+| Read own exam result | ✅ | ❌ | ❌ | ❌ |
76+| Write exam questions | ❌ | ✅ (course manager) | ✅ | ✅ |
77+| Read answer sheets | ❌ | ✅ (course manager) | ✅ | ✅ |
78+| Watch live monitor | ❌ | ✅ (course manager) | ✅ | ✅ |
79+| Sit an exam (attempt) | ✅ | ❌ | ❌ | ❌ |
80+| Work check-in / check-out | ❌ | ✅ | ✅ | ✅ |
81+| Read / correct any user's work log | ❌ | ❌ | ✅ | ✅ |
82+| Read school settings & terms | ✅ | ✅ | ✅ | ✅ |
83+| Edit school settings & terms | ❌ | ❌ | ✅ | ✅ |
84+| Change user roles | ❌ | ❌ | ❌ | ✅ |
85+| Look up any user | ❌ | ✅ (search) | ✅ (search) | ✅ (full) |
86+
87+## Architectural Rules
88+
89+- **Hierarchical roles:** `student < teacher < manager < admin`. A higher role satisfies any lower requirement.
90+- **Course management rights:** course creator or `manager+`. Required for enrollment, session CRUD, exam CRUD, grading, roster read.
91+- **Ownership edits:** event/note edit/delete respects creator id. Manager+ overrides creator gate.
92+- **Student-only pages:** `/marks` (personal report card) and `/attendance` (personal attendance) are guarded by `RouteGuard exactRole="student"` and router `beforeLoad` redirect.
93+- **Management pages:** all `/management/*` routes require at least `teacher` (marks/attendance lookup) or `manager` (settings/terms/staff-work). Guarded by both `RouteGuard` and `beforeLoad`.
94+- **Data scope:** students see only enrolled/related data; teachers see managed course scope; manager+ sees all.
95+
96+## Guard Implementation
97+
98+| Guard mechanism | Where | Purpose |
9899 |---|---|---|
99-| `PATCH /sessions/{id}` | Edit a course session | No helper, no UI |
100-| `GET /work/{user}` | Read another user's work log (manager+) | No helper, no UI |
101-| `PATCH /work/entries/{id}` | Correct a closed work stint (manager+) | No helper, no UI |
102-| `DELETE /work/entries/{id}` | Delete a work entry (manager+) | No helper, no UI |
103-
104-### Incomplete Features
105-
106-| Feature | Detail |
107-|---|---|
108-| `allow_rejoin` | Type + request body exist; form always sends `true`; no UI toggle |
109-| Exam weight badge | BE `ExamResponse` has no weight field; weight is derived from kind + settings. Badge never shows |
110-| Exam room CTA | Visible to managers/admins on exam detail page; the room page itself blocks non-students |
111-
112-### Pagination Status
113-
114-- All list endpoints accept `?limit=&offset=` and return `{ items, total, limit, offset }`.
115-- Main FE lists (courses, exams, events, notes, terms, work log, admin users) send real server page params.
116-- Nested lists (sessions, enrollments, attendance, exam results/questions) unwrap full `.items` — acceptable for school-scale data.
117-- Reports (`/marks/*`, `/attendance/*`) are not paged — aggregate report shapes.
118-
119----
120-
121-## Kullanılan Kısaltmalar
122-
123-- ✅ = erişim var
124-- ❌ = erişim yok
125-- FE = frontend (düzeltme sadece ön yüzde)
126-- BE = backend (düzeltme sunucu tarafında)
100+| `RouteGuard` (client component) | Page component root | Blocks render; shows fallback |
101+| `RouteGuard exactRole` | `/marks`, `/attendance` | Student-only pages |
102+| `RouteGuard minRole` | Management pages | Teacher+ or manager+ |
103+| `beforeLoad` redirect (router) | Route definition | Redirects before page JS loads |
104+| `!isTeacherPlus()` | In-page logic | Exam room CTA, event self-mark |
105+| `canManage()` / `hasCourseManagementRights()` | Detail pages | Course action visibility |
106+| `canCreate` | List pages | Create button visibility |
107+| Nav `exactRole` | Sidebar items | Student-only nav links |
108+| Nav `minRole` | Sidebar items / groups | Teacher+, manager+, or admin only groups |
109+
110+## Legend
111+
112+- ✅ = access granted
113+- ❌ = access denied
114+- FE = frontend only change
115+- BE = backend change required
116+- (badge) = visual indicator showing minimum role requirement on dashboard cards