Standards for organizing code by feature at the root level to improve scalability and maintainability.
Standard for modular Clean Architecture organized by business features in lib/src/features/.
lib/
└── src/
├── core/ # Shared infrastructure & utilities
├── shared/ # Common UI components & shared entities
└── features/
└── <feature_name>/
├── domain/ # Business Logic (Pure Dart): entities, interfaces, use_cases
├── data/ # Implementation: data_sources, dtos, repositories
└── presentation/ # UI & State: blocs, pages, widgets
Presentation -> Domain <- Data. Domain must have zero external dependencies.lib/src/features/ flat; avoid nested features.lib/src/shared/ or lib/src/core/.Any visually meaningful UI block must be extracted into presentation/components/.
lib/src/features/<feature_name>/presentation/
├── pages/
│ └── <feature>_page.dart
├── components/
│ ├── <feature>_header.dart
│ ├── <feature>_search_bar.dart
│ ├── <feature>_card.dart
│ └── ...
└── models/ (optional; presentation-only models)
└── ...
Page (only orchestrates layout, scroll, state):
class ActivityLogsPage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
children: [
const ActivityLogsHeader(),
const ActivityLogsSearchBar(),
Expanded(child: ActivityLogsList(entries: entries)),
],
);
}
}
Components (each UI block lives in its own file):
components/activity_logs_header.dartcomponents/activity_logs_search_bar.dartcomponents/activity_log_card.dartcomponents/activity_logs_list.dartBreak into:
components/login_header.dart (logo + title)components/login_form.dart (email/password fields + CTA)components/login_footer.dart (forgot password / terms links)For feature folder blueprints and cross-layer dependency templates: See references/REFERENCE.md.
layer-based-clean-architecture | retrofit-networking | go-router-navigation | bloc-state-management | dependency-injection