What the app calls at each screen, what it sends, and what it gets back. Pick a step to see a real request and response, captured from the API for a grade-5 test student, plus the fields the screen should read.
The app only ever talks to the Study Plan API. The API looks the student up on ClassQuiz (token stays on the server) and keeps saved plans in its own database.
sequenceDiagram
autonumber
participant U as Unity app
participant A as Study Plan API
participant C as ClassQuiz
participant D as Database
U->>A: GET /students/{id}/setup
A->>C: student profile (cached 10 min)
A->>D: latest saved plan
A-->>U: grade, subjects, periods, plans, latest plan
loop every change of marks / priority / period / plan
U->>A: POST /simulate (+ POST /recommend)
A-->>U: predicted marks, week cards, suggested week
end
Note over U: Student drags cards on the week (no call)
opt Suggest pressed with cards already placed
U->>A: POST /week/suggest
A-->>U: the week completed around the student's cards
end
U->>A: POST /week/confirm (marks, period, plan, week)
A->>D: save plan + time split + week
A-->>U: saved plan (id, week)
opt Edit plan
U->>A: PUT /week/edit
A->>D: replace the week only
end
U->>A: GET /missions
A->>D: latest plan + week
A-->>U: one daily mission per slot + weekly missions
day_index 0–6). Show them right to left.week.rest_days rest days. A rest day holds no cards.week.max_cards_per_day). A study day may stay empty (a free day) once every card is placed.cards[] is placed once (count of each subject), at most once per day.minutes from cards[]."اقترح علي" never fails because of the board.
recommended is a whole new week, with started_week_replaced: true.invalid_week.User-facing texts come ready in Arabic. Show them as they are; don't rebuild them from numbers.
name, label, description of plans and periodsname_ar of subjects and daysminutes_label, total_label, rest_label in the weekdescription and completed_paragraph| Call | Use it for |
|---|---|
| GET /students/{id}/plans?limit=20&offset=0 | The student's plan history, newest first (items[]). |
| GET /students/{id}/plans/latest | The current plan. 404 not_found if none. |
| GET /students/{id}/plans/{saved_plan_id} | One saved plan. |
| DELETE /students/{id}/plans/{saved_plan_id} | Delete one saved plan → 204. |
| POST /simulate · /recommend · /week/suggest | Same as the student versions, with "grade" in the body. For tests and "what if" screens. |
| GET /config | All reference data (grades, subjects, periods, plans, thresholds). |
| GET /health | Is the API up; database and ClassQuiz status. |
Every error has the same shape. Show message to developers only; use code in the app.
| code | HTTP | When |
|---|---|---|
| invalid_student_id | 422 | student_id is not a number. |
| student_not_found | 404 | ClassQuiz doesn't know this student. |
| unsupported_level | 422 | The student isn't in primary grades 1–6. |
| invalid_subjects | 422 | Missing, duplicate, unknown or not-taught subject. Send exactly the subjects from setup. |
| invalid_months | 422 | months is not 1, 3, 6 or 9. |
| unknown_plan · invalid_plan | 422 | Bad plan_id, or a custom plan without valid days and hours. |
| invalid_week | 422 | Confirm / edit: not every card and rest day placed once, or no week sent. |
| not_found | 404 | No such saved plan for this student. |
| classquiz_unavailable | 502 | ClassQuiz unreachable. Retry later. |
| database_unavailable · database_error | 503 | Saving or loading failed. Simulate still works. |