Skip to content

Latest commit

Β 

History

History
81 lines (75 loc) Β· 4.46 KB

File metadata and controls

81 lines (75 loc) Β· 4.46 KB

Folder Structure

Actual layout of flutter-clean-arch-unicorn (generated from the repository tree). Mirrors the diagrams in README.md and ARCHITECTURE.md.

flutter_clean_arch_unicorn/
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ configs/                 # Global app configs (AppConfigs, environment)
β”‚   β”œβ”€β”€ core/
β”‚   β”‚   └── database/            # Drift local relational DB (typed tables, migrations)
β”‚   β”‚       β”œβ”€β”€ database.dart
β”‚   β”‚       β”œβ”€β”€ database.g.dart
β”‚   β”‚       β”œβ”€β”€ database_connection.dart
β”‚   β”‚       β”œβ”€β”€ database_provider.dart
β”‚   β”‚       └── tables/
β”‚   β”œβ”€β”€ features/                # Isolated feature modules (feature-first)
β”‚   β”‚   β”œβ”€β”€ authentication/      # Example feature
β”‚   β”‚   β”‚   β”œβ”€β”€ data/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ datasource/        # auth_remote_data_source.dart
β”‚   β”‚   β”‚   β”‚   └── repositories/      # authentication_repository_impl.dart
β”‚   β”‚   β”‚   β”œβ”€β”€ domain/
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ models/            # user_model.dart
β”‚   β”‚   β”‚   β”‚   β”œβ”€β”€ repositories/      # AuthenticationRepository (interface)
β”‚   β”‚   β”‚   β”‚   └── use_cases/         # login_use_case.dart
β”‚   β”‚   β”‚   └── presentation/
β”‚   β”‚   β”‚       β”œβ”€β”€ providers/
β”‚   β”‚   β”‚       β”‚   β”œβ”€β”€ state/         # auth_state.dart, auth_notifier.dart
β”‚   β”‚   β”‚       β”‚   └── auth_providers.dart
β”‚   β”‚   β”‚       β”œβ”€β”€ screens/           # login_screen.dart
β”‚   β”‚   β”‚       └── widgets/
β”‚   β”‚   β”œβ”€β”€ dashboard/           # Same structure (data/domain/presentation)
β”‚   β”‚   └── splash/              # Splash screen (presentation only)
β”‚   β”œβ”€β”€ main/                    # Entry points
β”‚   β”‚   β”œβ”€β”€ main_dev.dart
β”‚   β”‚   β”œβ”€β”€ main_staging.dart
β”‚   β”‚   β”œβ”€β”€ main_prod.dart
β”‚   β”‚   └── main_common.dart
β”‚   β”œβ”€β”€ routes/                  # GoRouter (app_router.dart)
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ observability/       # Logger, ErrorReporter, Analytics, FeatureFlags contracts
β”‚   β”‚   β”œβ”€β”€ security/            # SecureStorage (interface + impl + fake)
β”‚   β”‚   β”œβ”€β”€ network/             # Dio interceptors (retry, auth, logging)
β”‚   β”‚   └── user_cache_service/  # Local user cache (SharedPreferences + SecureStorage)
β”‚   └── shared/                  # Shared code
β”‚       β”œβ”€β”€ data/                # local (shared_prefs) + remote (dio) datasources
β”‚       β”œβ”€β”€ domain/              # models (product/user), providers, either
β”‚       β”œβ”€β”€ exceptions/          # AppException hierarchy
β”‚       β”œβ”€β”€ mixins/              # exception_handler_mixin.dart
β”‚       β”œβ”€β”€ presentation/        # providers, theme, widgets
β”‚       └── theme/               # AppTheme
β”œβ”€β”€ test/                        # 151 tests (mirrors lib/), + fixtures, regression, tool
β”œβ”€β”€ tool/                        # new_feature.dart generator, check_boundaries.dart
β”œβ”€β”€ scripts/                     # check_secrets.sh pre-commit checker
β”œβ”€β”€ docs/                        # ADRs, audits, handoffs
└── .github/
    β”œβ”€β”€ workflows/main.yml       # CI: pub get β†’ build_runner β†’ format β†’ analyze β†’ boundary β†’ test+coverage β†’ coverage gate β†’ apk build
    β”œβ”€β”€ copilot-instructions.md
    └── PULL_REQUEST_TEMPLATE.md

Rules (enforced by tool/check_boundaries.dart in CI)

  • Feature A never imports Feature B internals.
  • presentation never imports dio / drift / firebase directly.
  • domain never imports data or presentation.
  • Infrastructure (Dio, Drift, SecureStorage) is injected via Riverpod providers.
  • shared/ holds cross-cutting models and utilities β€” no feature business logic.

Key files

Task File(s)
Add a feature lib/features/<name>/ with data/, domain/, presentation/
Change API lib/features/*/data/repositories/<name>_repository_impl.dart + lib/services/network/
Local persistence lib/core/database/ (Drift) + cache in the data layer
Auth flow lib/features/authentication/ + lib/routes/app_router.dart (guard)
CI .github/workflows/main.yml
Env config lib/main/main_<env>.dart + --dart-define
Generate code dart run build_runner build --delete-conflicting-outputs
Scaffold a feature dart run tool/new_feature.dart <name>