<< All versions

Skill v1.0.0

currentLLM-judged scan90/100
fluttermtl/scaffolding-skills/app-architecture-scaffold
──Details
PublishedOctober 24, 2026 at 12:26 AM
Content Hashsha256:6a428038e80b4a31...
Git SHA7841964db5ce
──Files
Files (1 file, 3.6 KB)
SKILL.md3.6 KBactive
SKILL.md · 76 lines · 3.6 KB

version: "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.dart
app.dart # MaterialApp.router + theme
core/
di/ # dependency injection setup
error/ # domain error enums
router/ # auto_route config (app_router.dart, generated)
config/ # env / flavor config (flavors-env-setup fills this)
features/
<feature>/
data/ # datasources, dtos, repository impls
domain/ # entities, error enums, repo interfaces, usecases
presentation/ # widgets, pages (@RoutePage), blocs
shared/
widgets/ # reusable UI
extensions/

Steps

  1. Make tree:

``bash mkdir -p lib/core/{di,error,router,config} lib/shared/{widgets,extensions} mkdir -p lib/features/auth/{data,domain,presentation} ``

  1. Core primitives (see examples/):
  • features/<f>/domain/*_error.dart — domain error enum (e.g. enum AuthError { wrongPassword, network, unknown }).
  • core/di/injector.dart — DI (get_it + injectable).
  1. Wire app.dart → core/router/app_router.dart (auto_route). Presentation state = bloc/flutter_bloc.
  2. Contracts = abstract interface class. Repo interface in domain, impl in data; datasource interface + impl in data.

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, plain Future, 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 create done
  • Next: flavors-env-setup, firebase-emulators-setup
  • Overlaps: flutter-apply-architecture-best-practices, reactive-repository-generator
  • Localization (error translation): flutter-setup-localization
All versions