How felixqaq/calorie_snap works
Main Components
• User Interface (UI) Layer: Represented by the Flutter frontend code in the “lib” directory (pages, dialogs, widgets). This includes pages such as the login, home, food entry, settings, and detail pages.
• State Management Layer: The “providers” folder (e.g., calorie_provider.dart) handles application state and business logic.
• Services Layer: Under “lib/services” (e.g., auth_service.dart, food_service.dart, storage_service.dart). These components encapsulate different functionalities such as authentication, food data retrieval, and local storage.
• Data Persistence Layer: The “lib/db” folder contains the food_db.dart, which is used for local database operations related to food data and calorie information.
• Domain / Models: The “lib/models” folder which includes detailed classes for food, composite food items, and nutritional information.
• External Systems / ML Model Integration: The system also makes use of the Gemini model for food recognition. This should be depicted as an external service or API that the Food Service interacts with.
Relationships and Interactions
• The UI components interact with state providers which in turn call on the services.
• The services layer interfaces with the local database for persisting food records, and with the external Gemini-based food recognition API for analyzing images.
• The authentication service manages user login and registration flows.
• Components (charts, dialogs, etc.) then display calorie information provided through the provider layer.
• Platform wrappers (Android, iOS, etc.) serve as hosts for the Flutter engine and glue the mobile or desktop OS with your Flutter code.
Architectural Patterns and Design Principles
• Separation of Concerns: The application is split between presentation (pages/widgets), state management/providers, services, and data (models, database).
• Cross-Platform Abstraction: The project’s structure lets Flutter handle most logic universally, while platform-specific directories manage runtime differences.
• Extensibility: Through services and providers, new features such as additional food recognition methods or enhanced analytics can be integrated without affecting the UI directly.