Code Monkey home page Code Monkey logo

glovo-android-challenge's Introduction

Glovo Android Challenge

This app solves the Glovo Android Challenge.

Getting Started

  • Setup and run the server
  • Checkout this project and edit the server url address in the following line of the app module's build.gradle file: buildConfigField "String", "SERVER_BASE_URL", "\"http://10.0.2.2:3000/\""
  • Run the app

Project Structure

This project was organized using the principles of the app modularization by features. Although this approach is not necessary for an app as small as this challenge, it is useful to demonstrate how to structure a project that aims to build a robust and scalable application. This is a very common and good practice to keep different teams working on isolated and decoupled features. This application was divided in two "product features":

  • User City: This feature is the responsible for getting the code of the city where the user is located, using two strategies: the current user device location, and the available city picker screen which is displayed to the user when the application starts and cannot be able to fetch the device location.
  • Working Area: The main screen of the app, which loads the map of available zones and the details of the city focused on the map.

In addition to these modules, the project contains the following additional ones:

  • app: This is the main application module which contains the application class and the navigation logic. The NavigationActivity is the responsible for driving the user through the flow composed by all the product features, and for loading the different features activities.
  • base: This is a base module which contains architecture base classes and helpers, which are used by the different product modules.
  • networkdatasource: This module contains the network communication logic between each product modules and the server, bringing a common data source class with api call capabilities.

Architecture

In order to maintain this code decoupled, testable and robust, the architecture of this app was designed using clean architecture. Each Product Feature contains the following layers represented as packages in the src module folder:

  • Domain Layer: Contains the business logic of each module, totally independent of the device, the networking data or the ui. Each business logic task is represented as an Use Case.
  • Data Layer: Represented by Repositories which have the responsibility to access and get data from the different sources (Device, Cache and Networking).
  • Presentation Layer: Layer responsible for displaying the information provided by the business logic layer, using the UI interface. This layer use the Google's architecture components approach to manipulate data between the activities/fragment and the presentation classes (represented by ViewModels).

The communication and transformation of data between different layers was represented by Mapper classes. Each user flow which implements these three layers was developed using async, event-based and reactive programming with RxJava.

Dependency Injection

All the app component dependencies are injected using Koin, which provides a lightweight and pure Kotlin dependency injection mechanism with glorious support for Android architecture classes such as ViewModels. Each module has an extra package called module who contains the injections of all the dependencies used by this module.

Unit Testing

Each module contains a set of unit test classes that intends to test every component of the architecture. These test classes were designed to check the output of the class being tested, using Mockito as a mocking mechanism of their inputs and dependencies.

Polygons Representation

As specified in the challenge statement, this app represents the available zones of the Glovo service using polygons displayed in the main Google Map screen. In order to avoid overlapped polygons when each city is represented, and also to avoid overlapped polygons between cities (such as Rio de Janeiro Center and North Rio de Janeiro), a polygon combination algorithm was developed using the JTS library. A unit test class with a valid example of this combination can be found here.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.