178 lines
5.9 KiB
Markdown
178 lines
5.9 KiB
Markdown
# CLAUDE.md
|
|
|
|
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
|
|
|
|
## Project Overview
|
|
|
|
Libra Law Firm is a bilingual (Arabic/English) web platform for managing client consultations, appointments, and case tracking. It serves as both a public-facing website and an internal management tool.
|
|
|
|
**Domain:** libra.ps
|
|
|
|
## Development Commands
|
|
|
|
```bash
|
|
# Initial setup (install deps, create .env, migrate, build assets)
|
|
composer run setup
|
|
|
|
# Start development (server, queue, logs, vite in parallel)
|
|
composer run dev
|
|
|
|
# Run all tests
|
|
composer run test
|
|
|
|
# Run specific test file
|
|
php artisan test tests/Feature/Auth/AuthenticationTest.php
|
|
|
|
# Run tests matching a filter
|
|
php artisan test --filter=testName
|
|
|
|
# Build frontend assets
|
|
npm run build
|
|
|
|
# Format PHP code
|
|
vendor/bin/pint --dirty
|
|
|
|
# Create new Volt component with test
|
|
php artisan make:volt pages/component-name --pest
|
|
|
|
# Create model with migration and factory
|
|
php artisan make:model ModelName -mf
|
|
```
|
|
|
|
## Architecture
|
|
|
|
### Technology Stack
|
|
- **Backend:** Laravel 12, PHP 8.4, Laravel Fortify (auth)
|
|
- **Frontend:** Livewire 3, Volt (single-file components), Flux UI Free, Tailwind CSS 4
|
|
- **Database:** SQLite (dev), MariaDB (production)
|
|
- **Testing:** Pest 4
|
|
|
|
### Key Directories
|
|
- `resources/views/livewire/` - Volt single-file components (class-based pattern)
|
|
- `resources/views/components/` - Reusable Blade components
|
|
- `app/Actions/Fortify/` - Authentication business logic
|
|
- `app/Providers/FortifyServiceProvider.php` - Custom auth views
|
|
- `app/Enums/` - UserType, UserStatus, ConsultationType, ConsultationStatus, PaymentStatus, TimelineStatus, PostStatus
|
|
- `docs/prd.md` - Full product requirements document
|
|
- `docs/architecture.md` - Complete architecture document
|
|
- `docs/stories/` - User story specifications
|
|
|
|
### Services
|
|
- `app/Services/AvailabilityService.php` - Calculates available time slots for bookings
|
|
- `app/Services/CalendarService.php` - Generates iCalendar files for consultations
|
|
|
|
### Domain Model
|
|
Core models in `app/Models/`:
|
|
- **User** - Three types: `admin`, `individual` (client), `company` (client)
|
|
- **Consultation** - Booking requests between clients and admin
|
|
- **Timeline** - Case tracking for clients
|
|
- **TimelineUpdate** - Updates within a timeline
|
|
- **WorkingHour** - Admin's available hours for booking
|
|
- **BlockedTime** - Time slots blocked from booking
|
|
- **Post** - Blog/legal content articles
|
|
- **Notification** - User notifications
|
|
- **AdminLog** - Audit logging for admin actions
|
|
|
|
### Route Structure
|
|
```
|
|
/ - Public home
|
|
/booking - Consultation booking
|
|
/posts - Public posts/blog
|
|
/language/{locale} - Language switch (ar/en)
|
|
|
|
/admin/* - Admin dashboard (requires admin middleware)
|
|
/client/* - Client dashboard
|
|
/settings/* - User settings (profile, password, 2FA, appearance)
|
|
```
|
|
|
|
### Middleware
|
|
- `admin` - Ensures user is admin (`EnsureUserIsAdmin`)
|
|
- `client` - Ensures user is a client (`EnsureUserIsClient`)
|
|
- `active` - Ensures user account is active (`EnsureUserIsActive`)
|
|
- `SetLocale` - Sets language from session/user preference
|
|
|
|
### Authentication (Fortify)
|
|
All auth is handled via Fortify with custom Volt views. Features enabled:
|
|
- Email verification, Password reset, Profile/password updates
|
|
- Two-factor authentication with QR codes and recovery codes
|
|
- Note: Public registration is disabled; admin creates all client accounts
|
|
|
|
### Volt Component Pattern
|
|
This project uses **class-based** Volt components:
|
|
|
|
```php
|
|
<?php
|
|
use Livewire\Volt\Component;
|
|
|
|
new class extends Component {
|
|
public string $name = '';
|
|
|
|
public function mount(): void
|
|
{
|
|
$this->name = Auth::user()->name;
|
|
}
|
|
|
|
public function save(): void
|
|
{
|
|
// ...
|
|
}
|
|
}; ?>
|
|
|
|
<div>
|
|
<!-- Blade template -->
|
|
</div>
|
|
```
|
|
|
|
### Flux UI Components
|
|
Use Flux components when available (free edition):
|
|
`avatar, badge, brand, breadcrumbs, button, callout, checkbox, dropdown, field, heading, icon, input, modal, navbar, otp-input, profile, radio, select, separator, skeleton, switch, text, textarea, tooltip`
|
|
|
|
Example: `<flux:button variant="primary">Save</flux:button>`
|
|
|
|
### Testing Pattern
|
|
Tests use Pest with `Volt::test()` for Livewire components:
|
|
|
|
```php
|
|
use Livewire\Volt\Volt;
|
|
|
|
test('profile can be updated', function () {
|
|
$user = User::factory()->create();
|
|
|
|
Volt::test('settings.profile')
|
|
->actingAs($user)
|
|
->set('name', 'New Name')
|
|
->call('updateProfileInformation')
|
|
->assertHasNoErrors();
|
|
});
|
|
```
|
|
|
|
### User Factory States
|
|
When testing, use these factory states:
|
|
- `->admin()` - Creates admin user
|
|
- `->individual()` - Creates individual client
|
|
- `->company()` - Creates company client
|
|
- `->client()` - Randomly creates individual or company
|
|
- `->deactivated()` - Creates deactivated user
|
|
- `->unverified()` - Creates user without email verification
|
|
- `->withTwoFactor()` / `->withoutTwoFactor()` - 2FA states
|
|
|
|
### Notifications
|
|
Located in `app/Notifications/`:
|
|
- **Booking:** `BookingApproved`, `BookingRejected`
|
|
- **Consultation:** `ConsultationCancelled`, `ConsultationRescheduled`, `ConsultationReminder24h`, `ConsultationReminder2h`
|
|
- **Account:** `WelcomeAccountNotification`, `PasswordResetByAdminNotification`, `AccountReactivatedNotification`, `AccountTypeChangedNotification`
|
|
- **Timeline:** `TimelineUpdateNotification`
|
|
|
|
### Business Rules
|
|
- **No self-registration:** Admin creates all client accounts
|
|
- **Single admin:** One lawyer manages the platform
|
|
- **No online payments:** All payments handled offline
|
|
- **Cascade deletes:** User deletion cascades to consultations, timelines, notifications
|
|
- **Bilingual required:** All user-facing text needs Arabic and English
|
|
|
|
## Design Requirements (from PRD)
|
|
- **Color scheme:** Charcoal (#4A4A42) + Warm Gray (#C9C4BA), Off-White (#E8E4DC), Deep Black (#1A1A1A)
|
|
- **Bilingual:** Arabic (primary, RTL) / English (LTR)
|
|
- Professional, elegant aesthetic with botanical/wheat Libra logo
|
|
- See `docs/brand.md` for complete brand guidelines
|