# Flutter Architecture (Customer App) — `mobile/lucknowone_app`

This describes the production Flutter architecture to implement LucknowOne (customer-only), matching the existing web UI/UX but optimized for native app UX.

## 1) Stack

- Flutter stable (current workstation: `flutter 3.32.0`, Dart 3.8)
- **Riverpod** (no generator/codegen to avoid version conflicts on this toolchain; we’ll use explicit providers)
- Dio + logging (`pretty_dio_logger`) for API
- GoRouter for navigation
- Freezed + json_serializable for DTOs
- flutter_secure_storage for token storage
- intl for formatting/localization readiness

## 2) Folder structure (feature-first + clean architecture)

```text
lib/
  core/
    routing/
      app_router.dart
    theme/
      app_colors.dart
      app_theme.dart
    network/
      (dio client, interceptors, error mapping)
    storage/
      (secure storage + cache)
    utils/
      (formatters, validators)

  features/
    auth/
      data/
      domain/
      presentation/
    home/
      data/
      domain/
      presentation/
    modules/
      data/
      domain/
      presentation/
    leads/
      data/
      domain/
      presentation/
    quick_pay/
      data/
      domain/
      presentation/
    profile/
      data/
      domain/
      presentation/
    my_properties/
      data/
      domain/
      presentation/
```

## 3) App entrypoint

- `lib/main.dart`
  - wraps app in `ProviderScope`
  - uses `MaterialApp.router`
  - uses `AppTheme.light()` / `AppTheme.dark()`
  - uses `appRouterProvider`

## 4) Theming & design tokens (web parity)

Tokens extracted from `public/css/homepage.css`:
- primary: `#de6d0f`
- hover: `#bb550c`
- card radius ~14px

In Flutter:
- `AppColors.brandPrimary` = `0xFFDE6D0F`
- `AppTheme` uses Material 3 `ColorScheme.fromSeed` but pins `primary` and `surface`.

Next step (implementation phase): add **Inter** font assets and standard spacing/radius constants.

## 5) Navigation (GoRouter)

Initial route map will mirror the web module flow:
- `/` Home
- `/auth` OTP login, OTP verify
- `/modules/:type` list (property/job/education/service)
- `/modules/:type/:id` detail
- `/dashboard` (auth)
- `/quick-pay` (auth)

Auth guarding will be implemented via a Riverpod auth state provider.

# Flutter Architecture (Customer App) — `mobile/lucknowone_app`

This describes the production structure we’ll follow for the Flutter app, aligned with **Clean Architecture**, **feature-first modules**, and the API contracts in `docs/mobile/API_CONTRACTS_V1.md`.

## 1) Stack

- Flutter (stable): created under `mobile/lucknowone_app`
- State management: **Riverpod** (manual providers; no codegen required)
- Networking: **Dio** (+ `pretty_dio_logger`)
- Navigation: **GoRouter**
- Models: **Freezed + json_serializable** (via `build_runner`)
- Secure storage: `flutter_secure_storage`
- Intl: `intl`

## 2) Folder structure

We use **feature-first Clean Architecture** with strict dependency direction.

```
lib/
  core/
    routing/
      app_router.dart
    theme/
      app_colors.dart
      app_theme.dart
    network/               # dio client, interceptors, error mapping (next)
    storage/               # secure token storage (next)
    widgets/               # shared reusable widgets (next)
    utils/                 # helpers, formatters (next)

  features/
    home/
      presentation/
        home_screen.dart

    auth/                  # otp login + token lifecycle (next)
    modules/               # list + detail shells (next)
    leads/                 # lead capture + my leads (next)
    quick_pay/             # razorpay flow + history (next)
    profile/               # me + edit + password (next)
    my_properties/         # customer property posting flows (next)
```

### Dependency rules

- `features/*/domain` **must not** depend on Flutter or on `data`.
- `features/*/data` depends on `core/network`, DTOs, and external packages.
- `features/*/presentation` depends on `domain` (usecases/entities) and Riverpod providers.

## 3) Routing

- Router lives in `lib/core/routing/app_router.dart`
- Route guards (auth-required pages) will be implemented using a token provider and `redirect`.

## 4) Theming / design tokens

Tokens are based on the existing web CSS:
- Primary: `#de6d0f`
- Hover/dark: `#bb550c`
- Card radius: 14
- Buttons: 12

Files:
- `lib/core/theme/app_colors.dart`
- `lib/core/theme/app_theme.dart`

## 5) Codegen workflow (Freezed/JSON)

When we introduce DTOs:

```bash
cd mobile/lucknowone_app
flutter pub run build_runner build --delete-conflicting-outputs
```

## 6) Current status

- App shell wired with `ProviderScope`, `MaterialApp.router`, base light/dark themes.
- Home screen placeholder exists as the starting point for UI parity with `resources/views/site/home.blade.php`.

