# Fily Project Structure

The Fily project follows this Laravel 12 structure. Files marked as implemented are currently present in the repository. Additional listed modules are the target locations for future implementation.

- `bootstrap`
  - `providers.php` (explicitly registers `AppServiceProvider` and the PHP Open Source Saver JWT provider)

- `app/Http/Controllers/Api/Provider`
  - `AuthController.php`
  - `ProfileController.php`
  - `SubscriptionController.php`
  - `ListingController.php`
  - `DashboardController.php`
- `app/Http/Controllers/Api/Customer`
  - `AuthController.php`
  - `ProfileController.php`
  - `ListingController.php`
  - `SavedListingController.php`
  - `ReviewController.php`
- `app/Http/Controllers/Api`
  - `ApiController.php` (shared JSON response helpers)
- `app/Http/Controllers/Admin`
  - `AuthController.php`
  - `DashboardController.php`
  - `CustomerController.php`
  - `ProviderController.php`
  - `SubscriptionPlanController.php`
  - `ListingModerationController.php`
  - `BannerController.php`
  - `PaymentController.php`
  - `WhatsappController.php`
- `app/Http/Requests`
  - `Auth/LoginRequest.php` (shared web and API login validation)
  - `Provider/RegisterRequest.php`
  - `Provider/SendOtpRequest.php`
  - `Provider/VerifyOtpRequest.php`
  - `Provider/CompleteProfileRequest.php`
  - `Provider/UpdateProfileRequest.php`
  - `Customer/RegisterRequest.php`
  - `Customer/SendOtpRequest.php`
  - `Customer/VerifyOtpRequest.php`
  - `Customer/CompleteProfileRequest.php`
  - `Customer/UpdateProfileRequest.php`
  - `Admin/Customer/StoreCustomerRequest.php`
  - `Admin/Customer/UpdateCustomerRequest.php`
  - `Admin/Provider/StoreProviderRequest.php`
  - `Admin/Provider/UpdateProviderRequest.php`
  - `Admin/Subscription/StoreCategoryRequest.php`
  - `Admin/Subscription/StoreSubscriptionPlanRequest.php`
  - `Admin/Subscription/StorePromoCodeRequest.php`
  - `Admin/Subscription/UpdateCategoryRequest.php`
  - `Admin/Subscription/UpdatePromoCodeRequest.php`
  - `Admin/Subscription/UpdateSubscriptionPlanRequest.php`
  - `Admin`
- `app/Http/Middleware`
  - `CheckAppVersion.php` (shared provider/customer mobile app version enforcement)
  - `JwtMiddleware.php`
  - `AdminMiddleware.php`
  - `CheckProviderSubscription.php`
- `app/Services/Provider`
  - `AuthService.php`
  - `ProfileService.php`
  - `SubscriptionService.php`
  - `ListingService.php`
  - `DashboardService.php`
- `app/Services/Customer`
  - `AuthService.php`
  - `ProfileService.php`
  - `ListingService.php`
  - `SavedListingService.php`
  - `ReviewService.php`
- `app/Services/Admin`
  - `AuthService.php`
  - `SubscriptionPlanService.php`
  - `ModerationService.php`
  - `BannerService.php`
  - `SubscriptionManagementService.php`
- `app/Services`
  - `AbstractJwtAuthService.php` (shared JWT and device lifecycle)
  - `Shared/OtpService.php`
  - `RazorpayService.php`
  - `WhatsappService.php`
  - `FcmService.php`
  - `ActivityLogService.php`
- `app/Repositories/Provider`
  - `AuthRepository.php`
  - `ProfileRepository.php`
  - `SubscriptionRepository.php`
  - `ListingRepository.php`
- `app/Repositories/Customer`
  - `AuthRepository.php`
  - `ProfileRepository.php`
  - `ListingRepository.php`
  - `SavedListingRepository.php`
  - `ReviewRepository.php`
- `app/Repositories/Admin`
  - `UserRepository.php`
  - `SubscriptionPlanRepository.php`
  - `ModerationRepository.php`
  - `SubscriptionManagementRepository.php`
- `app/Repositories/Contracts`
  - `AuthRepositoryInterface.php`
  - `CustomerProfileRepositoryInterface.php`
  - `ProviderProfileRepositoryInterface.php`
  - `SubscriptionManagementRepositoryInterface.php`
  - `OtpRepositoryInterface.php`
- `app/Repositories/Shared`
  - `AbstractAuthRepository.php` (shared Eloquent authentication queries)
  - `OtpRepository.php`
- `app/Models`
  - `User.php`
  - `UserDevice.php` (active JWT and FCM token per logged-in device)
  - `ProviderProfile.php`
  - `CustomerProfile.php`
  - `OtpVerification.php`
  - `AppVersion.php`
  - `Category.php`
  - `SubscriptionPlan.php`
  - `ProviderSubscription.php`
  - `Payment.php`
  - `PromoCode.php`
  - `JobListing.php`
  - `RentListing.php`
  - `HostelListing.php`
  - `ServiceListing.php`
  - `ListingMedia.php`
  - `SavedListing.php`
  - `Review.php`
  - `Banner.php`
  - `Notification.php`
  - `ActivityLog.php`
  - `ModerationLog.php`
  - `WhatsappLog.php`
  - `FcmLog.php`
