ACCESSING DATABANKS...
INITIALIZING SYSTEM...
[000%]
SYSTEM_SECURE // FPGD
ACCESSING DATABANKS...
This project has been refactored to follow Clean Architecture principles and implement the BLoC pattern for state management. The refactoring aims to improve code organization, testability, and maintainability.
The application is organized into layers following the Clean Architecture principles:
lib/
├── core/ # Core functionality used across the app
│ ├── di/ # Dependency injection
│ ├── error/ # Failures and exceptions
│ ├── network/ # Network client
│ └── usecases/ # Base usecase classes
│
├── features/ # Features are organized into modules
│ ├── auth/ # Authentication feature
│ │ ├── data/ # Data layer
│ │ │ ├── datasources/ # Data sources (remote, local)
│ │ │ ├── models/ # Data models
│ │ │ └── repositories/ # Repository implementations
│ │ ├── domain/ # Domain layer
│ │ │ ├── entities/ # Domain entities
│ │ │ ├── repositories/ # Repository interfaces
│ │ │ └── usecases/ # Business logic use cases
│ │ └── presentation/ # Presentation layer
│ │ ├── bloc/ # BLoC state management
│ │ ├── pages/ # UI screens
│ │ └── widgets/ # Reusable UI components
│ │
│ ├── user/ # User profile feature
│ │ ├── data/
│ │ ├── domain/
│ │ └── presentation/
│ │
│ ├── exercises/ # Exercises feature
│ │ ├── data/
│ │ ├── domain/
│ │ └── presentation/
Pure Dart classes representing the core business objects. They are independent of any framework or implementation details.
Represent a single business operation or action. Each use case has a single responsibility and is implemented as a class with a call method.
Interfaces defining the contract for data operations. Implementations handle the actual data retrieval and storage.
Manages the state of the application by handling events and emitting states.
The project uses GetIt for dependency injection. The injection_container.dart file registers all dependencies:
// Register BLoC
sl.registerFactory(() => AuthBloc(...));
// Register Use Cases
sl.registerLazySingleton(() => LoginUseCase(sl()));
// Register Repository
sl.registerLazySingleton<AuthRepository>(() => AuthRepositoryImpl(...));
// Register Data Sources
sl.registerLazySingleton<AuthRemoteDataSource>(() => AuthRemoteDataSourceImpl(...));
Errors are handled using a combination of Exceptions and Failures:
The ApiClient class handles all network operations, providing methods for HTTP requests with proper error handling and authentication.
To maintain compatibility with existing code, the ApiService class has been maintained but refactored to use the new clean architecture components internally. This allows for a gradual transition without breaking existing functionality.
Continue refactoring other features to follow the Clean Architecture pattern, moving functionality from the old services to proper feature modules with appropriate layers.