How civil31dot5/fitness-diary works
Project Type and Purpose
• The README confirms that the app helps users review their dietary intake, track exercise routines (by interfacing with Strava), and monitor changes in body statistics with photo records.
File Structure
• The project is organized into multiple Gradle modules: “app” (main Android application module), “common” (possibly shared utilities or functionality), “data” (handling database access, network calls, and repository implementations), “domain” (contains business models, use cases, repository interfaces, and domain logic), and “testing” (module for unit and instrumentation tests).
• The “app” module holds the UI components; you see extensive use of Jetpack Compose with navigation, view models (MVVM pattern), dependency injection (Hilt set up in di packages), and other typical Android resources.
• The “data” module includes implementation details such as Room database setup, network models using ktor and serialization, data mappers, and background workers for tasks like backup and syncing Strava data.
• The “domain” layer houses the core business logic with use cases (e.g., GetMonthRecordStatusUseCase, BackupDataUseCase, ConnectStravaUseCase), domain models, and repository interfaces ensuring a clean separation between presentation and data logic.
• Additionally, there is a “common” module for shared functionalities and a “testing” module dedicated to tests across the system.
a. Main Components:
• UI Layer: Presented in the “app” module. It includes components like MainActivity, various Jetpack Compose screens (HomeScreen, BackupRestoreDataScreen, AddRecordScreen, etc.), and corresponding ViewModels which follow MVVM.
• Domain Layer: Found in the “domain” module, containing business models, repository interfaces, and use cases for handling core business logic (diet, sport, bodyshape, backup/restore, report generation).
• Data Layer: Located in the “data” module. This module provides data handling through database entities (with Room), network services for Strava integration, repository implementations (RecordRepositoryImpl, StravaRepositoryImpl, BackupRestoreDataRepositoryImpl), data mappers, and background workers.
• Common Module: Likely contains utilities and shared components used by multiple modules across the application.
• External Services: Integration with Strava for fetching exercise records. The network layer handles OAuth and JSON parsing.
• Dependency Injection: Implemented through Hilt as seen in various “di” packages, ensuring dependencies are managed across the UI, domain, and data layers.
b. Relationships and Interactions:
• The UI layer (app) interacts with the Domain layer via ViewModels that call use cases.
• The Domain layer communicates with the Data layer through repository interfaces to abstract data source details.
• The Data layer retrieves data from local databases (via Room) and external APIs (via ktor for Strava), then maps it to domain models.
• DI (using Hilt) ties these components together, ensuring that ViewModels, use cases, and repository implementations are properly injected.
• Background workers in the Data layer handle data synchronization tasks and notifications.
c. Architectural Patterns & Design Principles:
• MVVM Architecture: Clearly separated UI (View & ViewModel) and business logic (use cases in the domain layer).
• Clean Architecture: Separation between presentation, domain, and data layers.
• Dependency Injection (Hilt) is used to manage component dependencies.
• Modular architecture is evident from the separation into app, data, domain, common, and testing modules.
d. Relevant Technologies, Frameworks, and Libraries:
• Jetpack Compose for the UI.
• Kotlin with Coroutines and Flow for asynchronous programming.
• Hilt for dependency injection.
• Room for local data persistence.
• ktor & Serialization for network operations.
• Timber for logging.
• MPAndroidChart and Coil for charting and image loading.
• Various testing tools and frameworks as supported by the “testing” module.