Skip to content

This project creates a search page using Spotify's API for finding albums, artists, playlists, and tracks. It's built with Kotlin, Coroutine, Flow, Dagger Hilt, Sealed class, Enum, Retrofit, and Room for offline caching support, following a Single Activity Multiple Fragments architecture.

Notifications You must be signed in to change notification settings

Bhupendrapatel98/Spotify-Search-App

Repository files navigation

Spotify Search App

Overview
This project aims to create a search page utilizing Spotify's search API to allow users to search for albums, artists, playlists, and tracks. It utilizes the Single Activity Multiple Fragments architecture, making use of Kotlin, Coroutine, Flow, Dagger Hilt, Sealed class, Enum, Retrofit, and Room for caching to ensure offline support.

Image 1

Video Link -https://github.com/Bhupendrapatel98/Spotify-Search-App/assets/55411086/f1c0eee6-18c0-479e-bb2f-6b504cd98ad1

Project Structure

data: This directory manages data operations.
- api: Houses the ApiService for making network requests.
- model: Contains interceptors for network requests.
- local: Handles local data storage, including converters, DAO interfaces, and database setup.
- model: Stores Plain Old Java Objects (POJOs) used for data modeling.
- repository: Contains repositories responsible for data management, including the search repository, user detail repository, and token repository.
di: This directory handles Dependency Injection using Dagger Hilt.
- AppModule.kt: Defines application-level dependencies such as Retrofit.
ui: This directory holds user interface-related components.
- view: Contains activities and fragments.
- viewmodel: Houses ViewModels responsible for managing UI-related data.
util: This directory contains utility classes and resources.
- constant: Stores constant values used throughout the application.
- networkutil: Contains utilities for network operations.
- Resource: Handles resource management.
- BaseApplication: The Application class responsible for Dagger setup and initialization.

Libraries Used

Kotlin: Primary language for development.
Coroutine: For asynchronous and non-blocking programming.
Flow: For reactive data streams.
Dagger Hilt: For dependency injection.
Retrofit: For making network requests.
Room: For local caching and offline support.
Mockito: For mocking objects in tests.
JUnit: For unit testing.

Architecture

The application follows the Single Activity Multiple Fragments architecture using Navigation Component. Each feature is divided into fragments, making the app modular and scalable.

Caching Strategy

Room Database is used for caching search results. Each time a user performs a search, the results are saved in the database. When offline or open the app, the app displays the last searched results fetched from the database.

Sealed Class and Enum

Sealed class and Enum are utilized for managing different types of search results (albums, artists, playlists, tracks) and their respective details.

Dependency Injection

Dependency Injection is implemented using Dagger Hilt for better modularization, testability, and maintainability of the codebase.

Unit Testing

Mockito and JUnit validate SearchRepository and SearchViewModel functionalities, ensuring reliability.

Conclusion

The project successfully implements a search feature using Spotify's API with offline support and follows best practices in terms of architecture, code quality, and efficiency. Further enhancements and optimizations can be made to make the app more robust and user-friendly.

About

This project creates a search page using Spotify's API for finding albums, artists, playlists, and tracks. It's built with Kotlin, Coroutine, Flow, Dagger Hilt, Sealed class, Enum, Retrofit, and Room for offline caching support, following a Single Activity Multiple Fragments architecture.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages