> ## Documentation Index
> Fetch the complete documentation index at: https://docs.criar.in/llms.txt
> Use this file to discover all available pages before exploring further.

# Staff Management Module

> SKOLE-STAF — Staff Management Module

# SKOLE-STAF — Staff Management Module

**Module ID:** `SKOLE-STAF` | **Version:** 1.0 | **Status:** Active\
**Products:** Web App (admin only)

***

## 1. Overview

| Field              | Value                                                                                                                                                                                 |
| ------------------ | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **Module Name**    | Staff Management                                                                                                                                                                      |
| **Module Code**    | STAF                                                                                                                                                                                  |
| **Business Value** | School admin manages teachers and support staff. Designations carry RBAC (role-based access control) JSON that determines what each staff role can see and do within the Teacher App. |

### Scope In

* Create, update staff records
* Assign designations with RBAC JSON permissions
* Manage staff addresses
* Track leave
* Assign students to staff members

### Scope Out

* Payroll
* Biometric integration

***

## 2. Requirements

### Functional Requirements (FR)

*What the module must DO — actions, behaviors, and outcomes.*

* **SKOLE-STAF-FR001:** The module shall allow admins to create staff records including name, designation, and contact details.
* **SKOLE-STAF-FR002:** The module shall enable admins to define designations and associate them with RBAC JSON configuration.
* **SKOLE-STAF-FR003:** The module shall allow admins to assign students to staff members for academic management.
* **SKOLE-STAF-FR004:** The module shall enable recording and management of staff leave requests.
* **SKOLE-STAF-FR005:** The module shall allow admins to toggle staff status between active and inactive.

### Non-Functional Requirements (NFR)

*How well the module must do it — performance, security, and reliability.*

* **SKOLE-STAF-NFR001:** The module shall behave as a security gate by using the RBAC JSON to control module-level access in the Teacher application.
* **SKOLE-STAF-NFR002:** The module shall perform multi-tenant isolation by scoping all staff records strictly to the `skole_id`.

### Constraints

*Rules and boundaries — tech choices and platform restrictions.*

* **C001:** We must use a JSON-based RBAC model for designations to allow for flexible permission changes without schema migrations.
* **C002:** We must separate staff personal data from their institutional roles to support designation history in the future.

***

## 3. Sub-modules / Backlog

| ID                 | Sub-module         | Priority | Status | Estimate | Linked FR    |
| ------------------ | ------------------ | -------- | ------ | -------- | ------------ |
| `SKOLE-STAF-SM001` | Staff CRUD         | P0       | Done   | 3d       | FR001, FR006 |
| `SKOLE-STAF-SM002` | Designation & RBAC | P0       | Done   | 2d       | FR002        |
| `SKOLE-STAF-SM003` | Student assignment | P1       | Done   | 1d       | FR003        |
| `SKOLE-STAF-SM004` | Leave tracking     | P1       | Done   | 1d       | FR004        |
| `SKOLE-STAF-SM005` | Address management | P2       | Done   | 0.5d     | FR005        |

***

## 4. Logical Implementation

### RBAC JSON Example (`staff_designation.rbac`)

```json theme={null}
{
  "attendance": { "view": true, "mark": true },
  "diary": { "view": true, "create": true, "edit": false },
  "write_to": { "view": true, "reply": true },
  "noticeboard": { "view": true, "create": false }
}
```

This JSON is read by the Teacher App on login and gates which tabs/features are visible.

***

## 5. UI Requirements

### Web App

| ID                 | Screen            | Route                          | Description                                            |
| ------------------ | ----------------- | ------------------------------ | ------------------------------------------------------ |
| `SKOLE-STAF-UI001` | Staff Page        | `/:skoleId/staff`              | Table of all staff with create/edit/deactivate         |
| `SKOLE-STAF-UI002` | Staff Detail      | `/:skoleId/staff/:id`          | Profile with address, leave records, assigned students |
| `SKOLE-STAF-UI003` | Designations Page | `/:skoleId/staff/designations` | RBAC designation management                            |

**Components:**

| ID                 | Component           | Props                               |
| ------------------ | ------------------- | ----------------------------------- |
| `SKOLE-STAF-UC001` | `StaffCard`         | `staff`, `onEdit`, `onToggleStatus` |
| `SKOLE-STAF-UC002` | `RBACEditor`        | `rbac`, `onChange`                  |
| `SKOLE-STAF-UC003` | `LeaveForm`         | `staffId`, `onSubmit`               |
| `SKOLE-STAF-UC004` | `StudentAssignment` | `staffId`, `students[]`, `onAssign` |

***

## 6. Conditional Expressions

| ID                 | Expression                          | Trigger              | True Action             | False Action           |
| ------------------ | ----------------------------------- | -------------------- | ----------------------- | ---------------------- |
| `SKOLE-STAF-CE001` | `staff.status === 0`                | Staff list render    | Show "Inactive" badge   | Show "Active" badge    |
| `SKOLE-STAF-CE002` | `rbac.attendance.mark === true`     | Teacher app login    | Show attendance mark UI | Hide mark controls     |
| `SKOLE-STAF-CE003` | `rbac.diary.create === true`        | Teacher diary screen | Show create button      | Read-only              |
| `SKOLE-STAF-CE004` | `leave.leave_status === 'approved'` | Leave list render    | Green badge             | Pending/rejected badge |

***

## 7. Database Tables

| ID                 | Table               | Role                         |
| ------------------ | ------------------- | ---------------------------- |
| `SKOLE-STAF-TB001` | `staff`             | Core staff record            |
| `SKOLE-STAF-TB002` | `staff_designation` | Role definitions + RBAC JSON |
| `SKOLE-STAF-TB003` | `staff_address`     | Staff home/work addresses    |
| `SKOLE-STAF-TB004` | `staff_leave`       | Leave request records        |
| `SKOLE-STAF-TB005` | `staff_student`     | Staff-to-student assignments |

***

## 8. API Endpoints

| ID                 | Method | Route                                | Auth       | Description              |
| ------------------ | ------ | ------------------------------------ | ---------- | ------------------------ |
| `SKOLE-STAF-EP001` | GET    | `/web-app/staff`                     | JWT (user) | List all staff           |
| `SKOLE-STAF-EP002` | POST   | `/web-app/staff`                     | JWT (user) | Create staff             |
| `SKOLE-STAF-EP003` | PUT    | `/web-app/staff/:id`                 | JWT (user) | Update staff             |
| `SKOLE-STAF-EP004` | GET    | `/web-app/staff/designations`        | JWT (user) | List designations        |
| `SKOLE-STAF-EP005` | POST   | `/web-app/staff/designations`        | JWT (user) | Create designation       |
| `SKOLE-STAF-EP006` | PUT    | `/web-app/staff/designations/:id`    | JWT (user) | Update designation RBAC  |
| `SKOLE-STAF-EP007` | POST   | `/web-app/staff/:id/assign-students` | JWT (user) | Assign students to staff |
| `SKOLE-STAF-EP008` | GET    | `/web-app/staff/:id/leave`           | JWT (user) | View staff leave         |
| `SKOLE-STAF-EP009` | POST   | `/web-app/staff/:id/leave`           | JWT (user) | Create leave record      |
