Skip to main content

SKOLE-WRIT — Write To (Parent Requests) Module

Module ID: SKOLE-WRIT | Version: 1.0 | Status: Active
Products: Parent App (create/view/reply) · Teacher App (manage/reply) · Web App (manage)

1. Overview

FieldValue
Module NameWrite To (Requests & Tickets)
Module CodeWRIT
Business ValueStructured parent-to-school communication. Parents submit requests (leave applications, complaints, queries) and track their status. Teachers/staff respond in-thread. Replaces informal phone calls and notes.

Scope In

  • Parent: Create requests, view own requests by status, view thread with replies, reply to teacher response
  • Teacher: View all incoming requests, assign to staff member, change status, add reply, resolve
  • Request types: leave, complaint, general, query
  • File attachment support (URL-based)

Scope Out

  • Email/SMS notification on status change (planned)
  • Escalation workflow to principal

2. Requirements

Functional Requirements (FR)

What the module must DO — actions, behaviors, and outcomes.
  • SKOLE-WRIT-FR001: The module shall allow parents to create new requests with type (leave, complaint, general, query), subject, and message.
  • SKOLE-WRIT-FR002: The module shall enable parents to view their own requests and filter them by status.
  • SKOLE-WRIT-FR003: The module shall provide a threaded view for single requests, displaying all replies.
  • SKOLE-WRIT-FR004: The module shall allow both parents and staff to add replies to an existing request thread.
  • SKOLE-WRIT-FR005: The module shall enable teachers to view all incoming requests and assign them to specific staff members.
  • SKOLE-WRIT-FR006: The module shall allow staff to update request statuses: pending, in-progress, resolved, or rejected.
  • SKOLE-WRIT-FR007: The module shall capture resolution details (who resolved it, notes, and timestamp) when a request is marked as resolved.
  • SKOLE-WRIT-FR008: The module shall allow for soft-deletion of requests and replies.

Non-Functional Requirements (NFR)

How well the module must do it — performance, security, and reliability.
  • SKOLE-WRIT-NFR001: The module shall behave securely by ensuring parents can only view requests they created (scoped by JWT parent_id).
  • SKOLE-WRIT-NFR002: The module shall perform structured threading by strictly linking all replies to a parent write_to_id.
  • SKOLE-WRIT-NFR003: The module shall behave reliably by tracking the is_read status of replies to ensure users are aware of new communications.
  • SKOLE-WRIT-NFR004: The module shall perform secure data filtering by excluding all soft-deleted records from standard views.

Constraints

Rules and boundaries — tech choices and platform restrictions.
  • C001: We must implement soft-deletion because the platform’s audit policy prevents permanent removal of communication records.
  • C002: We must use the skole_id as the primary partition key for all request and reply lookups to maintain multi-tenancy.

3. Sub-modules / Backlog

IDSub-modulePriorityStatusEstimateLinked FR
SKOLE-WRIT-SM001Parent request creationP0Done2dFR001–FR002
SKOLE-WRIT-SM002Parent request list & detailP0Done2dFR003–FR005
SKOLE-WRIT-SM003Teacher/staff request managementP0Done3dFR006–FR009
SKOLE-WRIT-SM004Web admin request managementP1Done2dFR006–FR009
SKOLE-WRIT-SM005Unread badge on repliesP2Partial1dNF003

4. Logical Implementation

Request Status State Machine

[pending] ──assign──→ [in-progress]
[in-progress] ──resolve──→ [resolved]  (captures resolved_by, resolution_notes, resolved_at)
[in-progress] ──reject──→ [rejected]
[pending|in-progress] ──delete──→ [deleted] (deleted_status=1)

Parent Create Flow

POST /parent-app/write-to
  ├─ Input: { skole_id, parent_id, student_id, request_type, subject, message,
  │           request_date, leave_from_date?, leave_to_date?, attachment_url?, priority }
  └─ INSERT write_to → return created request

Parent View Thread Flow

GET /parent-app/write-to/:id
  ├─ Verify request belongs to this parent (parent_id = jwt.sub)
  ├─ Fetch write_to record
  ├─ Fetch write_to_replies WHERE write_to_id = :id ORDER BY created_at ASC
  └─ Return { request, replies[] }

Teacher Reply Flow

POST /teachers-app/write-to/:id/reply
  ├─ Input: { replied_by, replied_by_id, message, attachment_url? }
  └─ INSERT write_to_replies + optionally update write_to.status

5. UI Requirements

Parent App — Write To Screens

