Skip to main content
This covers the 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:
Routes in routes/legacy-api.php under /api/v1/* prefix. Controllers in app/Http/Controllers/v1/. Simpler, less abstraction, direct model operations.

Model inheritance

The Tutor model extends User using the calebporzio/parental package:
This means 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:
The global Handler.php returns JSON for API requests, includes debug info when APP_DEBUG=true.

Namespace

The application uses the tutorbloc\ namespace (not App\):
Autoloading configured in composer.json as PSR-4: "tutorbloc\\": "app/".