# Phase 0 — SRS Review, Validation and Planning Record

> **Phase 0 status: documentation complete, reviewed by the user, and updated with the user's decisions on X-16 and X-21.** Phase 1 has **not** started. No application code exists.
> **Baseline:** SRS v2.0 (`docs/SRS.md`), **approved by the user**, plus the Master Development Prompt. Both are binding. The precedence rule and every conflict are recorded in `docs/DECISIONS.md`.
> **Revision:** 4 (17 Nov 2026). The SRS Appendix A Member row is aligned with C-38. Revision 3: X-16 resolved (C-38) and X-21 deferred to Phase 9 by the user. Revision 2 completed the documentation set; revision 1 was the first planning response.

## 1. Documentation set (single source for each topic)

| File                                                                                   | Holds                                                                                                                                 | Does not duplicate                    |
| -------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------- |
| `docs/SRS.md`                                                                          | The approved requirements (Markdown copy of the .docx; only the status wording was updated)                                           | —                                     |
| `docs/DECISIONS.md`                                                                    | **The decision register:** confirmed (C), conflicts (X), delegated (D), pending external (P)                                          | Other docs refer to its IDs           |
| `docs/ARCHITECTURE.md`                                                                 | System design, folder structure, business-logic engines, jobs, frontend design system, navigation, localisation                       |                                       |
| `docs/DATABASE.md`                                                                     | Collections, fields, indexes, relationships, integrity rules, transactions, retention, deletion dependencies                          |                                       |
| `docs/API.md`                                                                          | Planned endpoints, methods, permissions, validation, responses, error codes                                                           | Permission keys come from SECURITY.md |
| `docs/SECURITY.md`                                                                     | Authentication, sessions, **permission matrix**, CSRF, validation, uploads, rate limits, audit, deletion safeguards, exports, secrets |                                       |
| `docs/TESTING.md`                                                                      | Strategy, tools, test tables, acceptance scenarios AC-01–AC-26                                                                        |                                       |
| `docs/SETUP.md`                                                                        | Prerequisites, environment variable names, planned commands                                                                           |                                       |
| `docs/DEPLOYMENT.md`                                                                   | Hosting architecture, environments, free-tier limits, release and rollback                                                            |                                       |
| `docs/BACKUP_RESTORE.md`                                                               | Backup schedule, retention, storage, encryption, operator restore runbook                                                             |                                       |
| `docs/PHASE0_REVIEW.md`                                                                | This review: corrections, consistency checklist, stack validation                                                                     |                                       |
| Root: `README.md`, `PROJECT_STATUS.md`, `HANDOVER.md`, `CHANGELOG.md`, `NEXT_STEPS.md` | Project status and handover                                                                                                           |                                       |

Every technical document carries a **PLANNED** banner, because nothing in it has been implemented.

---

## 2. Re-check of revision 1 — corrections made

Revision 1 was checked against the approved SRS and the Master Prompt. Each item below was wrong, risky or incomplete and has been corrected:

