Context
I built the platform solo to replace the rigid off-the-shelf CRM the school was using. It runs the school's daily operations: enrollment, scheduling, attendance, billing, payroll and course delivery.
Architecture
A single Next.js App Router monorepo serves three surfaces behind one edge proxy with cross-subdomain SSO:
- Public site — the landing and lead intake, feeding applications straight into the CRM.
- CRM — role-based tools for admins and teachers: students, groups, attendance, balances and payroll.
- LMS — the student side: lessons, materials and embedded video with per-request access checks.
Inside the product
Screenshots from a local copy seeded with demo data — every name and number below is fictional. The interface is in Russian, the language the school works in.




Checking the money in production
A reader of my billing write-up asked whether the ledger invariants ever run outside the test suite. They didn't, so the same morning I ran them against production as read-only queries that return the rows breaking a rule.
- Every online payment reconciled with a credit on the student's balance.
- A few charges from before the cancel and delete paths learned to offset charges were flagged for correction.
- Reading the delete path to explain them turned up a live race. It read the lesson's ledger before its transaction started, so an attendance mark landing in that window could leave an orphaned charge. Deletion is now decided inside the transaction under a row lock, covered by a regression test, and was deployed the same day.
- The checks now run nightly and email a report every night, including clean ones, so a missing report means the check itself broke.
Engineering highlights
- Billing under concurrency. Production runs lesson billing in
SERIALIZABLEtransactions with row locks. Extracting the billing core showed that design aborting most concurrent writes, so the open-source version redesigns it aroundREAD COMMITTEDand an explicit, deadlock-free lock order. - Payment webhooks with a timing-safe secret check, IP allowlist, idempotency keys and server-side re-verification with the provider, so no payment is credited twice or without confirmation.
- Payroll engine with mid-cycle proration and idempotent lead-to-student conversion.
- Enumeration-safe login, Postgres-backed rate limiting, and access checks on presigned storage URLs.
- LLM features in production: a streaming AI tutor in the LMS and a report generator with prompt-injection sanitising, schema validation and hard timeouts.