# Project Final Audit Report

**Project:** Ananya International School website and CMS
**Audit date:** 2026-11-26
**Branch:** `audit/final-review` (baseline commit `78ad116` on `main`)

## 1. Architecture and technologies

| Layer | Technology |
|---|---|
| Backend | Laravel 12.74 on PHP 8.2.12 |
| Database | MySQL / MariaDB 10.4 (local XAMPP); SQLite in memory for tests |
| Views | Blade components, one template per Figma section |
| CSS | Tailwind CSS 4 via Vite 7, design tokens from Figma |
| JavaScript | Vanilla ES modules; Swiper 14 for sliders (loaded only where needed) |
| Fonts | General Sans and Boska (Fontshare), Outfit and Inter (Fontsource), all self-hosted |
| Queue / mail | Database queue; Laravel Mail (log locally, SMTP in production) |
| Tests | PHPUnit 11 (Laravel), Playwright 1.64 (Chromium, Firefox, WebKit), axe-core 4.14 |

Structure: fixed CMS section types in `app/Sections`, services in `app/Services`, thin controllers in `app/Http/Controllers/{Site,Admin}`. Details are in `docs/ARCHITECTURE.md`.

## 2. Modules inspected
- **Public pages:** Home, About Us, History & Journey, Campuses, Contact Us; sitemap.xml, robots.txt, error pages.
- **Enquiry forms:** Home and Contact variants, spam protection, queued emails.
- **CMS:** login, logout, password reset, idle timeout, dashboard, pages, sections (draft, preview, publish, discard, hide, reorder), media library and picker, enquiries (filters, status, notes, follow-up, archive, delete, CSV), settings, users, activity log, profile.
- **Database:** 7 application tables and the Laravel default tables; migrations, models, relationships, indexes.
- **Security:** authentication, authorization, input and output handling, uploads, headers, secrets, dependencies.
- **Frontend quality:** responsive layout, cross-browser behaviour, accessibility, performance.

Out of scope by agreement: new pages, public API, registration, 2FA, scheduled publishing, menu management, rich text editor.

## 3. Issues identified in this audit

| # | Area | Issue | Severity |
|---|---|---|---|
| 1 | Git | No commit existed; all 315 files were untracked | High (no rollback point) |
| 2 | Accessibility | History timeline used `<ol>/<li>` with `role="group"` on items (invalid list) | Medium |
| 3 | Accessibility | Admin dashboard stat tiles put `<dt>/<dd>` inside links (invalid `<dl>`) | Low |
| 4 | Accessibility | Pagination used `aria-label` on a plain `<span>` (prohibited ARIA) | Low |
| 5 | Mobile UI | Contact map card covered almost the whole map on phones, hiding the campus pin label | Medium |
| 6 | Security | No Content-Security-Policy header | Medium |
| 7 | Data retention | `CMS_ENQUIRY_RETENTION_DAYS` was configured but never used | Low |
| 8 | Code | Unused default Laravel `welcome.blade.php` | Low |
| 9 | Accessibility | Figma colours fail WCAG AA contrast: orange labels `#F58220` on white (2.59:1) and grey step text `rgba(0,0,0,.5)` on `#F4F4F4` (3.9:1) | Medium (design decision) |

## 4. Issues fixed

