Skill v1.0.0
currentLLM-judged scan90/100version: "1.0.0" name: app-architecture-scaffold description: Lay down a feature-first, layered Flutter folder structure (presentation/domain/data) with get_it+injectable DI, auto_route wiring, abstract-interface repositories/datasources, domain error enums, and fpdart TaskEither at the usecase layer. Use this whenever setting up the architecture/folder structure of a Flutter app, organizing lib/ into layers or features, applying Clean Architecture, or right after flutter create and before adding Firebase services — so every feature and service lands in a consistent place. Triggers on "structure my Flutter project", "set up clean architecture", "how should I organize this app".
App Architecture Scaffold
Directory skeleton + conventions rest of series writes into. Feature-first outside, layered inside.
When to use
- Right after
flutter create. - Refactoring flat
lib/into layers.
Target structure
lib/main.dartapp.dart # MaterialApp.router + themecore/di/ # dependency injection setuperror/ # domain error enumsrouter/ # auto_route config (app_router.dart, generated)config/ # env / flavor config (flavors-env-setup fills this)features/<feature>/data/ # datasources, dtos, repository implsdomain/ # entities, error enums, repo interfaces, usecasespresentation/ # widgets, pages (@RoutePage), blocsshared/widgets/ # reusable UIextensions/
Steps
- Make tree:
``bash mkdir -p lib/core/{di,error,router,config} lib/shared/{widgets,extensions} mkdir -p lib/features/auth/{data,domain,presentation} ``
- Core primitives (see
examples/):
features/<f>/domain/*_error.dart— domain errorenum(e.g.enum AuthError { wrongPassword, network, unknown }).core/di/injector.dart— DI (get_it+injectable).
- Wire
app.dart→core/router/app_router.dart(auto_route). Presentation state =bloc/flutter_bloc. - Contracts =
abstract interface class. Repo interface indomain, impl indata; datasource interface + impl indata.
Rules
- One feature = one
features/folder. - Domain errors = enums. No message strings in domain — enum cases only.
- Repos + datasources: no fpdart. Plain
Future<T>; throw on failure. TaskEither<ErrorEnum, T>only at usecase layer — usecase wraps repo call, maps throws →Left(ErrorEnum.case).- Presentation translates the error enum → user text via localization (
AppLocalizations). No hardcoded error strings in UI. e.g.switch (err) { AuthError.wrongPassword => l10n.errWrongPassword, ... }. - Interfaces:
abstract interface class(repos, datasources).
Examples
Full auth vertical slice in examples/feature_auth/ — copy the shape per feature:
domain/auth_error.dart— domain error enum (no strings).domain/app_user.dart— framework-free entity.domain/auth_repository.dart—abstract interface class, plainFuture, throws.domain/sign_in_usecase.dart— the only fpdart layer;TaskEither<AuthError, AppUser>.data/firebase_auth_repository.dart— impl; Firebase types stay here, maps SDK → enum.presentation/auth_error_l10n.dart— enum → localized text (only place error strings live).
Related
- Prereq:
flutter createdone - Next: flavors-env-setup, firebase-emulators-setup
- Overlaps:
flutter-apply-architecture-best-practices,reactive-repository-generator - Localization (error translation):
flutter-setup-localization