Slingshot, for Android is a boilerplate project designed to accelerate the development of Android applications. With an emphasis on scalability and maintainability, this project provides a ready-made structure based on the MVVM architecture pattern and comes pre-configured with essential tools.
This repository is perfect for developers who want to quickly set up an Android app while following best practices and architecture patterns, enabling you to focus on writing the features and logic that matter.
- Android Studio
- JDK 11 or higher
- Gradle (usually bundled with Android Studio)
-
Create a new repo, of your liking.
-
Sync the gradle - and SLINGSHOT your app into the ethos! πππ, (I mean run the application xD)
This template includes several optional configurations for your app (like Room Database, Retrofit Network setup, RecyclerView, and Glide).
You can easily choose what to include or exclude using a bash script during the setup. Here's how: The script will prompt you to select which setups you want to include in your app (Room Database, Retrofit, RecyclerView, Glide, etc.).
- Run
make setup
, in the terminal.
If you want to stick with the default setup, simply choose y when prompted, and the script will proceed without any changes.
If you choose n for any feature, the corresponding dependencies and folders will be removed from your project.
This setup will allow you to quickly customize the project to suit your needs.
- MVVM Architecture: Easily scale and manage your app's complexity.
- Retrofit: Simple, type-safe HTTP client for making network requests.
- Room Database: Local storage implementation that allows seamless data persistence.
- Glide: Efficient image loading and caching.
-
ViewModel + Base ViewModel The ViewModel handles UI-related data and persists it during configuration changes. The BaseViewModel class includes common functionality like error handling and loading state management, which can be shared across all ViewModels. The child ViewModel extends BaseViewModel to focus on business logic.
-
Retrofit + Network Layer Retrofit handles all HTTP requests, and the network layer is abstracted with the help of a repository. This makes it easy to switch data sources or handle responses consistently across the app. The RetrofitClient provides the instance of Retrofit and ensures a single point of configuration for API calls.
-
Room Database Room is used for local persistence. The repository layer abstracts all interactions with Room, making it simple to fetch, insert, or update data from the local database. It provides a clear separation of concerns, where data access is decoupled from business logic.
-
Glide for Image Loading Glide is integrated for smooth and efficient image loading. We provide a utility method for consistent image handling across the app, including caching and placeholder management.
-
Factory Pattern for ViewModels A custom ViewModelFactory is provided to inject dependencies into the ViewModel. This allows for a clean and testable architecture, especially when the ViewModel requires dependencies like repositories or other services.
- Fork the repository.
- Create your feature branch (
git checkout -b feature/YourFeature
). - Commit your changes (
git commit -m 'Add new feature'
). - Push to the branch (
git push origin feature/YourFeature
). - Open a pull request.
Please follow the code style and submit tests for new features.
This project is licensed under the MIT License - see the LICENSE file for details.