MarinePrep CMS
The content console behind MarinePrep, rebuilt from Flutter desktop into Next.js.
- Role
- Full-Stack Engineer
- Platforms
- Web
- Year
- 2026
The tool MarinePrep's content runs through (curriculum, the question bank, mock tests, the roadmap's resource cards and counselling calls), originally a Flutter desktop app, rebuilt as a Next.js 16 console that shares its stack and design tokens with MarinePrep HQ.
Reads run in server components and writes in server actions, always as the signed-in admin, so the same Postgres row-level security that protects students' own data governs every edit here too. It had to keep writing exactly what the old Flutter admin and the student app already expected, down to a sort order the app hard-codes by subject, while the two consoles ran side by side during the changeover.
- is_admin()
- re-checked on every request, not just sign-in
- 5
- content areas: curriculum, questions, mocks, roadmap, counselling
- Next.js 16
- React 19
- Turbopack
- Supabase
- RLS
- Tailwind
How it was built.
Re-checking admin on every request, not trusting the session
- Problem
- Students and staff share one Supabase project with open signup. A session that was an admin's at sign-in could, in principle, be forged or reused; checking the role only once and caching it is the easy mistake that quietly widens the access window.
- Approach
- requireAdmin() asks the database (public.is_admin(), backed by an admin_users table) on every server component render and every server action, not once at login. The same table drives RLS, so the UI's notion of who is an admin and the database's are the same check.
- Trade-off
- There is no cached privilege to go stale or be replayed. The cost is a database round trip on every protected action, acceptable for an internal console where correctness matters more than shaving milliseconds.
Writing exactly what the old admin and the app already expected
- Problem
- Replacing a content tool while the app it feeds keeps running means the new tool cannot just model the domain cleanly. It has to reproduce undocumented behaviour the student app silently depends on, like a hard-coded subject order and dual plain-text/Quill-delta columns the mobile editor still reads.
- Approach
- A rules file (app-rules.ts) mirrors the Flutter app's own config file line for line (subject priority, which categories the mock-test generator is allowed to draw from, which fields cascade-delete and which don't), kept deliberately in step with the Dart source rather than re-derived from first principles.
- Trade-off
- The new console and the old Flutter admin could write to the same tables simultaneously during the changeover without corrupting what the student app displays. Keeping two files in step by hand is a real maintenance cost, paid until the old admin is fully retired.
