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
- Feature A never imports Feature B internals.
presentationnever importsdio/drift/firebasedirectly.domainnever importsdataorpresentation.- Infrastructure (Dio, Drift, SecureStorage) is injected via Riverpod providers.
shared/holds cross-cutting models and utilities β no feature business logic.
| 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> |