2.5 KiB
2.5 KiB
Directory Structure
How frontend (Flutter) code is organized in this repository.
Practical Conventions
apps/lib/main.dartis the single root entry file.- Keep second-level folders fixed to:
app/,core/,data/,features/,shared/,l10n/. - Put feature business code under
features/<feature>/...; keep cross-feature infra/protocol incore/and shared infra indata/. - Shared reusable UI belongs to
shared/widgets/**, not duplicated under each feature.
Real File Path Examples
- App bootstrap and routing composition:
apps/lib/main.dartapps/lib/app/app.dartapps/lib/app/router/app_router.dart
- Shared infrastructure (non-feature business):
apps/lib/data/network/api_client.dartapps/lib/data/cache/cache_store.dartapps/lib/core/theme/app_theme.dart
- Feature-bounded implementation:
apps/lib/features/todo/data/apis/todo_api.dartapps/lib/features/todo/data/repositories/todo_repository.dartapps/lib/features/auth/presentation/bloc/auth_bloc.dart
Placement Checklist (before adding a file)
- Does this logic belong to exactly one feature flow?
- Yes ->
features/<feature>/...
- Yes ->
- Is it cross-feature protocol/orchestration (auth/session/notification/ui schema)?
- Yes ->
core/**
- Yes ->
- Is it shared storage/network/cache infra?
- Yes ->
data/**
- Yes ->
- Is it reusable widget/presentation helper with no feature business orchestration?
- Yes ->
shared/widgets/**(orshared/forms/**)
- Yes ->
Anti-patterns (with evidence)
- Creating feature business repositories/models under shared
apps/lib/data/**.- Existing correct pattern is feature-local repositories under
apps/lib/features/**/data/repositories/.
- Existing correct pattern is feature-local repositories under
- Letting UI code bypass repositories for consistency-sensitive data flow.
- Correct references:
apps/lib/features/todo/data/repositories/todo_repository.dart,apps/lib/features/messages/data/repositories/inbox_repository.dart.
- Correct references:
- Deep redundant nesting without clear ownership.
- Current tree generally keeps flat-by-concern organization (e.g.,
data/apis,data/repositories,presentation/screens,presentation/widgets).
- Current tree generally keeps flat-by-concern organization (e.g.,
Uncertainties / Gaps
- Some modules blend domain-specific and infrastructure concerns (for example, notification rewrite boundaries) and rely on AGENTS rules rather than strict automated folder enforcement.
- No script currently validates folder placement rules automatically; enforcement is mostly review + convention.