How klerith/flutter-teslo-app works
Main Components
• Frontend Flutter Application: This is the core of the project. It is structured primarily within the lib directory. Its main features include:
• Auth (authentication): Contains domain, infrastructure, and presentation layers for authentication.
• Products: Displays and manages product data.
• Shared: Common widgets and infrastructure shared across features.
• Configuration: Contains environment settings (.env), routing (app_router.dart), themes, and constants.
• Platform-Specific Folders: Directories such as android, ios, linux, macos, web, and windows indicate that the app is intended to run on multiple platforms.
• External Backend: As described in the README, the backend is obtained from the provided NestJS repository (Teslo Backend) and handles CRUD operations, token handling, and additional REST API endpoints.
• Assets and Resources: Assets (images, loaders, fonts) are used by the frontend for UI rendering.
Architectural Layers and Relationships
• Presentation Layer:
• Screens and Widgets for each feature such as login_screen.dart, register_screen.dart, and products_screen.dart.
• Providers (e.g., auth_provider.dart, login_form_provider.dart) that manage state via Riverpod.
• The UI Layer interacts with the domain logic through these providers.
• Domain Layer:
• Contains entities (e.g., user.dart) and repository interfaces (auth_repository.dart) that define the core business logic and data models.
• Infrastructure Layer:
• Implements the domain interfaces by connecting to data sources (e.g., auth_datasource_impl.dart) and handling API interactions.
• Contains error handling (auth_errors.dart) and mappers (user_mapper.dart) to convert data between API responses and domain objects.
• Configuration and Routing:
• app_router.dart’s configuration (using GoRouter) handles navigation between various screens.
• Environment configuration via the .env file (to be created from .env.template) allows dynamic configuration for different environments (e.g., Android emulator IP setup).
• External Integration:
• The Flutter app connects to the external Teslo Backend for authenticated CRUD operations.
Architectural Patterns and Principles
• The project follows a feature-based modular architecture with a separation of concerns among presentation, domain, and infrastructure.
• It leverages clean architecture concepts by splitting business logic (domain) from implementation details (infrastructure).
• The state management is handled by Riverpod, and navigation is centrally managed by GoRouter.
• Use repository patterns to abstract the details of data fetching and API communication.