| # | Fix | Files |
|---|---|---|
| 1 | Baseline commit on `main`; audit work done on branch `audit/final-review` | git |
| 2 | Timeline slides are now `<div>` elements (Swiper slides with `role="group"`) | `resources/views/sections/history/timeline.blade.php` |
| 3 | Stat tiles are a `<ul>` of links | `resources/views/admin/dashboard.blade.php` |
| 4 | Pagination labels moved to screen-reader text | `resources/views/vendor/pagination/tailwind.blade.php` |
| 5 | On phones the card sits below the map; on tablet and desktop it overlays the map as in Figma | `resources/views/sections/contact/maps.blade.php` |
| 6 | Nonce-based CSP added (scripts from this site only, frames from YouTube/Vimeo only, no `eval`, `object-src none`). It supports the Vite dev server and is skipped on the debug error page. It can be switched off with `CMS_CSP_ENABLED` | `app/Http/Middleware/SecurityHeaders.php`, `resources/views/layouts/site.blade.php`, `config/cms.php` |
| 7 | New `php artisan enquiries:prune [--days] [--dry-run]` deletes only archived enquiries older than the retention period (minimum 30 days) and logs the action | `app/Console/Commands/PruneArchivedEnquiries.php` |
| 8 | Removed after confirming it had no references | `resources/views/welcome.blade.php` |
| 9 | **Not changed.** Your rule is to keep the approved Figma colours. Left for your decision (see section 15) | none |

New tests: `tests/Feature/PerformanceTest.php`, `tests/Feature/SecurityHeadersAndRetentionTest.php`, `tests/e2e/audit.mjs`, `tests/e2e/admin-flows.mjs`. The browser scripts now accept `ENGINE=chromium|firefox|webkit`.

## 5. Features tested (all run during this audit)
- All 5 public pages, sitemap, robots, 404 page: HTTP 200 (404 for the missing page).
- Contact form: empty submit blocked in the browser; valid submit saved and success shown (Chromium, Firefox, WebKit).
- Queued notification job: both emails generated, sent flags stored, and jobs for deleted enquiries skipped without failure.
- Home tabs, mobile menu (including Escape), hero slider, history timeline arrows, YouTube walkthrough dialog under CSP.
- CMS: login, dashboard, section editor, media picker list and upload and select, draft save, repeater add row, enquiry list and status update, settings save, users list, activity log, media alt text and delete, mobile sidebar, logout, and admin blocked after logout.
- Permissions, validation, XSS, IDOR, uploads and throttling through PHPUnit (see section 14).

## 6. Frontend status
**Working.** The 5 pages match the Figma desktop frames. There is no horizontal overflow from 1920 to 360 px, and no console errors in Chromium, Firefox or WebKit. There are no broken links or images, and no images without `alt`. Every page has one `h1` and no skipped heading levels. Buttons without a link are hidden instead of being dead.

## 7. Backend status
**Working.** Routes, controllers, services, Form Requests and policies/gates were all exercised by tests. The Laravel log shows no new errors. The only errors in it are from early development, before the admin controllers existed. `php artisan optimize` (config, route, view and event cache) runs cleanly.

## 8. Admin panel status
**Working.** All modules were tested in the browser and with PHPUnit. All 13 admin screens pass axe WCAG 2.1 A/AA with 0 violations. Dashboard numbers come from real database queries.

## 9. Database status
**Consistent.** 7 application tables with foreign keys (cascade or null-on-delete set on purpose), unique keys (`users.email`, `pages.key`, `pages.slug`, `settings.key`, `page_sections(page_id,type)`) and indexes on the filter and sort columns. No destructive command was run. Local data: 5 pages, 24 sections, 46 media files, 16 settings, 1 user (`admin@ananaygroup.com`), 0 enquiries. Test records were removed after the browser tests.

## 10. API status
There is no public API, by design. The only JSON endpoints are inside the CMS (`/admin/media/picker`, `/admin/media` upload). Both need a login and are tested.

## 11. Security audit status
- In place and tested: CSRF, login throttling, password policy, session regeneration, idle timeout, deactivated-user sign-out, single-use reset tokens, role gates on every admin route, scoped bindings, schema-based sanitising, escaped output, link allowlist, upload re-encoding, CSV formula escaping, markdown escaping in email, honeypot, timing and rate limits, security headers, **CSP (new)**.
- `composer audit`: 0 advisories. `npm audit`: 0 vulnerabilities.
- Tracked files were scanned for secrets: none found. `.env` and `.mcp.json` are git-ignored.
- Details: `docs/SECURITY.md`.

