Android app to search for artists, albums or tracks and get a list of related songs using the iTunes Searcher API.

Overview

iTunes Searcher

Android app to search for artists, albums or tracks and get a list of related songs using the iTunes Searcher API. Each song may be clicked for further details.

screen_recording.mp4

Technical Design

The high level app architecture looks like this. It's inspired by Uncle Bob's Clean Architecture + MVVM, although not totally by the book. Each layer is an separate module on the project so the app can grow easily while keeping separation of concerns, reusability and quality of code. The domain is the inner module and accessed by app and data modules. The app module works as the presentation layer and sees the domain and data modules. The app module is the application entrypoint and set the Dependency Injection.

App Architecture

Check this link to see the full design.

Domain Module

Domain Module

The domain module is a pure kotlin module with the abstractation of business logic. It has no Android-related dependency. It's the inner module in clean architecture and is seen by app and data modules, but does see them.

  • UseCases: makes the necessary calls from the repositories and get it ready to the UI. GetResultsUseCase calls the necessary method from the ItunesSearcherRepository and may add aditional logic.
  • Entities: basically the app models. The domain Entity is read to be used at the app/presentation layer, but it's mapped from the network entity in data module first
  • Repositories: interface to get the data from the data module. ItunesSearcherRepository does the job.
  • CustomResponse: API responses wrapper (Success or Failure)
  • Extensions: takes advantaged from Kotlin extensions features to write custom functions to existing classes. At domain we have useful extensions for String and Double to be used app-wide, supporting the business logic.

Data Module

Data Module

