# El Captain Sports Management

## What This Is
A modular ERP specialized for sports organizations. Activity-agnostic platform — any sport/activity is a configuration of the same underlying business model.

## Stack
- **Framework:** Laravel 13 (PHP 8.5)
- **Database:** PostgreSQL 16 at `18.192.166.221:5434` (db: `elcaptainsportsonly`, user: `elcaptain`)
- **Frontend:** Livewire 3 + Alpine.js + Tailwind CSS (to be added)
- **Multi-tenancy:** Single database with `academy_id` column + global scope
- **Deploy:** CapRover at `*.caprover.al-arcade.com`

## Architecture

### Domain-Driven Layout
```
app/Domain/{Module}/Models/     — Eloquent models
app/Domain/{Module}/Services/   — Business logic (DB::transaction wrapped)
app/Domain/{Module}/Events/     — Domain events (dispatched after commit)
app/Domain/{Module}/Enums/      — PHP 8.1+ backed enums
app/Domain/Shared/Traits/       — BelongsToAcademy, HasUuid
```

### Key Patterns
- **BelongsToAcademy trait** — auto-scopes queries to `app('current_academy')`
- **HasUuid trait** — auto-generates UUID, uses `uuid` as route key
- **Amounts stored as integers** (piasters, not pounds) to avoid float issues
- **Double-entry transactions** — every financial operation creates debit + credit entries
- **Events for side effects** — never send email/notification inline from services

### Modules (in build order)
1. Financial (DONE - schema + models + services)
2. People (next)
3. Training Programs + Groups
4. Facility & Scheduling
5. Attendance
6. Inventory
7. Pricing Engine

## Commands
```bash
php artisan serve          # Dev server at :8000
php artisan migrate        # Run migrations
php artisan db:seed        # Seed default data
php artisan tinker         # REPL
```

## Login Credentials (dev)
- Email: `admin@oc-sport.com`
- Password: `Alarcade123#`

## Rules
- Laravel Discipline is ALWAYS active (see global CLAUDE.md)
- Migration first — schema is source of truth
- One vertical slice at a time
- Arabic locale default (`ar`), bilingual (name + name_ar)
- CHECK constraints on all status/type columns
- No `href="#"` — real routes or don't render the link
