How zanz9/flutter_architecture works
Project type and purpose
• This is a mobile application built with Flutter, structured according to Clean Architecture principles.
• The core objective is to deliver a scalable, maintainable codebase with clear separation of concerns across presentation, domain, and data layers.
File structure
• Top-level:
• android/ and ios/ folders for native build configurations
• lib/ with main.dart and src/ for all Dart code
• assets/ for static resources
• Under lib/src:
• app/ holds application entry, flavor builds, runner
• core/ contains reusable modules: API client, dependency injection, theme, routing, localization, utilities, base classes, models, exceptions, widgets
• features/ holds feature modules; here only auth with data, domain, presentation subdirectories
• Recognize Clean Architecture boundaries: presentation → domain → data, plus a shared core.
README for additional insights
• It confirms three layers: Presentation (BLoC + UI), Domain (use cases, entities, repository interfaces), Data (concrete implementations, remote/local sources).
• Stacks: BLoC, Dio, GetIt/Injectable, GoRouter, Hive, Intl, etc.
Components
a. Main application shell (main.dart → runner)
b. Dependency Injection Container (GetIt/Injectable)
c. Presentation Layer
– UI Widgets, Screens, BLoC/Cubit components
– GoRouter navigation
d. Domain Layer
– Entities, Use Cases, Repository Interfaces
e. Data Layer
– Repository Implementations
– Remote Data Source (Dio HTTP Client, token interceptor)
– Local Data Source (Hive storage service)
f. Core Modules
– API client configuration
– Logging & error handling (Talker, Sentry)
– Localization module
g. External Services
– REST API endpoints
– Local storage (Hive)
– Third-party services (Firebase, geolocation, file picker)
Relationships and interactions
• Startup flow: main.dart → runner → configure DI → launch App widget
• Presentation requests a use case via injected view-controller or BLoC
• Use case calls repository interface
• Repository implementation picks either remote or local source
• Remote source uses Dio client → REST API
• Local source uses Hive → device storage
• Responses propagate back: data layer → domain → presentation → UI
• Navigation events handled by GoRouter
• Services logging errors to Talker/Sentry
Architectural patterns and design principles
• Clean Architecture (layered hexagon) – dependency rule inward
• BLoC for state management in presentation
• Repository pattern for data access
• Dependency Injection for decoupling components
• Code generation (Freezed, JSON Serializable, Injectable)
• Flavor builds for environment configuration