Folder Structure

Code
src/
├── app/
│   ├── (site)/                 Public school website
│   ├── admin/(panel)/          Admin panel — ~100 screens
│   ├── parent/(app)/           Parent portal
│   ├── teacher/(app)/          Teacher portal
│   ├── student/(app)/          Student portal
│   ├── install/                First-run wizard
│   ├── docs/[version]/         These documents
│   └── api/
│       ├── v1/admin/*          Admin endpoints (excluded from the app docs)
│       ├── v1/parent/*         Parent app API
│       ├── v1/teacher/*        Teacher app API
│       ├── v1/student/*        Student app API
│       ├── docs/v1/            Scalar API reference (admin-gated)
│       └── openapi.json/       Generated spec
│
├── lib/
│   ├── db.ts                   The tagged-template SQL client
│   ├── public-id.ts            Opaque id allowlist + provisioning
│   ├── validation.ts           validateForm / hasErrors
│   ├── api-helpers.ts          ok / err / serverErr / pageParams
│   ├── payments.ts             Active payment connections
│   ├── r2.ts                   Storage client, provider-agnostic
│   ├── secrets.ts              Encrypt / decrypt stored credentials
│   └── school/                 ◀ the domain
│       ├── schema.ts           Years, terms, classes, sections, timetable, calendar
│       ├── people.ts           Students, guardians, staff + authz primitives
│       ├── attendance.ts       Registers, summaries
│       ├── fees.ts             Heads, structures, invoices, the payment ledger
│       ├── fee-payments.ts     Add-on driven online payment
│       ├── exams.ts            Exams, marks, grade scale, report cards
│       ├── homework.ts         Assignments and submissions
│       ├── communication.ts    Circulars, notifications, leave, threads
│       ├── admissions.ts       The pipeline and conversion
│       ├── feed.ts             The parent app's home feed
│       ├── library.ts          Catalogue and loans
│       ├── facilities.ts       Transport, hostel, inventory
│       ├── hr.ts               Qualifications, payroll, syllabus
│       ├── auth.ts             The three portal sessions
│       ├── parent-api.ts       parentContext, verification gate, paging
│       ├── teacher-api.ts      teacherContext, section assertion
│       ├── student-api.ts      studentContext
│       ├── types.ts            Structural unions + guards
│       ├── admin-crud.ts       Server-side CRUD factory
│       ├── admin-specs.ts      One spec per table
│       └── seed.ts             Essential seed data
│
├── components/
│   ├── admin/                  Btn, Card, PageHeader, DataTable, Modal, ImageUpload…
│   ├── form/                   Every input: fields, pickers, uploads
│   ├── ui/                     Modal, Toast, Skeleton, Avatar, motion
│   └── school/
│       ├── CrudPage.tsx        Spec-driven list + edit screen
│       ├── PortalShell.tsx     Parent/teacher/student chrome
│       └── PortalLogin.tsx     Shared portal sign-in
│
├── core/
│   ├── payments/               Driver contract, registry, built-in drivers
│   ├── channels/              Channel definitions
│   └── install/                Installer seam
│
├── product/
│   ├── admin-nav.ts            The sidebar
│   ├── admin-routes.ts         Route registry
│   ├── install.ts              What a fresh install provisions
│   ├── master/                 Lookup-list kinds and seeds
│   └── addons/                 Bundled channel add-ons (20 payment gateways…)
│
└── docs/
    ├── docsConfig.ts           This documentation's registry
    └── content/                These markdown files

scripts/
├── init-db.ts / init-core.ts   Schema provisioning
├── seed-master.ts              Lookup lists
├── seed-school-demo.ts         A demo school
├── seed-school-templates.ts    Message templates
└── gen-openapi.ts              Regenerates the API reference

Where to put a change

Change Goes in
A new table and its rules src/lib/school/<module>.ts
A CRUD API over a flat table A spec in admin-specs.ts + collectionHandlers
A new admin screen src/app/admin/(panel)/… with CrudPage
A screen with real interaction A bespoke page — a generic form cannot express a timetable grid
A new app endpoint src/app/api/v1/<portal>/…, then npm run gen:openapi
A reusable input src/components/form/ and its barrel
A payment gateway An add-on in src/product/addons/payments-* exporting a driver