How mohammadfebriyanto/ahuahu_app works
Main System Components
• Mobile Client (Android Application):
• Built with Kotlin and Android Studio.
• Follows the MVVM design pattern: it contains UI components (activities/fragments), a ViewModel layer, and a repository that orchestrates both local (Room database) and remote (Retrofit API calls) data sources.
• Uses Dagger-Hilt for dependency injection.
• UI-related resources (layouts, drawables, fonts) are managed under the Android “res” folder.
• Backend API (Python/Flask Service):
• Implemented in the “api” folder.
• Provides endpoints that the mobile app can call to get sports recommendations based on air quality.
• Integrates a pre-trained Machine Learning model (e.g., best_model.h5) and associated prediction scripts (predict.py, request.py).
• Uses libraries like Tensorflow, Numpy, Pandas, Keras, and Scikit-Learn.
• Containerized using Docker (see Dockerfile and docker-compose.yml).
• Data & Model Assets:
• The “model” directory contains dataset files and classification scripts.
• This component is used during the training phase or potentially for updating the API’s model.
Relationships and Data Flow
• User Interaction: The user opens the mobile app and interacts with the UI (e.g., tapping the “Get Location” button).
• Mobile App Data Flow:
• The UI layer communicates with the ViewModel.
• The ViewModel calls the Repository, which routes requests to:
▸ The Room database (for local history or caching).
▸ Retrofit API service to send location data to the backend.
• Backend API Processing:
• The Flask API receives location requests.
• It invokes the ML prediction process (using Tensorflow models) to determine if the current air quality makes for an optimal day for outdoor sports.
• Response Flow:
• The API sends back the recommendation result to the Android client via a JSON response.
• The mobile app then updates the UI accordingly.
Architectural Patterns and Design Principles
• MVVM Architecture on Android supports separation of concerns.
• Dependency Injection with Dagger-Hilt simplifies component wiring.
• The Repository pattern abstracts data sources (local vs. remote).
• Microservice/cloud containerization for the API enhances scalability and portability.
• Usage of Retrofit for networking abstracts connection details.
• Docker enables efficient deployment of the Flask service.