Case study

Aflon SMS
Full Stack Engineering
Aflon SMS is a multi-tenant school management SaaS for admissions, results, and fees. I extended the open-source GegoK12 Laravel app with database-per-school isolation using stancl/tenancy and MySQL, adding 48 models, 117 service classes, 333 routes, 5 payment gateways, and about 1,000 automated tests, with Vue and Livewire for the interface.
How it’s built
Aflon SMS · Multi-tenant school management SaaS built on GegoK12 with database-per-school isolation
Aflon SMS is a school management platform that schools, teachers, parents and bursars use for admissions, results and fees. I extended the open-source GegoK12 Laravel app into a multi-tenant SaaS where each school domain resolves to its own MySQL database. On top of upstream I added 48 models, 41 migrations, 117 service classes, 5 payment gateways and about 1,000 automated tests.
- new Eloquent models
- 48
- new migrations (141 tenant + 8 central now)
- 41
- service classes added under app/Services
- 117
- route definitions added
- 333
- test methods added (1,031 now vs 31 upstream, in 127 test files vs 4)
- 1,000
- payment gateway adapters
- 5
Technology and what it does here
- Laravel 12 / PHP 8.4
- Application framework for all tenant and central admin workflows
- stancl/tenancy 3
- Database, cache, filesystem and queue bootstrappers that isolate each school
- MySQL
- One central registry database plus one aflon_tenant_* database per school
- Vue 3
- Upstream SPA components; 43 .vue files modified, none added
- Blade
- 168 new server-rendered views for results hub, invoices, central admin
- Livewire 3
- Interactive admin components (inherited stack, kept in composer.json)
- laravel-dompdf
- A5 fee receipt PDFs and branded report cards
- maatwebsite/excel
- Spreadsheet import and export of school records
- Paystack, Flutterwave, Monnify, FCMB
- Per-tenant payment gateways behind one PaymentGatewayInterface with webhook verification
- NVIDIA NIM (Llama 3.2)
- LLM behind the AI copilot with tool registry and guided page tours
- PHPUnit
- Feature, unit and tenancy isolation suites including separate phpunit.tenancy.xml
- Docker / Nginx / GitHub Actions
- Dockerfile, nginx.conf, systemd units, ci.yml and a scheduled tenancy isolation workflow
Implementation details
- TenantProvisioner creates a school database, runs tenant migrations, seeds academic structure and the first admin inside tenant->run().
- Result approval moves term results through draft, submitted, approved and published, with each transition logged to result_status_events.
- Payment reversal runs in a DB transaction, can re-record a corrected amount or carry credit to another invoice, and InvoiceRevisionService snapshots and fingerprints invoice lines so the original receipt survives.
- Legacy import reads SQL dumps or flat files, scores candidate tables per entity, prunes implausible rows and flags natural-key collisions before committing.
- Custom domains are verified by DNS probe and routed by middleware, with session cookies scoped per host.
System architecture
A central tenant registry resolves each incoming request to a school. School workflows run against that school’s database and payment configuration.
Project screenshots
Open full-size screenshot in a new tab
Open full-size screenshot in a new tab
Open full-size screenshot in a new tab
Open full-size screenshot in a new tabResults and testing
Two schools with overlapping IDs
The tenancy tests create two school databases and exercise the same local school ID in each. That makes the database connection boundary observable in a regression test.
A correction with a paper trail
The invoice correction suite includes 14 scenarios. It covers reversed receipts, replacement payments, revision restore, fee totals, and attempts to modify another school’s records.
Synthetic migration fixtures
The import tests model old schemas with linked students, assessments, and invoices. A local run passed 21 tests for SQL parsing, schema discovery, and relationship mapping with synthetic fixtures.
Tenancy and Migration
The platform needed to onboard schools with existing records and familiar workflows. That meant drawing a new data boundary around each school while keeping the inherited application compatible.
Separate school data while reusing the application
I worked on the database-per-school design, tenant administration, branding, and custom domain routing. I kept the existing school identifier local to each database so inherited queries could continue to work inside the tenant context.
Make a legacy import reviewable
I built import support for CSV, Excel, and SQL dumps, with a preview that orders dependent records. I added logic to resolve legacy relationships and keep historical marks attached to their academic sessions.
Adapt the academic workflow
I added Nigerian secondary-school defaults, configurable grading, and a submit, approve, and publish workflow for results. I added tests for midterm results and for calculating grades within the correct academic session.
Billing and Delivery
A school needed to choose its own payment provider. The finance team also needed a way to correct a recorded payment without losing the receipt or obscuring why the balance changed.
Select a payment provider per school
I added a gateway registry, tenant-specific activation and credentials, and an FCMB integration backed by SeerBit. This let checkout and verification resolve the school’s configured gateway through the same interface.
Keep corrections auditable
I built an invoice history and payment reversal workflow. A correction preserves the original receipt and records who reversed the payment, when, and why. The service can link a replacement and recalculate the balance and instalments in the same transaction.
Test boundaries and support releases
I added two-school MySQL tests for tenant isolation, plus feature tests for invoice revisions, reversed receipts, and restricted access. I also worked on deployment tooling that checks central and tenant migrations separately.
Technologies
- Laravel 12
- PHP
- Vue 3
- Blade
- MySQL
- Stancl Tenancy
- Docker
- GitHub Actions
