This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
LoadPartner TMS - An open source Transportation Management System for freight brokers built with Laravel + Inertia.js + React + TypeScript.
# Set up with Laravel Sail
sail up -d
sail artisan migrate
sail npm install
sail artisan key:generate
sail npm run dev
# Fresh test data
sail artisan dev:refresh# Run all dev services (server, queue, logs, vite)
composer run dev
# Individual commands
sail artisan serve
sail npm run dev
sail artisan queue:listen --tries=1
sail artisan pail --timeout=0# Run tests (uses Pest)
sail artisan test
# or
sail pest
# Run static analysis
sail artisan dev:check # Runs PHPStan + IDE helper generation
vendor/bin/phpstan analyse
# Lint frontend
npm run lint# Build frontend assets
npm run build
# Link storage for file uploads
sail artisan storage:link- All business logic organized in
app/Actions/by domain - Uses
lorisleiva/laravel-actionspackage - Each action has
handle(),asController(),rules(),authorize()methods - Actions serve as both controllers and reusable business logic
- All models use
HasOrganizationtrait for automatic scoping OrganizationScopeprovides global filtering- Use
current_organization_id()helper for context
- Shipments use
spatie/laravel-model-states - States: Pending → Booked → Dispatched → AtPickup → InTransit → AtDelivery → Delivered
- State transitions trigger events for side effects
- React + TypeScript with Inertia.js for SPA-like experience
- Components organized by domain in
resources/js/Components/ - UI components in
resources/js/Components/ui/ - Pages in
resources/js/Pages/
Organization- Multi-tenant containerShipment- Core business entity with state machineCarrier- Transportation providersCustomer- Freight customersContact- Polymorphic contacts systemDocument- Polymorphic file attachmentsNote- Polymorphic notes system
- Create action in appropriate domain directory
- Add enum values if needed (sync with
Permission::syncToDatabase()) - Create policy for authorization
- Add tests in corresponding test directories
- Create frontend components following existing patterns
- Add permissions to
app/Enums/Permission.php - Include entry in
label()method - Create migration calling
App\Enums\Permission::syncToDatabase()
- Use event bus for real-time updates between components
- Emit events:
emit('event-name-' + id) - Subscribe:
subscribe('event-name-' + id, callback)
- Modify
CreateOrUpdateOrganizationDefaultsaction - Consider both migration for existing orgs and action updates for new ones
- Uses SQLite for development, PostgreSQL for production
- Migrations in
database/migrations/ - Seeders for test data in
database/seeders/
- Supports both local and S3 storage
- Configured via
FILESYSTEM_DISKenvironment variable - Uses polymorphic
Documentmodel for file attachments
- Unit tests in
tests/Unit/ - Feature tests in
tests/Feature/ - Uses Pest testing framework
- Factory classes for model creation
Available via sail artisan dev:refresh:
[email protected]/password(admin)[email protected]/password(regular user)
lorisleiva/laravel-actions- Business logic actionsspatie/laravel-model-states- State machinespatie/laravel-permission- Authorizationinertiajs/inertia-laravel- Frontend bridgelaravel/cashier- Subscription billing
@inertiajs/react- Inertia.js React adapter@tanstack/react-table- Data tablesreact-hook-form- Form management@radix-ui/*- UI componentstailwindcss- Styling
- Follow PSR-12 coding standards
- Use PHP 8.2+ features including enums
- Type hints required for all methods
- PHPStan level 5 static analysis
- Strict TypeScript configuration
- Props interfaces for all components
- Use React hooks patterns
- ESLint + Prettier for code formatting
- Run
sail artisan storage:linkif file uploads fail - Check organization context if data not appearing
- Verify permissions if authorization fails
- Use event bus for component updates, not direct prop passing
- All services run via Docker Compose
- Access application at
http://localhost - Mailpit at
http://localhost:8025for email testing - Database accessible via standard Laravel tools