Architecture & Multi-Tenancy Engine
This platform is a multi-tenant School Management SaaS built with Laravel 12 and Vue 3 (Inertia.js). It uses one shared database, with tenant-owned records isolated by tenant ID and domain-based tenancy context powered by Stancl Tenancy v3.
- • tenants: Tenant ID, school profile, status, plan_id, db credentials
- • domains: Subdomains and custom domains linked to tenant
- • plans: Subscription tiers, limits (students, teachers, staff), pricing in BDT
- • subscriptions: School subscription periods, payment status, renewals
- • platform_invoices: Central billing invoices for schools
- • tenant_sms_logs: Platform-wide SMS allocations and consumption audit
- • database_backup_logs: Central database snapshot records
- • activity_log: Global super administrator audit trail
- • users: School admin, teachers, students, parents, staff
- • students & student_academics: Enrolled pupils, admission numbers, rolls
- • classes, sections, subjects: Academic structural hierarchy
- • attendances & biometric_devices: Physical punches, morning statuses
- • fee_categories, structures, invoices: Student billing & SSLCommerz
- • exams, exam_subjects, marks: Grading, report cards, GPA scales
- • books & book_issues: Library inventory, active loans, fines
- • payrolls & expenses: Staff compensations and operating vouchers
1. Incoming HTTP request hits Nginx reverse proxy.
2. Central domains (e.g. localhost, smartschool.com) match Central Route Collection in routes/web.php.
3. Tenant subdomains (e.g. ideal-school.smartschool.com) trigger Stancl\Tenancy\Middleware\InitializeTenancyByDomain in routes/tenant.php.
4. Tenant connection automatically dynamically connects to database tenant_{id}.
5. If domain is unmapped, system intercepts with custom 404 Inertia error handler.
Technology Stack & Architectural Patterns
| Layer / Tool | Version / Technology | Architectural Responsibility |
|---|---|---|
| Backend Framework | Laravel 12 (PHP 8.3+) | Routing, ORM, multi-tenancy pipelines, security, authorization gates. |
| Frontend Engine | Vue 3 + Inertia.js 2 | Single Page Application (SPA) experience without decoupling backend controllers. |
| Styling & UI | Tailwind CSS 3.4 | Responsive utility-first layout, dark/light theme, typography. |
| Multi-Tenancy | Stancl Tenancy 3.8 | Domain resolver, automatic tenant DB switching, filesystem scoping. |
| Authorization | Spatie Laravel Permission 6 | Role-Based Access Control (RBAC), granular permission matrices. |
| Audit Logging | Spatie Activitylog 4 | Immutable audit trail of actions performed by administrators and staff. |
| PDF Generation | Barryvdh DomPDF 3 | Server-side rendering of ID cards, admit cards, report cards, routine timetables. |
| Payment Gateway | SSLCommerz Hosted API | Online payment processing in Bangladeshi Taka (৳ BDT) with IPN callback. |
| Hardware Biometrics | ZKTeco Push Protocol | Hardware biometric time clocks, device heartbeat, punch log aggregation. |
To maintain slim controllers, business logic is encapsulated inside dedicated single-responsibility Action classes located in app/Actions/Tenant/. For example, enrolling an applicant is performed by CreateStudentAction, settling fees by SettleSslCommerzPaymentAction, and generating routine timetables by SaveRoutineAction.
Role: Super Admin (Central SaaS Platform)
The Super Administrator oversees the entire SaaS infrastructure. They manage tenant school onboarding, approval workflows, subscription billing, plan limits, SMS credits, central backups, and platform-level audit logs.
Path: /tenants & /approvals • Controller: TenantController, TenantApprovalController
- • School Registration: Public schools register via
/register-schoolspecifying requested subdomain, admin contact, and subscription plan. - • Approval Workflow: Pending applications appear in Central Approvals. Super Admin reviews school credentials and clicks [Approve].
- • Automated Provisioning: Approval triggers
JobPipelineexecutingCreateDatabasefollowed byMigrateDatabaseand seeding tenant roles and initial school administrator. - • Tenant Status: Statuses: pending, active, suspended, banned. Suspending instantly cuts off tenant subdomain access.
- • Impersonation: Super Admin can click [Impersonate] to securely authenticate into any school's administrative panel without asking for passwords.
Path: /plans • Controller: PlanController • Model: App\Models\Plan
- • Configure plans with student limits (e.g. 300, 1000, 5000) and staff limits (e.g. 30, 100, 500).
- • Dual billing cycles: price_monthly and price_yearly stored in BDT (৳).
- • Feature toggles: Biometric attendance enabled, SMS gateway enabled, White-label portal enabled.
Path: /sms • Controller: TenantSmsController • Model: App\Models\TenantSmsLog
- • Super admin allocates SMS credit packages to specific schools.
- • Tracks real-time sent count, failed count, recipient phone numbers, and gateway API responses across all schools.
Path: /backups • Controller: CentralBackupController • Rate-limited: throttle:10,1
- • Generate full platform database dumps on-demand.
- • Create platform database backups containing central and tenant records.
- • Secure rate-limited download stream with zip file integrity verification.
Role: School Admin (Tenant Administration)
The School Admin has full control over the individual institution's operational ecosystem. They manage academics, students, teachers, fee structures, examinations, attendance hardware, accounting, payroll, and website portfolio.
Path: /admin/dashboard • Controller: Tenant\DashboardController
- • Regional Demographic Heatmap: Visual interactive SVG map of the 8 administrative divisions of Bangladesh (Dhaka, Chittagong, Rajshahi, Khulna, Barishal, Sylhet, Rangpur, Mymensingh) showing live student enrollment distribution.
- • Faith & Religion Breakdown: Live enrollment distribution across Muslim, Hindu, Buddhist, Christian, and Other.
- • Device Platform Share: Real-time platform tracking (Desktop, Mobile, Tablet).
- • Today's Attendance Status Share: Donut chart of Present, Absent, Late, and Half-day students.
- • Financial Summary: Total billed, total collected (৳), outstanding dues, and 30-day collection velocity.
Path: /admin/students • Controller: StudentController • Action: PromoteStudentAction
- • Full Student Directory with server-side searchable data table and export to Excel/CSV.
- • Detailed 360-degree Profile: attendance history (MySQL aggregated), paid invoices, active book loans, guardian contact.
- • Bulk Promotion Engine: Promotes entire classes from one Academic Year to the next (e.g., Class 1 to Class 2) with automated roll reassignment while archiving previous academic histories in
student_academics.
Path: /admin/fees • Controller: FeeController • Action: GenerateClassInvoicesAction
- • Fee Categories: Tuition, Admission, Exam, Transport, Lab, Session, Development.
- • Bulk Class Invoice Generator: Emits customized invoices for every student in a class with 1-click.
- • Payment Collection: Supports Cash/Bank counter collection (with partial payments) or Online Checkout via SSLCommerz.
- • Automated Payment Reminders: Evaluates due dates and triggers automated SMS/Email reminders to parents.
Path: /admin/exams • Controller: ExamController • Policy: ExamPolicy
- • Configure Exam Types, exam subjects, full marks, and pass marks.
- • Tab-friendly Marks Entry Grid: Instant score recording, absence toggle, automated grade points (GPA 5.0 scale).
- • Publish Privacy Lock: Results remain strictly invisible to students and parents until the School Admin explicitly toggles
is_published = true. - • Official PDF Report Card generation via DomPDF.
Role: Teacher
Teachers manage academic instruction, daily attendance, examination marks entry, routine timetables, and their personal leave applications.
Teachers can record daily morning attendance and period-wise attendance for their assigned classes. Quick toggles: Present, Late, Absent, Half Day.
Routes: /admin/morning, /admin/attendance/students
Teachers can select Exam, Class, and Subject to open the Marks Entry Matrix. Marks are validated against subject full mark with auto GPA calculation.
Routes: /admin/exams/marks-entry
Teachers have full access to view weekly period routines for their assigned subjects and download printable landscape PDF timetables.
Routes: /admin/routines, /admin/routines/export/pdf
Teachers can apply for Sick Leave, Casual Leave, or Earned Leave with date range and reason. Balance automatically updates upon admin approval.
Routes: /admin/leaves • Action: ApplyLeaveAction
Role: Student
Enrolled students log into a personalized Student Portal. They can track attendance records, view class timetables, see examination schedules, download published report cards, view outstanding fee dues, and pay online.
Displays real-time attendance percentage, today's classes from the routine, upcoming exams, and pending fee alerts.
Path: /student/attendance • Visual monthly calendar color-coded by Present, Absent, Late, or Holiday with total percentages.
Path: /student/exams • Access to exam dates and syllabus. Student can download official PDF Report Card only when is_published = true.
Path: /student/fees • Lists all issued invoices, paid amounts, and due balances. Clicking [Pay Online] redirects to SSLCommerz gateway to pay via bKash, Nagad, Rocket, or Visa/Mastercard.
Role: Parent / Guardian
The Parent Portal features multi-child switching, enabling parents with multiple children enrolled in the same school to monitor each ward independently under a single user account.
A switcher on top of the dashboard toggles between children. When selected, all academic progress, attendance stats, and fee invoices dynamically refresh for that child.
Parents see real-time whether their child arrived at school or was marked absent. The system dispatches SMS notifications to the parent's mobile on absence.
Parents can view published exam gradebooks and download the official signed PDF report card for each term.
Parents can review monthly tuition bills and complete payment securely via SSLCommerz with instantaneous digital receipt issuance.
Role: Specialized Staff (Accounts, Library, Office)
Permissions: manage_fees, collect_fees, manage_accounts, manage_payroll.
- • Collects cash/cheque counter fees from students and prints official payment receipts.
- • Runs monthly bulk class invoice generation.
- • Tracks expense categories and records operating expense vouchers.
- • Executes monthly payroll batch generation and generates teacher/staff payslips.
Permissions: manage_library, view_library.
- • Catalogues books with Title, Author, ISBN, Publisher, Shelf location, and total copies.
- • Issues books to students or staff with automated due-date calculation.
- • Processes book returns and computes overdue delay fines.
Permissions: manage_admissions, view_students.
- • Reviews incoming online admission applications and updates preliminary statuses.
- • Assists with walk-in parent inquiries and document uploads.
DFD Level 0: Context Data Flow Diagram
The Level 0 context diagram demonstrates the boundary of the Smart School Management SaaS platform and how external entities (Super Admin, School Admin, Teachers, Students, Parents, Payment Gateways, and Biometric Devices) interact with the central system.
DFD Level 1: Multi-Tenancy Architecture & Routing Flow
Decomposition of how the routing layer classifies HTTP requests, identifies tenancy, selects the target database, and enforces authorization gates.
DFD Level 2: Student Admission & Enrollment Pipeline
Step-by-step logic and data transformations from a prospective student's online application to active student account, guardian linkage, and academic roll assignment.
DFD Level 2: Biometric Hardware & Attendance Engine
Architecture of physical hardware biometric integration alongside daily manual morning attendance recording.
DFD Level 2: Fees, Invoicing & SSLCommerz Payment Flow
Complete transaction lifecycle from bulk class fee generation to online checkout, IPN webhook validation, and ledger settlement.
DFD Level 2: Examination, Marks Entry & Report Cards
Workflow detailing how exam structures are set, marks recorded, GPA computed, and unpublished results locked against unauthorized viewing.
Database Schema & Entity Relationship Architecture
A comprehensive map of all tables, relations, and foreign keys across Central and Tenant database schemas.
[classes] 1 ──── < [sections]
│
├──── < [class_subjects] > ──── [subjects]
│
├──── < [student_academics] > ──── [students] 1 ──── 1 [users]
│ │
│ ├──── < [student_guardian] > ──── [guardians] 1 ──── 1 [users]
│ │
│ ├──── < [attendances]
│ │
│ ├──── < [invoices] 1 ──── < [invoice_items]
│ │ │
│ │ └──── < [payments]
│ │
│ └──── < [marks] > ──── [exams] 1 ──── < [exam_subjects]
│
├──── < [routines] (day, period, room, subject_id, teacher_id)
│
└──── < [fee_structures] > ──── [fee_categories]
Artisan Commands & Operations Playbook
# Run all central and tenant schema migrations
php artisan migrate
# Seed platform data and tenant-scoped records
php artisan db:seed
# Cache configurations
php artisan config:cache
# Cache routes (with multi-tenant domain constraints)
php artisan route:cache
# Cache Blade templates
php artisan view:cache
# Clear all caches for fresh deployment
php artisan optimize:clear
# Build production bundle (Dynamic Async ApexCharts & Vite)
npm run build
# Start local HMR development server
npm run dev
Actions, Policies & Code Conventions
A guide for incoming developers on writing new code adhering to this codebase's architectural integrity.
Always use the centralized helpers on User model instead of manually checking user_type strings:
$user->isAdmin(), $user->isTeacher(), $user->isStudent(), $user->isParent(), $user->isStaff(), $user->isAccountant(), $user->isLibrarian(), $user->isReceptionist().
All currency formatting throughout the application must use the official Bangladeshi Taka symbol: ৳ (BDT), never raw dollar ($) signs.
Always authorize actions using Laravel Policies registered in app/Policies/Tenant/:
$this->authorize('create', Exam::class); or $this->authorize('view', $invoice);.
Never dispatch external HTTP notifications or SMS inside DB::transaction(function() { ... }). Always execute the database mutations first, and dispatch notifications after the transaction successfully commits.