---
description: Vertical slice order. One feature end-to-end before the next.
globs: ["**"]
---

# Build Order — Vertical Slices

## The Rule

ONE vertical slice at a time: migration → model → service → controller/Livewire → view → test in browser.
NEVER batch 20 migrations, then 20 models, then 20 services.

## Module Build Order (dependencies dictate sequence)

### Phase 1: Foundation (no domain dependencies)
1. Organizations + Branches migration/model
2. Users migration/model + Auth (login, middleware)
3. Roles + Permissions migration/model/seeder
4. People migration/model
5. Layout (app.blade.php, sidebar, topbar) — bare minimum working UI

### Phase 2: Core Entities
6. Participants (migration → model → service → list/create/show views)
7. Guardians + pivot (migration → model → service → UI in participant form)
8. Activities (migration → model → simple CRUD)
9. Financial Accounts (migration → model → seeder)

### Phase 3: Programs & Training
10. Training Programs (migration → model → service → CRUD)
11. Training Groups (migration → model → service → CRUD)
12. Group Schedules + Session Generation
13. Enrollments (migration → model → service → UI in participant + program views)

### Phase 4: Financial
14. Invoices (migration → model → service → list/create/show)
15. Payments (migration → model → service → record payment UI)
16. Transactions (double-entry, created by PaymentService)
17. Wallets (migration → model → service → UI in participant profile)
18. Payment Plans + Installments
19. Cash Sessions + Daily Closing

### Phase 5: Scheduling & Space
20. Facilities (migration → model → CRUD)
21. Space Layouts + Segments
22. Space Reservations + Collision Detection
23. Assignments (migration → model → service → UI)

### Phase 6: Attendance
24. Attendance Records (migration → model)
25. Attendance Generation Service
26. Take Attendance UI (trainer view)
27. Auto-absent job + threshold enforcement

### Phase 7: Pricing & POS
28. Base Prices (migration → model → UI in program/product settings)
29. Pricing Rules (migration → model → service → rule builder UI)
30. Promotions/Coupons
31. POS Session + Transaction + Full POS UI

### Phase 8: Inventory
32. Products + Categories (migration → model → CRUD)
33. Warehouses + Inventory Levels
34. Inventory Movements
35. Purchase Orders
36. Kits
37. Stock Counts

### Phase 9: Notifications & CMS
38. Notification Templates + rendering
39. Email channel (poste.io)
40. SMS interface (log gateway)
41. Notification preferences
42. Audit Log (trait + observer)

### Phase 10: Reporting & Polish
43. Dashboard widgets
44. Exportable reports
45. Evaluations
46. System Settings UI
47. SuperAdmin panel

### Phase 11: Deployment
48. Dockerfile + nginx + supervisor
49. captain-definition
50. Environment variables
51. Deploy to CapRover

## Before Starting ANY Migration

1. Read the docs/rules file for that module
2. Check migration order in `docs/rules/11-integration-contract.md`
3. Ensure all prerequisite tables exist
4. Grep existing migrations for column names you're referencing
