Overview
The School Management Platform follows the Model-View-Controller (MVC) architectural pattern, a design pattern that separates application logic into three interconnected components. This separation promotes organized code, easier maintenance, and scalability.MVC Pattern Explained
The Three Components
Model
Handles data logic and database interactions using PDO
View
Presents data to users through PHP templates
Controller
Processes requests and coordinates Model-View interaction
Folder Structure
The application follows a clean, organized directory structure:Front Controller: index.php
Thepublic/index.php file serves as the front controller and routing mechanism for the entire application.
Routing Implementation
All requests are routed through a single entry point:Route Categories
Routes are organized by functionality:Authentication Routes
Authentication Routes
Dashboard Routes
Dashboard Routes
Student CRUD Routes
Student CRUD Routes
Grade Management Routes
Grade Management Routes
Timetable Routes
Timetable Routes
Controllers
Controllers handle HTTP requests and coordinate between models and views.Controller Example
app/controllers/StudentController.php
Key Controller Responsibilities
- Authentication checking via
Auth::admin(),Auth::teacher(), orAuth::student() - Request validation and data extraction from
$_POSTand$_GET - Model interaction to fetch or persist data
- View rendering by including the appropriate view file
- Redirects after successful operations
Models
Models encapsulate database logic and business rules.Model Example
app/models/Student.php
Model Best Practices
Database Abstraction
All database queries are contained in model classes
Prepared Statements
PDO prepared statements prevent SQL injection
Password Hashing
Passwords are hashed using
password_hash() before storageReusability
Models can be used across multiple controllers
Views
Views are PHP templates that generate HTML output.View Example
app/views/students/index.php
View Characteristics
- Minimal logic - only presentation logic (loops, conditionals)
- XSS protection via
htmlspecialchars()for output escaping - Bootstrap integration for responsive UI
- Data passed from controllers as PHP variables
Core Components
Authentication Class
TheAuth class in app/core/Auth.php provides centralized authentication and authorization:
app/core/Auth.php
Request Flow Example
Here’s how a typical request flows through the MVC architecture:Benefits of MVC Architecture
Separation of Concerns
Business logic, data access, and presentation are cleanly separated
Code Reusability
Models and controllers can be reused across different parts of the application
Easier Testing
Each component can be tested independently
Team Collaboration
Frontend and backend developers can work simultaneously on views and models
Maintainability
Changes to one component don’t affect others
Scalability
New features can be added following the same pattern
Next Steps
Database Schema
Explore the database structure and relationships
Security Features
Learn about authentication, authorization, and security measures