How hoangpd2001/tnol-php works
Project Type and Purpose
• This is a monolithic full-stack web application built in PHP.
• It implements an online examination system supporting user authentication (token, Google OAuth, OTP), role-based access control, question/exam management, test-taking with anti-cheat features, reporting, and import/export utilities.
High-Level File Structure (inferred)
├─ config.php # database credentials, site config
├─ public/ # public-facing assets
│ ├─ index.php # routing entry point
│ ├─ css/, js/, img/ # static resources
├─ src/ # application source
│ ├─ controllers/ # request handlers (AuthController, ExamController…)
│ ├─ models/ # database entities (User, Question, Exam…)
│ ├─ views/ # PHP/HTML templates
│ ├─ services/ # business logic (OTPService, ImportService…)
│ └─ lib/ # third-party libs (Google OAuth, PHPWord)
├─ tests/ # unit/integration tests
├─ vendor/ # Composer dependencies
└─ README.md # project overview
a. Presentation Layer (Frontend)
• User’s Browser (landing pages, login, exam UI)
• Static assets (HTML/CSS/JS, AJAX calls)
b. Application Layer (Backend)
• Web Server + PHP Runtime (Apache/Nginx + PHP-FPM)
• MVC Components:
• Controllers (Auth, Exam, Question, Report, Import)
• Services (TokenManager, OTPManager, FileParser)
• Models (ORM or raw DB access)
c. Data Layer
• Relational Database (MySQL/MariaDB)
• File storage for imported Word docs (or BLOB)
d. External Services
• Google OAuth 2.0 API
• SMTP/Email Provider (OTP delivery)
Interactions and Data Flow
• User → Browser UI → AJAX/HTTP → Controllers
• Controllers call Services → Services read/write Models → Database
• AuthController → TokenManager for JWT storage in cookies/localStorage
• OTPController → OTPService → SMTP
• ImportController → PHPWord (in lib/) → Service parses Word → persists Questions
• ExamController monitors browser tab events via JS → AJAX logs to backend
• ReportingController queries DB → formats CSV/PDF for export
Architectural Patterns
• MVC: clear separation between controllers, views, models
• Service-oriented components for cross-cutting concerns (Auth, OTP, Import)
• Modularization by domain (Question module, Exam module, User module)
• Asynchronous interactions via AJAX for search/pagination and cheat detection
Final Advice
• Be exhaustive: break the monolith into functional slices (Auth, UserProfile, QuestionBank, ExamEngine, Reporting).
• With key technologies/frameworks (PHP 7.x/8.x, MySQL, AJAX, PHPWord, Google API client).