tutorbloc-api Laravel backend. For the Vue 2 frontend client, see the Frontend overview.
Directory layout
Architectural patterns
MVC + Service Layer
The codebase follows a layered approach:- Controllers handle HTTP concerns — request parsing, auth checks, response formatting
- Services contain business logic —
StripeService,RegistrationService,SearchService, etc. - Models define relationships, scopes, and some domain methods
- Transformers format model data into API response shapes
API versioning (dual approach)
Two versioning strategies coexist:- Legacy v1 (URL prefix)
- Current (header-based)
Routes in
routes/legacy-api.php under /api/v1/* prefix. Controllers in app/Http/Controllers/v1/. Simpler, less abstraction, direct model operations.Model inheritance
TheTutor model extends User using the calebporzio/parental package:
Tutor::query() always includes WHERE role_id = 1. The Tutor model adds tutor-specific methods like isVerified(), shouldApplyManagementFee(), and getAvailableLessonLocations().
Exception handling
Custom exception classes with static factories:Handler.php returns JSON for API requests, includes debug info when APP_DEBUG=true.
Namespace
The application uses thetutorbloc\ namespace (not App\):
composer.json as PSR-4: "tutorbloc\\": "app/".