| #    | Revision 1 said                                                                                                                                               | Problem                                                                                   | Correction                                                                                                                                                                                                                                                                                    |
| ---- | ------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| R-01 | Asked the user to approve SRS v2.0 (Q1)                                                                                                                       | The SRS was already approved                                                              | Withdrawn. `docs/SRS.md` status wording updated (header, Document Control, Revision Summary, §20.2). No requirement text changed                                                                                                                                                              |
| R-02 | Default for Trainer archive/restore: "Trainer may archive; **only Admin restores**"                                                                           | This took away a Trainer permission that SRS §3.1 and §5.2 state explicitly               | Now follows SRS §3.1 and §5.2 (Trainer may archive and restore; archiving is blocked while a membership is active). The conflict with the Prompt and Appendix A was recorded as **X-16**. **The user confirmed it on 17 Nov 2026 (C-38).** In revision 4, SRS Appendix A was amended to match |
| R-03 | Default for payment status: "derived from verified totals only, plus a separate flag"                                                                         | This made the confirmed **Pending** status unreachable                                    | **D-32** keeps all four statuses: Paid, Partially Paid, Pending, Unpaid                                                                                                                                                                                                                       |
| R-04 | "Admin password reset by email" listed as a Phase 1 task without explaining why                                                                               | SRS §11.2 (email reset) and §11.1 (Trainer cannot change own password) needed reconciling | **X-19 / D-07**: email reset is for Admin accounts only. Trainers are reset by an Admin                                                                                                                                                                                                       |
| R-05 | Proposed asking about Admin management, login identity and other items as blockers                                                                            | The user had delegated these decisions                                                    | Decided and recorded: D-08, D-09, D-15, D-18, D-24 to D-29, D-38, D-42 and others                                                                                                                                                                                                             |
| R-06 | Did not mention that member deletion is effectively impossible as written                                                                                     | The SRS has no deletion path for workout notes, consent history or notification history   | Recorded as **X-21**. **The user has deferred it to the Phase 9 review.** No workaround will be implemented, and the no-cascade and retention rules stay in force                                                                                                                             |
| R-07 | Gallery and template removal safeguards were not specified                                                                                                    | SRS §12.1 says "**every** permanent deletion"                                             | **D-56** applies the full safeguards to every permanent deletion                                                                                                                                                                                                                              |
| R-08 | Expense access for Trainers not addressed                                                                                                                     | SRS §9.5 wording is ambiguous                                                             | **D-41**: Admin-only, matching the §3.1 matrix and Prompt §6. Marked as an interpretation                                                                                                                                                                                                     |
| R-09 | Some dashboard items were missing from the plan (Inactive Members, each Trainer's last login, recent payment corrections)                                     | Required by SRS §9.1                                                                      | Added to API.md §16 and the checklist below                                                                                                                                                                                                                                                   |
| R-10 | Some collections the design needs were not named (sessions, deletion audits, asset clean-up, backup runs, public trainers, site content, counters, job locks) | Needed to implement SRS rules                                                             | Added to DATABASE.md, each with a reason. Prompt §18 allows additional collections where genuinely necessary                                                                                                                                                                                  |
| R-11 | `.env.example` was listed among the files to create                                                                                                           | Phase 0 must not create application files                                                 | Not created. The environment variable _names_ are documented in SETUP.md §3. Phase 1 creates the example files                                                                                                                                                                                |
| R-12 | Retry wording said "15 min ×3"                                                                                                                                | It needed to be clear whether that means 3 retries or 3 attempts                          | D-47: initial attempt + 3 retries (4 attempts)                                                                                                                                                                                                                                                |

Items from revision 1 confirmed unchanged: the project understanding; the approved stack; the supporting library choices (with justification in ARCHITECTURE.md §2); phases 0–10; the main risks; the mobile-first strategy; the handover strategy.

---

## 3. Requirement consistency checklist

The columns show where each concern is documented. ✓ means documented consistently with the approved SRS and Prompt. "Lost?" checks that no confirmed decision was dropped or weakened.

| Area                                      | Source                         | Permissions                                            | Business rules                                             | Security                                       | Tests                                  | Lost? | Result                                                                                                                                    |
| ----------------------------------------- | ------------------------------ | ------------------------------------------------------ | ---------------------------------------------------------- | ---------------------------------------------- | -------------------------------------- | ----- | ----------------------------------------------------------------------------------------------------------------------------------------- |
| **Authentication & sessions**             | SRS §11.1–11.5; Prompt §17     | SECURITY §4.2 ✓                                        | SECURITY §2–3; D-01, D-06 to D-12 ✓                        | SECURITY §2, §3, §8 ✓                          | TESTING §5 ✓                           | No    | Consistent. Prompt differences X-01 to X-04 recorded                                                                                      |
| **Admin vs Trainer permissions**          | SRS §3.1; Prompt §6            | SECURITY §4.2, with a permission key for every route ✓ | —                                                          | Deny by default; 403 matrix test ✓             | TESTING §5 (matrix) ✓                  | No    | Consistent. X-16 resolved by the user (C-38)                                                                                              |
| **Inquiry → member conversion**           | SRS §4, §12.3; Prompt §7.7, §8 | `inquiries.manage` Admin only ✓                        | D-17 to D-19; DATABASE §2.14 ✓                             | Rate limit, no data leak ✓                     | AC-01 to AC-04 ✓                       | No    | Consistent                                                                                                                                |
| **Members, archive/restore**              | SRS §5; Prompt §9              | ✓                                                      | Archive is a separate state; restore reuses the ID; D-21 ✓ | —                                              | AC-05 to AC-07 ✓                       | No    | Consistent. Trainer archive and restore confirmed (C-38)                                                                                  |
| **Membership activation & renewal**       | SRS §6, §7.3; Prompt §10       | ✓ (custom price Admin only)                            | ARCHITECTURE §5.2; D-24 to D-30 ✓                          | Dates are computed on the server only ✓        | AC-09 to AC-12; TESTING §3.1 ✓         | No    | Consistent                                                                                                                                |
| **Payment summary + PaymentEntry ledger** | SRS §7.2; Prompt §11.3         | ✓                                                      | ARCHITECTURE §5.3; D-31 to D-34 ✓                          | Transactions + optimistic concurrency ✓        | AC-13 to AC-15; TESTING §3.2 ✓         | No    | Consistent. X-07 recorded                                                                                                                 |
| **Payment verification & receipts**       | SRS §7.1, §7.4; Prompt §11.7   | ✓ (both roles can share)                               | D-31, D-35 to D-37 ✓                                       | Immutable receipts; void and reissue ✓         | AC-13, AC-14; PDF checks ✓             | No    | Consistent. X-06 recorded                                                                                                                 |
| **Expenses & financial reports**          | SRS §9.4, §9.5; Prompt §15     | Admin only (D-41) ✓                                    | No net profit; Cash/Online filter; D-38, D-42 ✓            | Logged exports ✓                               | AC-21 ✓                                | No    | Consistent. D-41 is an interpretation                                                                                                     |
| **Exercises & workout notes**             | SRS §8; Prompt §12             | ✓ (author rule, Admin override)                        | Soft delete; D-39, D-40 ✓                                  | Ownership checked in the service ✓             | AC-16 ✓                                | No    | Consistent                                                                                                                                |
| **WhatsApp & consent**                    | SRS §10; Prompt §14            | Templates Admin only; send both; history own/all ✓     | ARCHITECTURE §5.5; D-45 to D-51 ✓                          | Guards at enqueue and dispatch; webhook HMAC ✓ | AC-17 to AC-20; TESTING §3.3 ✓         | No    | Consistent. X-05, X-09 recorded; P-06 pending                                                                                             |
| **Audit logs & login history**            | SRS §11.7; Prompt §17          | Admin only ✓                                           | 2-year TTL; D-62 ✓                                         | SECURITY §10 ✓                                 | TESTING §5 ✓                           | No    | Consistent                                                                                                                                |
| **Archive, restore & permanent deletion** | SRS §12; Prompt §9.4           | Admin only for deletion ✓                              | DATABASE §7; D-56 ✓                                        | SECURITY §11 ✓                                 | AC-23 ✓                                | No    | Consistent with the SRS as written. **X-21 deferred to the Phase 9 review**; member deletion stays dependency-blocked, with no workaround |
| **Data export**                           | SRS §9.4; Prompt §15           | Admin only ✓                                           | PDF only ✓                                                 | Password, logging, no-store ✓                  | AC-22 ✓                                | No    | Consistent. X-11 recorded                                                                                                                 |
| **Backup & recovery**                     | SRS §14.2, §19; Prompt §6, §23 | Status Admin only; restore by operator ✓               | BACKUP_RESTORE ✓                                           | Encryption; no HTTP restore ✓                  | AC-26 ✓                                | No    | Consistent. X-15 recorded; P-08 pending                                                                                                   |
| **English/Urdu localisation**             | SRS §1, §17; Prompt §16        | —                                                      | ARCHITECTURE §8.5; D-52 to D-55 ✓                          | —                                              | TESTING §5 ✓                           | No    | Consistent. P-10 pending                                                                                                                  |
| **Responsive mobile-first UI**            | SRS §13; Prompt §5             | —                                                      | ARCHITECTURE §8.3, §8.4 ✓                                  | —                                              | TESTING §1, §5 (6 widths × 2 themes) ✓ | No    | Consistent                                                                                                                                |
| Public website & content                  | SRS §4.1; Prompt §7            | Admin only ✓                                           | Plans from the database, not hard-coded ✓                  | Upload limits ✓                                | E2E ✓                                  | No    | Consistent                                                                                                                                |
| Dashboards                                | SRS §9.1 to 9.3; Prompt §13    | Trainer has no expiry widget ✓                         | D-38, D-44 ✓                                               | —                                              | AC-25 ✓                                | No    | Consistent                                                                                                                                |
| Trainer account lifecycle                 | SRS §11.6                      | ✓                                                      | D-09, D-13 ✓                                               | Immediate revocation ✓                         | AC-24 ✓                                | No    | Consistent                                                                                                                                |
| Deployment & environments                 | SRS §14, §19; Prompt §23       | —                                                      | DEPLOYMENT ✓                                               | HTTPS, secrets ✓                               | Smoke tests ✓                          | No    | Consistent. X-10; P-02 to P-05 pending                                                                                                    |

**Overall:** every major feature in the SRS and the Prompt is represented. Permissions, business rules, security controls and tests are documented. No confirmed decision has been dropped. X-16 has been **resolved** by the user (C-38). X-21 is **deferred** to the Phase 9 review and stays unresolved. The other X entries follow the Prompt's own precedence rule and are listed so that none is resolved silently.

---

## 4. Technology and architecture validation

### 4.1 Approved stack — practicality

| Component                | Verdict                                                                    | Notes / impact                                                                                                                                         |
| ------------------------ | -------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
| React + Vite, JavaScript | Practical                                                                  | No change                                                                                                                                              |
| Tailwind CSS             | Practical                                                                  | Design tokens as CSS variables keep the palette consistent in both themes                                                                              |
| React Router             | Practical                                                                  | Role guards for UI only; enforcement on the server                                                                                                     |
| Context API              | Practical at this scale                                                    | No extra state library                                                                                                                                 |
| React Hook Form + Zod    | Practical                                                                  | The same Zod ideas on server and client (separate files, no shared package needed)                                                                     |
| Node.js + Express        | Practical                                                                  | Current LTS                                                                                                                                            |
| MongoDB Atlas + Mongoose | Practical                                                                  | Transactions work on every Atlas tier (replica sets). **M0 has no cloud backups**, which is handled by D-61                                            |
| Vercel                   | Practical                                                                  | The `/api` rewrite solves the cross-site cookie problem (D-02). The Hobby plan is for non-commercial use, so check whether production needs Pro (P-12) |
| Render                   | Practical **only on a paid always-on instance** for staging and production | The free tier spins down after 15 minutes idle. The scheduler, retries and webhooks need the service to stay up (D-59, P-02)                           |
| Cloudinary               | Practical                                                                  | Server-signed uploads; the free tier is probably enough                                                                                                |
| Meta WhatsApp Cloud API  | Practical, but **depends on external approvals**                           | Business verification, sender number, template approval, per-message charges (P-06). The mock adapter is used until then                               |

**No change to the approved stack is proposed.**

### 4.2 Supporting libraries

All of them are mainstream and actively maintained, and each one serves a stated requirement (ARCHITECTURE.md §2). Deliberately **not** added: TypeScript, Redis or a queue service, a separate background-worker service, headless Chrome for PDFs, a payment gateway, a global data-cache library and a CSS component framework. Exact versions are checked at the start of Phase 1 (D-63).

### 4.3 External services and future configuration

See `docs/DECISIONS.md` section P (P-01 to P-12). In summary: GitHub, Render, Vercel, Atlas, Cloudinary, Meta WhatsApp, SMTP, backup storage, the domain, the Urdu reviewer, the gym content, and cost confirmation. **All of them are pending.** None of them blocks the start of Phase 1, except that an Atlas dev cluster (P-04) is needed for integration testing against Atlas. An in-memory replica set is used for automated tests.

---

## 5. Phases (unchanged)

0 Review (this) · 1 Foundation · 2 Public site & inquiries · 3 Members · 4 Memberships · 5 Payments & receipts · 6 Trainer experience · 7 WhatsApp · 8 Dashboards, reports & expenses · 9 Settings & operational security · 10 QA, deployment & handover. The scope of each phase is in SRS §20, and the Phase 1 task list is in `NEXT_STEPS.md`.

---

## 6. Items for the user

| Item                                                                                | Type                                                                                                 | Needed by             |
| ----------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | --------------------- |
| ~~X-16~~ Trainer restore permission                                                 | **Resolved**: Trainers can archive and restore (C-38)                                                | —                     |
| **X-21** How member permanent deletion should handle records that cannot be deleted | **Deferred**: formal decision and any SRS amendment reviewed before Phase 9. No workaround meanwhile | Before Phase 9        |
| **Phase 1 authorisation**                                                           | The user's explicit instruction                                                                      | Before any code       |
| **P-01** GitHub repository                                                          | External                                                                                             | Phase 1 (recommended) |
| **P-04** Atlas dev cluster                                                          | External                                                                                             | During Phase 1        |
| All other X, D and P entries                                                        | For information. Override any at any time                                                            | —                     |
