# Lifestyle Manager App

A personal lifestyle management application for Persian-speaking users. Primary language is **Persian (فارسی)**, with English as the secondary language.

## Language & Localization

- **Primary UI language:** Persian (RTL layout)
- **Secondary UI language:** English (LTR)
- Translations live in `lang/fa/` and `lang/en/` using Laravel's localization system
- Enums use the `HasLabels` trait: call `label()` for current locale, `label('en')` for explicit English
- Database values use English slugs; display values are Persian-first
- Seed data uses Persian names
- Default app locale is `fa`; fallback locale is `en`

## Tech Stack

### Web (this repo)
- **Backend:** Laravel 13 (PHP 8.3+)
- **Frontend:** Vue 3 + TypeScript + Inertia.js 3
- **Styling:** Tailwind CSS 4 + shadcn-vue (reka-ui)
- **Auth (web):** Laravel Fortify (passwords, 2FA, passkeys) — session-based
- **Auth (API):** Laravel Sanctum — token-based for mobile clients
- **Build:** Vite 8
- **Database:** SQLite (default), MySQL/PostgreSQL supported

### Mobile (separate repo)
- **Framework:** Flutter (Dart) — single codebase for iOS & Android
- **State Management:** Riverpod
- **HTTP Client:** Dio
- **Routing:** go_router
- **Design:** Material 3, production-ready, modern, minimal UI following UI/UX best practices

## Project Structure

```
app/                    # Laravel backend
  Actions/Fortify/      # Auth actions (registration, password reset)
  Concerns/             # Shared traits (HasLabels, etc.)
  Enums/                # PHP enums (FoodCategory, WeightUnit, etc.)
  Http/Controllers/     # Web controllers (Inertia)
  Http/Controllers/Api/V1/  # API controllers (JSON, Sanctum-auth)
  Http/Middleware/       # Inertia, appearance & API locale middleware
  Http/Resources/       # API Resource classes (JSON transformers)
  Models/               # Eloquent models
  Services/             # Business logic (MealSuggestion, Outfit, AI)
  Providers/            # Service providers
resources/js/           # Vue frontend
  components/           # Shared Vue components
  components/ui/        # shadcn-vue UI primitives
  layouts/              # Page layouts (AppLayout, AuthLayout, etc.)
  pages/                # Inertia page components
lang/                   # Translation files (fa/, en/)
routes/                 # Laravel route definitions
  web.php               # Web routes (Inertia, session auth)
  api.php               # API routes (JSON, Sanctum token auth, /api/v1/...)
  settings.php          # Settings routes
database/migrations/    # Database migrations
config/                 # Laravel config files
tests/                  # PHPUnit tests
```

## Development Commands

```bash
# Setup
composer setup              # Full setup (install deps, migrate, build)

# Development
composer dev                # Start all dev servers (Laravel, Vite, queue, logs)
npm run dev                 # Vite dev server only
php artisan serve           # Laravel server only

# Testing & Linting
composer test               # Full test suite (lint + types + PHPUnit)
php artisan test            # PHPUnit only
composer lint               # Fix PHP code style (Pint)
composer lint:check         # Check PHP code style
composer types:check        # PHPStan static analysis
npm run lint                # ESLint fix
npm run lint:check          # ESLint check
npm run format              # Prettier format
npm run format:check        # Prettier check
npm run types:check         # vue-tsc type checking
composer ci:check           # Full CI check (JS lint + format + types + test)
```

## Key Conventions

### Web
- Vue pages live in `resources/js/pages/` and map to Inertia routes
- UI components use shadcn-vue (reka-ui based) in `resources/js/components/ui/`
- Routes defined via `Route::inertia()` for simple pages, controllers for data
- Laravel Wayfinder generates typed route helpers for the frontend
- Fortify handles all web authentication flows

### API
- API routes live in `routes/api.php` under `/api/v1/` prefix
- API controllers live in `App\Http\Controllers\Api\V1\` — separate from web controllers
- API controllers reuse the same Services, Models, and Form Requests as web controllers
- API responses use Laravel API Resource classes in `App\Http\Resources\`
- Authentication via Laravel Sanctum (Bearer token)
- Locale set via `Accept-Language` header (fa/en), handled by `SetApiLocale` middleware
- Enum endpoints (`/api/v1/enums`) provide localized dropdown values for mobile clients

### Shared
- Enums use `HasLabels` trait with `label(?string $locale)` backed by `lang/{locale}/enums.php`
- Weight/measurement standardization: use `WeightUnit` enum; `weight_grams` column stores a normalized gram value for items measured by piece
- Business logic lives in `App\Services\` and is shared between web and API controllers

## Pre-Push Checklist (MANDATORY)
Before every `git push`, run ALL of the following and fix any failures:
1. `composer lint:check` — fix code style issues
2. `composer types:check` — fix static analysis issues
3. `php artisan test` — ensure all tests pass
4. Check for merge conflicts with the base branch: `git fetch origin main && git merge --no-commit --no-ff origin/main` (abort if conflicts, resolve before pushing)

If any step fails, fix the issue before pushing. Never push code that hasn't passed all checks.

## PR Checklist
When creating a PR, verify the test plan items are actually checked/passing — do not leave unchecked items.

## Post-Merge Checklist (MANDATORY)
After a PR is merged:
1. Review the task's acceptance criteria to confirm all are met
2. Move the task/issue to the "Done"/"Completed" column on the project board

## Git Conventions

- **Branch naming:** `feature/{TASK_ID}` (e.g. `feature/25` for issue #25)

## Core Features

- **Meal Suggestion:** Suggest meals based on items users have in their refrigerator
- **Wardrobe Manager:** Suggest outfits based on the user's clothes inventory
- **Dashboard:** Central hub showing daily suggestions and quick actions
- **AI Suggestions:** AI-powered meal and outfit suggestions (via Prism/Claude Haiku)
- **REST API:** Full API layer for Flutter mobile app (Sanctum auth, all CRUD + suggestion endpoints)
- **Flutter Mobile App:** iOS & Android app (separate repo) — mirrors all web features
