2026-09-14 23:01:15 +01:00
|
|
|
# SchoolCompare frontend and CMS
|
2026-02-02 20:34:35 +00:00
|
|
|
|
2026-09-14 23:01:15 +01:00
|
|
|
Next.js App Router with React, TypeScript, CSS Modules, Chart.js, Leaflet and
|
|
|
|
|
Payload CMS. It serves school search, comparisons, rankings, school/place detail
|
|
|
|
|
pages and editorial content across England.
|
2026-02-02 20:34:35 +00:00
|
|
|
|
2026-09-14 23:01:15 +01:00
|
|
|
Start with the [repository overview](../README.md),
|
|
|
|
|
[architecture](../docs/ARCHITECTURE.md) and [development checks](../docs/DEVELOPMENT.md).
|
2026-02-02 20:34:35 +00:00
|
|
|
|
2026-09-14 23:01:15 +01:00
|
|
|
## Source map
|
2026-02-02 20:34:35 +00:00
|
|
|
|
2026-09-14 23:01:15 +01:00
|
|
|
| Path | Purpose |
|
|
|
|
|
|---|---|
|
|
|
|
|
| `app/(frontend)/` | Public root layout, server pages and FastAPI proxy |
|
|
|
|
|
| `app/(payload)/` | Payload root layout, `/admin` and `/cms-api` |
|
|
|
|
|
| `app/robots.ts`, `app/opengraph-image.tsx`, root icons | Site-wide metadata endpoints |
|
|
|
|
|
| `components/` | Client views and reusable display components |
|
|
|
|
|
| `components/school/` | School detail sections |
|
|
|
|
|
| `lib/api.ts`, `lib/types.ts` | Fetch wrappers and manual school API types |
|
|
|
|
|
| `lib/schoolSections.ts`, `lib/compareLogic.ts` | Presentation decisions and data preparation |
|
|
|
|
|
| `context/`, `hooks/` | Comparison state, suggestion state and responsive behaviour |
|
|
|
|
|
| `collections/`, `blocks/`, `migrations/` | CMS schema and production migrations |
|
|
|
|
|
| `__tests__/` | Jest and React Testing Library tests |
|
2026-02-02 20:34:35 +00:00
|
|
|
|
2026-09-14 23:01:15 +01:00
|
|
|
Do not introduce a shared `app/layout.tsx`: public pages and Payload have separate
|
|
|
|
|
root layouts. Keep root metadata files outside the route groups.
|
2026-02-02 20:34:35 +00:00
|
|
|
|
2026-09-14 23:01:15 +01:00
|
|
|
## Data and state
|
2026-02-02 20:34:35 +00:00
|
|
|
|
2026-09-14 23:01:15 +01:00
|
|
|
Server pages fetch initial data directly from `FASTAPI_URL`. Browser fetches use
|
|
|
|
|
`/api` by default, forwarded by `app/(frontend)/api/[...path]/route.ts`.
|
|
|
|
|
`FASTAPI_URL` must include `/api`. See `.env.example` for CMS and API settings.
|
2026-02-02 20:34:35 +00:00
|
|
|
|
2026-09-14 23:01:15 +01:00
|
|
|
State uses React hooks/context, URL search parameters and localStorage for the
|
|
|
|
|
comparison basket. SWR is not installed. Maps use dynamic Leaflet wrappers.
|
|
|
|
|
Revalidation intervals are configured in fetch wrappers and pages; they vary by
|
|
|
|
|
resource. Backend reloads do not automatically invalidate every Next.js cache.
|
2026-02-02 20:34:35 +00:00
|
|
|
|
2026-09-14 23:01:15 +01:00
|
|
|
## Commands
|
2026-02-02 20:34:35 +00:00
|
|
|
|
2026-09-14 23:01:15 +01:00
|
|
|
```sh
|
|
|
|
|
npm ci
|
|
|
|
|
npm run typecheck
|
|
|
|
|
npm test -- --runInBand
|
2026-02-02 20:34:35 +00:00
|
|
|
npm run build
|
|
|
|
|
```
|
|
|
|
|
|
2026-09-14 23:01:15 +01:00
|
|
|
`test:watch` and `test:coverage` are also available. There is no `lint` script.
|
|
|
|
|
A running application needs the backend/data environment described in the
|
|
|
|
|
[development guide](../docs/DEVELOPMENT.md).
|
2026-02-02 20:34:35 +00:00
|
|
|
|
2026-09-14 23:01:15 +01:00
|
|
|
After CMS field or editor changes, run `npm run generate:importmap`. Keep
|
|
|
|
|
`payload-types.ts` generated from the CMS schema rather than editing it by hand.
|
|
|
|
|
The build must work without a database connection; avoid module-scope CMS queries
|
|
|
|
|
and DB-backed `generateStaticParams` functions.
|
2026-02-02 20:34:35 +00:00
|
|
|
|
2026-09-14 23:01:15 +01:00
|
|
|
See [publishing](docs/PUBLISHING.md) for CMS operations and
|
|
|
|
|
[deployment](../docs/DEPLOY.md) for staging and production promotion.
|