How tauhid219/pwapractice works
1. Overall shape
- This is a Laravel 12 monolith for a quiz-learning PWA, split into three main surfaces: guest/auth, student/frontend, and admin.
- The core domain is educational content and assessment: categories, levels, questions, quiz attempts, live exams, user progress, and RBAC-managed administration.
2. HTTP entry and routing
- Requests enter through Laravel’s normal public/index.php front controller and are routed mainly by routes/web.php and routes/auth.php.
- Controllers are organized by boundary: app/Http/Controllers/Auth, Frontend, and Admin, which makes the UI/application split explicit at the routing layer.
3. Presentation layer split
- The app uses Blade views heavily, with distinct layout families:
- resources/views/layouts/* for shared app/admin shells
- resources/views/frontend/* for student-facing quiz/live-exam screens
- resources/views/admin/* for management screens
- View components and dedicated layout classes in app/View/Components keep the UI shell separate from feature pages.
4. Student-facing learning flow
- The frontend controllers (FrontendController, Frontend/QuizController, Frontend/LiveExamController) drive the learner experience.
- Students browse levels/questions, take quizzes, and take live exams; results are rendered in separate result pages.
- app/Services/QuizScoringService.php is the main scoring boundary for quiz evaluation, keeping grading logic out of controllers.
5. Live exam subsystem
- Live exams are modeled separately from regular quizzes using LiveExam, LiveExamQuestion, and LiveExamAttempt.
- The live exam flow includes dedicated create/manage/result screens in the admin panel and taking/results screens in the frontend.
- Anti-cheat and exam telemetry are part of the domain: tab_switches is tracked on live exam attempts, and there is a queued job ProcessLiveExamScore for post-submission processing.
6. Content management and admin operations
- Admin controllers manage the content catalog: categories, levels, questions, users, roles, permissions, and live exams.
- Admin views include CRUD pages plus specialized pages like live exam question management and results reporting.
- This side is the operational control plane for maintaining the learning content and exam setup.
7. Data import/export boundary
- Question data can be bulk imported and exported via app/Imports/* and app/Exports/*.
- Separate import/export types exist for standard questions and live exam question templates, which suggests a deliberate distinction between reusable question banks and exam-specific assemblies.
8. Domain model and persistence
- The primary tables/entities are users, categories, levels, questions, quiz_attempts, user_progress, live_exams, live_exam_questions, live_exam_attempts, and read_questions.
- Migrations show the schema evolved around quiz scoring, exam analytics, streaks, and localized/content metadata such as options and acceptable answers.
- Factories and seeders provide a reproducible baseline dataset for categories, levels, chapters, questions, and roles/permissions.
9. RBAC and access boundaries
- Authorization is a first-class subsystem, backed by config/permission.php and the permission_tables migration, indicating Spatie Laravel-Permission usage.
- Middleware like IsAdmin and CheckLevelAccess enforce role- and content-based access at the HTTP boundary.
- The admin area is therefore not just a UI split; it is protected by explicit authorization rules.
10. Request validation and form contracts
- Feature actions are guarded by dedicated Form Request classes such as StoreQuestionRequest, SubmitQuizRequest, SubmitLiveExamRequest, and profile/auth requests.
- This keeps validation and authorization close to the input boundary, separate from controller orchestration and domain logic.
11. PWA and client-side runtime
- The project includes a real offline-capable PWA layer: public/manifest.json, public/sw.js, icons, and offline fallback views.
- public/frontend/js/timer-worker.js and bundled frontend assets indicate client-side support for exam timing independent of the main page lifecycle.
- Sounds and worker-based timing are part of the learner experience, especially for quiz/live-exam interactions.
12. Cross-cutting concerns
- SetLocale supports bilingual content (lang/en.json, lang/bn.json), so localization is built into the request pipeline.
- SecurityHeaders is a dedicated middleware for response hardening.
- ProfileController and profile views show that user account management is a shared concern across student/admin experiences.
13. Background processing and platform services
- Laravel’s queue system is enabled (database/jobs migration and config/queue.php), with scoring work offloaded to a job for live exams.
- Cache and session infrastructure are standard Laravel services, with MySQL/SQLite as supported persistence targets.
- The architecture is largely server-rendered, with the PWA and worker layer augmenting, not replacing, the backend.
14. Verification and quality
- The test suite is broad and architecture-aware: feature tests cover auth, RBAC, quiz flows, live exams, profile/progress, and admin question management, while unit tests cover scoring and streak logic.
- This suggests the repo’s critical boundaries are meant to be preserved through tests: authentication, authorization, exam correctness, and scoring behavior.
Main entry points: web.php Web routes · Admin Admin controllers · Models Domain models · frontend Student views
Components 24
Entry & routing
HTTP entry points, route definitions, and request boundary concerns.
- Front controller · Laravel front controller that boots the application and receives web requests.
public/index.php - Web routes · Main route definitions for guest, frontend, and admin flows.
routes/web.php - Auth routes · Authentication and session-related route definitions.
routes/auth.php
Presentation layer
Blade layouts and UI shells for guest, frontend, and admin surfaces.
- Layout shells · Shared app, guest, and admin layout components.
app/View/Components - Student views · Learner-facing pages for levels, quizzes, and live exams.
resources/views/frontend - Admin views · Management screens for catalog, users, permissions, and live exams.
resources/views/admin
Learner flow
Student-facing quiz and live-exam experience.
- Auth controllers · Login, registration, verification, and password flows.
app/Http/Controllers/Auth - Frontend shell · Main frontend page controller for the student experience.
app/Http/Controllers/FrontendController.php - Quiz flow · Handles quiz browsing, taking, and submission.
app/Http/Controllers/Frontend/QuizController.php - Live exam flow · Handles live-exam browsing, taking, and result screens.
app/Http/Controllers/Frontend/LiveExamController.php - Profile · Shared account and progress management.
app/Http/Controllers/ProfileController.php
Admin control plane
Content, user, role, and live-exam administration.
- Admin controllers · CRUD and operational controllers for admin-managed content.
app/Http/Controllers/Admin
Domain & persistence
Core models, scoring logic, queue work, and schema-backed state.
- Scoring service · Encapsulates quiz grading and scoring rules.
app/Services/QuizScoringService.php - Score job · Queued post-processing for live-exam scoring.
app/Jobs/ProcessLiveExamScore.php - Domain models · Core content, attempt, progress, and live-exam entities.
app/Models - Import/export · Bulk question and live-exam template import/export boundary.
app/Imports - Schema & seed · Tables and baseline data for users, content, attempts, and permissions.
database/migrations
Platform services
Localization, middleware, PWA assets, and RBAC configuration.
- Locale · Sets request locale for bilingual UI and content.
app/Http/Middleware/SetLocale.php - Security headers · Adds response hardening headers.
app/Http/Middleware/SecurityHeaders.php - Admin gate · Protects admin surfaces with role-based access control.
app/Http/Middleware/IsAdmin.php - Level gate · Enforces content-level access boundaries for learners.
app/Http/Middleware/CheckLevelAccess.php - RBAC config · Permission table configuration for role and permission management.
config/permission.php - Translations · English and Bengali UI/content strings.
lang - PWA assets · Manifest, service worker, timer worker, and client-side exam assets.
public/manifest.json
Connections 29
- Front controller → Web routes: dispatches to · Front controller hands requests to route definitions.
- Web routes → Auth routes: includes · Web routing composes authentication routes.
- Web routes → Locale: applies · Localized request handling is part of the HTTP pipeline.
- Web routes → Security headers: applies · Response hardening is enforced at the boundary.
- Web routes → Admin gate: guards admin · Admin routes are protected by explicit authorization.
- Web routes → Level gate: guards content · Learner access is filtered by level/content rules.
- Web routes → Auth controllers: routes to · Authentication endpoints connect to auth controllers.
- Web routes → Frontend shell: routes to · Student landing and navigation flow through the frontend shell.
- Web routes → Quiz flow: routes to · Quiz pages and submissions are handled here.
- Web routes → Live exam flow: routes to · Live-exam pages and submissions are handled here.
- Web routes → Profile: routes to · Profile and progress pages are shared concerns.
- Web routes → Admin controllers: routes to · Admin CRUD endpoints map to management controllers.
- Frontend shell → Student views: renders · Student-facing screens are Blade-rendered.
- Quiz flow → Student views: renders · Quiz taking and result pages live in the frontend view family.
- Live exam flow → Student views: renders · Live-exam taking and result pages live in the frontend view family.
- Admin controllers → Admin views: renders · Admin CRUD and reporting screens are Blade-rendered.
- Auth controllers → Layout shells: uses · Guest and app shells are shared across auth flows.
- Frontend shell → Layout shells: uses · Frontend pages use shared layout components.
- Admin controllers → Layout shells: uses · Admin pages use a dedicated layout family.
- Quiz flow → Scoring service: scores with · Quiz evaluation is centralized in a scoring service.
- Live exam flow → Score job: queues · Live-exam submission triggers background scoring.
- Scoring service → Domain models: reads/writes · Scoring depends on quiz attempts, questions, and progress models.
- Score job → Domain models: updates · Queued processing persists live-exam results and analytics.
- Admin controllers → Domain models: manages · Admin CRUD operates on core catalog and exam entities.
- Import/export → Domain models: moves data for · Bulk import/export bridges external files and question models.
- RBAC config → Admin controllers: authorizes · RBAC configuration underpins admin access control.
- Translations → Locale: drives · Locale middleware selects translated strings.
- PWA assets → Student views: supports · Offline runtime and timing assets augment learner screens.
- Schema & seed → Domain models: backing store · Migrations and seeders define the persistence shape for the models.