How dgbjkrist/flutter-clean-arch works
Project Type and Purpose
• This is a Flutter mobile app (“cleanarchi”) with Android and iOS native projects that wrap the Flutter code.
• The project follows clean architecture principles by separating the code into distinct layers (presentation, domain, data) and includes core elements like dependency injection, navigation, and session management.
File Structure
• Top-level directories include “android”, “ios”, and “lib”. The “lib” directory is subdivided into:
• core: Contains common utilities like dependency injection (service locator), navigation (app router), and session management.
• data: Contains data sources (remote API services for auth, transaction, and user), and repositories’ implementations.
• domain: Holds entities, repository interfaces, and use cases. This is the business logic layer of the application.
• presentation: Includes the UI elements (screens) and BLoC/Cubit components for state management.
• Other files like “pubspec.yaml” and “Main.dart” indicate standard Flutter project configurations.
Reading the README
• The README confirms that this is a “starting point for a Flutter application” and gets new users started with Flutter, indicating no further custom external integrations beyond the typical mobile app ecosystem.
a. Identification of Main Components:
• Native Shells: Android and iOS projects which bootstrap the Flutter app.
• Flutter Framework: The overall framework which runs the logic.
• Presentation Layer: Contains screens (UI) and BLoC/Cubit components located under lib/presentation.
• Domain Layer: Consists of entities, repository interfaces, and use cases under lib/domain.
• Data Layer: Includes data sources (API services in lib/data/datasources/remote) and concrete repository implementations under lib/data/repositories.
• Core Utilities: Contains dependency injection (service_locator), navigation (app_router) and session management in lib/core.
b. Relationships and Interactions:
• The Presentation Layer interacts with the Domain Layer by invoking use cases (e.g., login, register, transfer).
• The Domain Layer uses abstract repository interfaces that are fulfilled by implementations in the Data Layer.
• The Data Layer communicates with external APIs via remote data sources.
• The Core layer acts as an underlying structure that all layers depend on for common services like dependency injection and navigation.
• UI events flowing from screens to BLoC/Use Cases.
• Use cases calling repository interfaces.
• Repositories calling remote data sources.
• Dependency injection wiring linking all these components.
c. Architectural Patterns/Design Principles:
• Clean Architecture: Clear separation between presentation, domain, and data layers.
• Dependency Injection: The service locator handles wiring across layers.
• BLoC/Cubit Pattern: Used in the presentation for state management.
• Modularization: Each layer’s responsibilities are isolated, making the code testable and scalable.
d. Key Technologies/Frameworks:
• Flutter framework (Dart language)
• BLoC state management libraries (as evidenced by files like auth_bloc.dart, transfer_bloc.dart)
• Dependency Injection pattern (service_locator.dart)
• Platform-specific integrations for Android and iOS.