This repository contains a SalesSparrow app built using Android that follows MVVM architecture, Coroutines, Hilt, Room, Data Binding, View Binding, Retrofit, and Repository pattern. It also includes a Network service built on top of Retrofit and a push notification setup, along with TDDS (Test-Driven Development Setup).
- Features
- Architecture Overview
- Product Flavors
- Setup Instructions
- Dependencies
- Contributing
- License
- Code of Conduct
- Testing and Quality Assurance
Key features of Sales Sparrow project:
- MVVM architecture
- Coroutines for asynchronous operations
- Hilt for dependency injection
- Room for local database handling
- Data Binding and View Binding for UI setup
- Retrofit for network communication
- Repository pattern for data management
- Network service setup for API calls
- Push notification integration
- Test-Driven Development Setup (TDDS)
The MVVM architecture with Jetpack Compose follows a unidirectional flow of data and communication between different components:
-
View (Activity / Fragment): The View layer represents the user interface, implemented using Jetpack Compose. It observes the ViewModel and displays the data received from it. The View is responsible for capturing user interactions and forwarding them to the ViewModel for processing.
-
ViewModel: The ViewModel acts as a mediator between the View and the domain layer. It exposes LiveData or StateFlow objects for the View to observe. When the View requires data or actions, it communicates with the ViewModel. The ViewModel may call the domain layer to retrieve data or perform business logic.
-
Domain (Use-Cases): The domain layer contains use-cases that define the actions or operations that the application can perform. Each use-case represents a specific functionality of the app. Use-cases are responsible for orchestrating the flow of data between the ViewModel and the data layer.
-
Data (Repository): The data layer abstracts the data sources (local and remote) from the domain layer. It contains a repository that acts as the single source of truth for data. The repository can retrieve data from local data sources (Room database) or remote data sources (API calls with Retrofit).
-
Local Data Source (Room): The local data source is responsible for handling data stored locally in a Room database. It includes data access objects (DAOs) to perform database operations like CRUD (Create, Read, Update, Delete) operations.
-
Remote Data Source (Retrofit): The remote data source handles data communication with the server using Retrofit for making API calls. It defines interfaces for the API endpoints and handles network requests and responses.
The Sales Sparrow project includes different product flavors for staging, development, and production environments. The environment variables can be managed using separate property files for each flavor.
- Staging: staging.properties
- Development: dev.properties
- Production: prod.properties
You can use these properties for adding different environment-based configurations. For example:
sample.properties:
- DEV_API_URL = https://sample-api.com
- DEV_API_LABEL = staging
Provide step-by-step instructions on setting up the Android project in Kotlin:
- Clone the repository:
git clone https://github.com/TrueSparrowSystems/sales-sparrow-android.git
- Open Android Studio and import the project.
- Create the necessary
properties
files for each product flavor (staging.properties, dev.properties, prod.properties) and add the required environment variables. - Build the project and ensure there are no errors.
- Select the desired product flavor in Android Studio to build the corresponding version of the app.
- Retrofit: HTTP client for network communication.
- Coroutines: For managing asynchronous operations.
- Hilt: For dependency injection.
- Room: For local database management.
- Data Binding and View Binding: For setting up the UI.
- Navigation Component: For navigating between different screens.
This project is licensed under the MIT License. See the LICENSE file for details.
Contributions to the project are welcome! If you would like to contribute, please follow the guidelines in the CONTRIBUTING.md file.
This project has a code of conduct that outlines expected behavior for contributors and users. Please read the CODE_OF_CONDUCT.md file before getting involved.
The app includes unit tests and UI tests to ensure the functionality is working as expected. Follow these steps to run the test cases:
- Open the project in Android Studio.
- In the top navigation bar, next to the "Build" option, you will find a dropdown menu.
- Click on the dropdown menu and select the test case you want to run.
- Click on the "Run" button to execute the selected test case.
- To view more detailed test results, check the links provided in the test output.
Happy coding! 🎉