The data module is responsible for all data sources that the app relies on, that could be either local or remote. For now the first and only data source is the iTunes Searcher API.

  • ITunesSearcherRepositoryImpl: the data module makes the actual implementation of the Repository interface. From there the API services are called.
  • ItunesSearcherService: service with the contract to fetch data from the API.
  • Responses: network entities to map the JSON objects from the API using Moshi. It comes raw from the API, just with few property name changes.
  • Mappers: functions to map a network entity to a domain entity (that's better suited to be used in the app)
  • NetworkModule: define the Dependency Injection for network and repository calls.

App Module

App Module

The app module is the starting point to the app and works as the presentation layer to handle all UI logic and design. To do so, a MVVM approach is used. The app module also takes care of the Dependency Injection for all layers through the MainApplication class. It takes advantage from modern Android Jetpack libraries, Kotlin features and SOLID concepts to deliver clean and efficient code.

Each feature may have several packages under it, with activity, viewmodel. fragments, adapters, listeners and so on.

  • Activities: each Activity is an app screen to interact with the user and runs along with the app lifecycle. DataBinding is used to populate views with data from ViewModel with reactive programming + MutableStateFlow. The Activity is a dumb view with its state controlled by ViewModel. MainActivity is the only Activity so far, but it could easily grow. It relies on data binding and reactive programming with MutableStateFlow to listen to ViewModel properties.
  • Fragments: each Fragment is an encapsulated component attached to an Activity, a smaller part of the view. Also uses DataBinding to observe data from ViewModel. Now we have TrackDetailsBottomSheetFragment to show the details of a clicked song.
  • ViewModel: a ViewModel class is responsible for all the view logic and data, handling and managing all UI-related data. The ViewModel is aware of the view's lifecycle. It calls the UseCases from domain layer and handle all the data flow to be observed by the views with the help of Coroutines. MainViewModel is the main only viewmodel so far and calls GetResultsUseCase. It has a holder class MainViewModelState with MutableStateFlow properties.
  • Adapters: implementation of RecyclerView.Adapter and manages all the logic to deal with RecyclerView lists. It has rules to bind each element of an array (with DataBinding) at every position. There's an adittional ViewHolder class for each adapter with rules to bind an individual item.
  • MainApplication: the start of everything. Deals with app-wide state and injects the dependency with Koin from AppModule and NetworkModule
  • Base classes: abstract classes to be reused by activities and viewmodels (additional base classes may be implemented later)
  • Extensions: takes advantaged from Kotlin extensions features to write custom functions to existing classes. At app module we have extensions that are meant for presentation layer.
  • Components: data classes to set everything up for UI components. So far we have RecyclerComponent to create RecyclerView with a given adapter and other configurations.

Tests

Some unit tests were written to check some functionalities, like mappers (network entity to domain entity) and extension functions. Additional tests will be implemented to cover ViewModel, Repository and UseCase.

Tests

Stack

Next steps

  • Create reusable themes and styles for the app layouts

  • Make the app looks better improving UI/UX

  • Create a embedded player to play the 30-second song from previewUrl property

  • Map API errors

  • Enhance unit tests coverage

๐Ÿ“ƒ License

MIT License

Copyright (c) 2022 Miguel Freitas

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
You might also like...
๐Ÿ’™ Android sample Avengers chat application using Stream Chat SDK based on MVVM (ViewModel, Coroutines, Room, Hilt, Repository) architecture.
๐Ÿ’™ Android sample Avengers chat application using Stream Chat SDK based on MVVM (ViewModel, Coroutines, Room, Hilt, Repository) architecture.

Avengers Chat AvengersChat is a demo application based on modern Android tech stacks and Stream Chat SDK. Previews Download Go to the Releases to down

A simple real-time chatting application using android

In this project we have created a simple real-time chatting application using android. In this project we can chat with a registered user in the app. We can also set profile photo, about, name. After chatting with registered user we can also logout from the app and we can login, whenever we want .

Open Source Messenger App For Android - Real-time Messaging, Voice and Video Calls

Open Source Messenger App For Android - Real-time Messaging, Voice and Video Calls

NotiNotes - A simple Notes app for Android which only lives in your QS and notification panel
NotiNotes - A simple Notes app for Android which only lives in your QS and notification panel

NotiNotes The Notes app for your notification panel. A simple Notes app for Andr

Qiscus provide everything you need to power up your app with chats. And it's now made simple.
Qiscus provide everything you need to power up your app with chats. And it's now made simple.

Introduction Qiscus Chat SDK (Software Development Kit) is a product provided by Qiscus that enables you to embed an in-app chat/chat feature in your

An instant messaging and audio-video calling app
An instant messaging and audio-video calling app

Babble Babble is a chatting and calling application for anyone with an Android phone and an Internet connection. Just sign up using your phone number

Quick Text is about send the message on WhatsApp without saving number. You can see the status of other and share and download those status also.
Quick Text is about send the message on WhatsApp without saving number. You can see the status of other and share and download those status also.

Quick Text is about send the message on WhatsApp without saving number. You can see the status of other and share and download those status also.

Sample Android App for WebRTC with Firebase as backend
Sample Android App for WebRTC with Firebase as backend

Simple Demo App for Android WebRTC video call using Firebase Realtime Database as Signalling server.

A private-chat-only Android App for Secure Scuttlebutt
A private-chat-only Android App for Secure Scuttlebutt

Tremola README Tremola is a Secure Scuttlebutt (SSB) client for Android that only supports private chat. Tremola aims at having the same functionality

Owner
Miguel Freitas
I'm a mobile software engineer passionate about applying technology to build great products for users. 7 years of experience. Focused on Android/Kotlin.
Miguel Freitas
Messaging API: Connect to PostgreSQL and Kafka to obtain and manage cars inventory

Messaging-API In this simple API, we connect to PostgreSQL and Kafka to obtain a

Kevork 0 Feb 18, 2022
A simple video calling application uses Firebase database and WebRTC API that enables you Peer-to-Peer Full-HD video and audio connection.

A simple video calling application uses Firebase database and WebRTC API that enables you Peer-to-Peer Full-HD video and audio connection.

Indrajit Sahu 10 Sep 27, 2022
Android Combined Application for chat, audio/video calls, and broadcast to millions of web and app users using VdoTok SDK.

Android Combined Application for chat, audio/video calls, and broadcast to millions of web and app users using VdoTok SDK.

VdoTok 3 Nov 22, 2022
SayHi! is an instant messaging app that allows users to send text messages to other people using the app

SayHi SayHi! is an instant messaging app that allows users to send text messages to other people using the app ?? Screen Shots ?? Features OTP Verific

Prince Fahad 0 Dec 25, 2021
This app includes Implementation of Huawei and Google Kits in a single codebase using Build Variants. ๐Ÿ—บ ๐Ÿ“ฉ

Build Variant App ?? ?? ?? Build variant is a feature of Android Studio to create a project which can be build in different versions. By using Build V

Halil ร–zel 13 May 26, 2022
Chat App is built to demonstrate a simple end-to-end chat encryption using RSA and AES algorithms

End-to-End Encrypted Chat ?? Chat App is built to demonstrate a simple end-to-end chat encryption using RSA and AES algorithms Built With โš’๏ธ Jetpack C

Team Matrix 6 Dec 23, 2022
A mirai chatbot plugin based on OpenAI GPT-3 API

Mirai OpenAI GPT-3 ChatBot Plugin This is a Mirai ChatBot plugin based on OpenAI GPT-3 API. Installation Download the JAR file from https://github.com

std::_Rb_tree 33 Jan 31, 2023
Firebase-Chat-App-Final - An android real-time chat application implemented using firebase

Firebase-Chat-App-Final An android real-time chat application implemented using

Tanmay Nandanikar 4 Sep 10, 2022
A chat app for Android written in Kotlin using MVVM.

Chat App Android About A chat app for Android written in Kotlin using MVVM. Features Authentication: Email and password Google Auth Reset Password Sen

Sreshtha Mehrotra 14 Jul 3, 2022
A chat app for Android written in Kotlin using MVVM.

Chat App Android About A chat app for Android written in Kotlin using MVVM. Features Authentication: Email and password Google Auth Reset Password Sen

Sreshtha Mehrotra 14 Jul 3, 2022