## 12. Performance status
- Public pages run **6 or fewer database queries each** (enforced by `PerformanceTest`).
- Local Chromium LCP is 1.07 to 1.36 s, CLS is 0.035 or lower, with 15 to 24 requests per page.
- Images are WebP with 600 and 1200 px variants, `srcset`, explicit dimensions and lazy loading. The slider JS (29 KB gzip) loads only on pages with sliders. CSS is 17 KB gzip.
- Production numbers must be measured on the real hosting.

## 13. Responsive testing status
- Chromium: 1920, 1440, 1366, 1024, 768, 430, 390 and 360 px for all pages.
- WebKit: 390 and 1366 px for all pages.
- Firefox: 1366 px.
- No overflow anywhere. One mobile layout issue (the map card) was fixed.

## 14. Build and test results

| Command | Result |
|---|---|
| `php artisan test` | **87 passed, 369 assertions** |
| `vendor/bin/pint` | passed |
| `npm run build` | built with no errors |
| `php artisan optimize` | no errors |
| `node tests/e2e/audit.mjs` (Chromium, Firefox, WebKit) | 0 console errors, 0 broken links, 0 broken images |
| `smoke.mjs` | 14/14 in Chromium, Firefox and WebKit |
| `admin-flows.mjs` | 11/11 in Chromium |
| axe on admin (13 screens) | 0 violations |
| axe on public pages | only the Figma colour-contrast item |
| `composer audit` / `npm audit` | 0 / 0 |

## 15. Remaining issues

| Item | Why it is open | What is needed |
|---|---|---|
| Colour contrast of Figma orange labels and grey step text (WCAG AA) | Changing approved colours needs your permission | Approve one option: (a) keep as designed; (b) darker orange only for the small label text, for example `#AD580D` (5.0:1 on white, 4.6:1 on the `#F4F4F4` panel), with the large headings unchanged; the grey step text would also change from 50% to about 65% black; (c) the designer updates Figma |
| Real email delivery | no SMTP credentials | SMTP host, port, username, password, encryption and from-address, set in `.env` |
| Content to confirm | placeholder copy was replaced on 2026-11-26; some facts need the school | listed in `docs/IMPLEMENTATION_STATUS.md` ("Content to confirm"): timeline 2024/2025, stats, CBSE number, contact details, two photos from other schools, links, video |
| Real devices and screen reader | needs a person and devices | test on an iPhone, an Android phone and NVDA/VoiceOver |
| Lighthouse on production | needs hosting | run after deployment |
| `PROJECT_REQUIREMENTS.md` is not in the repository | the file was only shared in chat | add it to the project root |

## 16. Deployment readiness
**Ready for staging, after the credentials below are in place.** Code, tests, build and the deployment guide (`docs/DEPLOYMENT.md`) are complete. Production launch also depends on the content and SMTP items in section 15.

## 17. Manual configuration and credentials still required
1. **Hosting:** server with PHP 8.2+, the GD extension with WebP support, and MySQL 8 or MariaDB 10.4+.
2. **`.env` on the server:** `APP_ENV=production`, `APP_DEBUG=false`, `APP_URL`, new `APP_KEY`, database name, user and password, `SESSION_SECURE_COOKIE=true`.
3. **SMTP:** `MAIL_MAILER=smtp`, `MAIL_HOST`, `MAIL_PORT`, `MAIL_USERNAME`, `MAIL_PASSWORD`, `MAIL_SCHEME`, `MAIL_FROM_ADDRESS`.
4. **Queue worker or cron** for enquiry emails (see `docs/DEPLOYMENT.md`).
5. **CMS Settings:** enquiry notification email, social links, Privacy Policy and Terms links, campus website links, walkthrough video.
6. **Security actions by the owner:**
   - Revoke the Figma API token that was shared in chat.
   - Change the password of `admin@ananaygroup.com` after the first login (it was shown in chat).
