Project: Slot Booking API Service
Framework: Laravel 12 (PHP 8.2+)
Database: MySQL 8+
Repository: github.com/SirAndrewGotham/LogisticsApiTest
Contact: andreogotema@gmail.com
Website: AndrewGotham.ru
This project uses the lean application skeleton introduced in Laravel 12. Key points:
- No Default AppServiceProvider: Laravel 12 does not include an
AppServiceProviderin its default structure. Service bindings are typically handled via thebootstrap/providers.phpfile or by creating specific providers only when needed . - Service Layer: Business logic is encapsulated in dedicated Service classes (e.g.,
SlotService) to keep controllers thin and focused on HTTP handling, adhering to the Single Responsibility Principle . - Configuration: Environment variables are accessed via
config()helper after being defined in configuration files, not directly viaenv(). - Testing: The project is configured for testing with PHPUnit/Pest. Laravel's testing environment automatically sets the configuration to
testingand uses array drivers for sessions/cache .
This API service manages slot bookings (warehouse windows, delivery slots, or client appointments) with:
- Limited capacity slots
- Temporary holds with expiration
- Capacity management to prevent overbooking
- Idempotent operations
- Cache protection (stampede prevention)
slots table:
id,capacity,remaining,created_at,updated_at- Check constraint:
remaining >= 0 AND remaining <= capacity
holds table:
id,slot_id,user_id,status(held/confirmed/cancelled/expired)idempotency_key(UNIQUE),expires_at,created_at,updated_at- Indexes:
(slot_id, status),(expires_at),(idempotency_key)
GET /slots/availability # Cached 5-15s with stampede protection
POST /slots/{id}/hold # Idempotent (Idempotency-Key header)
POST /holds/{id}/confirm # Atomic capacity decrement
DELETE /holds/{id} # Cancel hold, return capacity
- Service Classes for Business Logic: Controllers delegate core operations to
SlotServiceandCacheService, keeping them clean and testable . - Form Request Validation: Use dedicated Request classes (e.g.,
StoreHoldRequest) for input validation, separating concerns from controllers . - Database Transactions: Wrap operations that affect multiple records (like creating a hold and decrementing remaining capacity) in
DB::transaction. - Efficient Eloquent: Use Eloquent ORM features like model casting, accessors/mutators with closure syntax, and eager loading where applicable .
- Artisan CLI: Utilize Artisan commands for code generation (
make:controller,make:service,make:request) and optimizations (config:cache,route:cache) . - Modern Testing: Leverage Laravel's built-in testing tools, including database migrations per test and the ability to run tests in parallel for speed .
- Repository link with complete code
- Video on Yandex.Disk with access to
serggit+phptest@yandex.ru - Email subject: "Видео-вакансия — результат - ФИО"
- Email sender:
andreogotema@gmail.com - README with setup instructions and curl examples
- Deadline: 10 days from assignment receipt