- `app/Traits/LogActivityTrait.php`
- `app/Console/Commands`
  - `CheckExpiredSubscriptions.php`
  - `SendSubscriptionReminder.php`
- `routes`
  - `api.php` (API route aggregator)
  - `api/provider/api.php`
  - `api/customer/api.php`
  - `web.php` (web route aggregator; includes frontend routes and admin/auth routes)
  - `frontend/web.php` (public frontend, frontend auth, and frontend dashboard routes)
- `database/migrations`
  - `2026_05_30_000021_create_otp_verifications_table.php`
  - `2026_05_30_000022_allow_incomplete_customer_profiles.php` (allows OTP-first profile onboarding)
  - `2026_05_30_000023_expand_user_devices_device_token.php` (stores JWT tokens as text)
  - `2026_05_30_000024_add_customer_management_indexes.php` (admin customer directory indexes)
  - `2026_05_30_000025_allow_incomplete_provider_profiles.php` (allows OTP-first provider onboarding)
  - `2026_05_30_000026_add_provider_management_indexes.php` (admin provider directory indexes)
  - `2026_05_30_000027_create_app_versions_table.php` (shared provider/customer app release policy)
- `database/seeders`
  - `AdminSeeder.php`
  - `CategorySeeder.php`
  - `SubscriptionPlanSeeder.php`
- `resources/views/admin`
  - `auth`
  - `dashboard`
  - `providers`
  - `customers`
  - `listings`
  - `subscription-plans`
  - `promo-codes`
  - `banners`
  - `payments`
  - `whatsapp`
  - `customers/create_edit.blade.php` (shared admin create/edit modal)
  - `provider/create_edit.blade.php` (shared admin provider create/edit modal)
  - `plan-subscription/index.blade.php` (split category and subscription-plan management screen)
- `resources/views/frontend`
  - `partials/head.blade.php` (shared frontend document head, fonts, Bootstrap CSS)
  - `partials/header.blade.php` (shared frontend navbar and shared frontend button styles)
  - `partials/footer.blade.php` (shared frontend footer and Bootstrap JS)
  - `pages/welcome.blade.php` (public landing page)
  - `pages/category-list.blade.php` (public listing/category page)
  - `pages/details.blade.php` (public listing detail page)
  - `auth/customer-login.blade.php` (frontend customer mobile OTP login UI)
  - `auth/provider-login.blade.php` (frontend provider mobile OTP login UI)
  - `dashboard/index.blade.php` (generic frontend dashboard landing)
  - `dashboard/partials/styles.blade.php` (shared frontend dashboard styles)
  - `dashboard/customer/index.blade.php` (customer dashboard overview)
  - `dashboard/customer/saved.blade.php` (customer saved listings page)
  - `dashboard/customer/profile.blade.php` (customer profile settings page)
  - `dashboard/provider/index.blade.php` (provider dashboard overview)
  - `dashboard/provider/profile.blade.php` (provider profile settings page)
  - `dashboard/provider/add-list.blade.php` (provider add-listing UI)
  - `dashboard/provider/subscription.blade.php` (provider subscription details page)
- `tests/Feature/Api`
  - `JwtAuthenticationTest.php`
  - `CustomerOtpProfileTest.php`
  - `ProviderOtpProfileTest.php`
  - `AppVersionMiddlewareTest.php`
- `tests/Feature/Admin`
  - `CustomerManagementTest.php`
  - `ProviderManagementTest.php`
  - `SubscriptionPlanManagementTest.php`
- `config`
  - `logging.php`
  - `jwt.php`
  - `services.php`
  - `otp.php`
  - `razorpay.php`
- `storage/logs`
  - `provider-auth-YYYY-MM-DD.log`
  - `provider-YYYY-MM-DD.log`
  - `customer-auth-YYYY-MM-DD.log`
  - `customer-YYYY-MM-DD.log`
  - `otp-YYYY-MM-DD.log`
  - `admin-auth.log`
  - `payment.log`
  - `razorpay.log`
  - `listing.log`
  - `moderation.log`
  - `subscription.log`
  - `cron.log`
  - `whatsapp.log`
  - `fcm.log`
  - `error.log`

Use this structure as the target architecture for future Fily implementation work.

## JWT Token Policy

- Provider and customer access tokens expire after 30 days (`JWT_TTL=43200` minutes).
- Provider and customer APIs do not expose JWT refresh endpoints.
- When a token expires, the mobile user authenticates again using OTP.
- Logout blacklists the active JWT and deactivates the matching `user_devices` record.

## Frontend View Organization

- Public frontend views live under `resources/views/frontend`.
- Frontend route definitions live in `routes/frontend/web.php` and are included from `routes/web.php`.
- Frontend view names use the `frontend.*` namespace style, for example:
  - `frontend.pages.welcome`
  - `frontend.auth.customer-login`
  - `frontend.dashboard.customer.index`
  - `frontend.dashboard.provider.subscription`
- Shared frontend layout fragments are partials, not duplicated page markup.