IDScreenRouteDescription
SKOLE-WRIT-UI001WriteToListScreen/writetoFilterable list of all parent requests with status badges
SKOLE-WRIT-UI002WriteToCreateScreen/writeto-createForm to create a new request
SKOLE-WRIT-UI003WriteToDetailScreen/writeto-detailThreaded conversation view for a single request
Components:
IDComponentProps
SKOLE-WRIT-UC001RequestCardrequest, onPress
SKOLE-WRIT-UC002StatusBadge`status: pendingin-progressresolvedrejected`
SKOLE-WRIT-UC003RequestTypeSelectortypes[], selected, onChange
SKOLE-WRIT-UC004DateRangePickerfromDate, toDate, onChange — for leave requests
SKOLE-WRIT-UC005ReplyBubblereply, isFromParent
SKOLE-WRIT-UC006ReplyInputonSubmit, loading
SKOLE-WRIT-UC007StatusFilterTabsstatuses[], active, onChange
UI States:
  • WriteToListScreen Loading: Skeleton cards
  • Empty list: “No requests found. Tap + to create one.”
  • WriteToDetailScreen Loading: Skeleton thread
  • Error: Toast with retry

Teacher App — Write To

IDScreenRouteDescription
SKOLE-WRIT-UI004WriteToManageScreen/writetoAll school requests with filter, assign, status change

Web App

IDScreenRouteDescription
SKOLE-WRIT-UI005Tickets Page/:skoleId/ticketsAdmin full view: all requests, status management, replies

6. Conditional Expressions

IDExpressionTriggerTrue ActionFalse Action
SKOLE-WRIT-CE001request.status === 'resolved'RequestCard renderGreen badge, lock reply inputNormal style
SKOLE-WRIT-CE002request.status === 'rejected'RequestCard renderRed badgeNormal style
SKOLE-WRIT-CE003request.request_type === 'leave'CreateScreen renderShow DateRangePickerHide date range fields
SKOLE-WRIT-CE004request.parent_id !== jwt.subGET /parent-app/write-to/:idReturn 403Return request + replies
SKOLE-WRIT-CE005reply.is_read === 0 && reply.replied_by !== 'parent'ReplyBubble renderShow unread dotNormal
SKOLE-WRIT-CE006request.deleted_status === 1DB queryExcludeInclude
SKOLE-WRIT-CE007request.priority === 'high'RequestCard renderRed priority iconNormal priority icon
SKOLE-WRIT-CE008request.resolved_at !== nullTimeline renderShow resolution timestampHide resolution section

7. Internal Module Connections

DirectionModuleData / EventCondition
WRIT → AUTHAuthJWT sub used as parent_id to scope requestsEvery parent request
WRIT → STUDStudentsstudent_id links request to a specific childEvery request
WRIT → STAFStaffassigned_to references a staff.idWhen request is assigned

8. External Connections

IDServicePurposeFailure Behavior
SKOLE-WRIT-EX001PostgreSQL (Prisma)Read/write write_to and write_to_replies500 error
SKOLE-WRIT-EX002Firebase FCMPush notification on new reply (planned)Silent fail

9. Database Tables

IDTableRole
SKOLE-WRIT-TB001write_toParent requests
SKOLE-WRIT-TB002write_to_repliesThreaded replies per request

write_to Key Columns

ColumnTypeNotes
idInt PK
skole_idVarChar(15)Tenant
parent_idIntFK → parent_details.id
student_idIntFK → students.id
request_typeVarChar(50)leave/complaint/general/query
subjectVarChar(255)Subject line
messageTextBody
leave_from_dateDate?Leave period start
leave_to_dateDate?Leave period end
statusVarChar(25)pending/in-progress/resolved/rejected
priorityVarChar(25)low/medium/high
assigned_toInt?FK → staff.id
resolved_byInt?FK → staff.id
resolution_notesText?Resolution message
resolved_atTimestamp?Resolution timestamp
deleted_statusInt0=active, 1=deleted

10. API Endpoints

IDMethodRouteAuthDescription
SKOLE-WRIT-EP001POST/parent-app/write-toJWT (parent)Create new request
SKOLE-WRIT-EP002GET/parent-app/write-toJWT (parent)List parent’s requests
SKOLE-WRIT-EP003GET/parent-app/write-to/:idJWT (parent)Get request + replies
SKOLE-WRIT-EP004POST/parent-app/write-to/:id/replyJWT (parent)Add reply to request
SKOLE-WRIT-EP005GET/teachers-app/write-toJWT (staff)View all school requests
SKOLE-WRIT-EP006GET/teachers-app/write-to/:idJWT (staff)Get request detail + replies
SKOLE-WRIT-EP007PUT/teachers-app/write-to/:idJWT (staff)Update status / assign
SKOLE-WRIT-EP008POST/teachers-app/write-to/:id/replyJWT (staff)Staff reply to request
SKOLE-WRIT-EP009GET/web-app/write-toJWT (user)Admin: all requests
SKOLE-WRIT-EP010PUT/web-app/write-to/:idJWT (user)Admin: update request
SKOLE-WRIT-EP011POST/web-app/write-to/:id/replyJWT (user)Admin: reply