Project 4 - Distributed Systems
Project Objective:
- Implement a native Android application
- Implement a web service deployed to Heroku using Docker that executes all business logic of the Android application.
- Handle error conditions (ie. invalid inputs, network errors, API unavaibility, API invalid responses, etc.)
- Log all traffic through webservice and store data in a noSQL database using MongoDB
- Create HTML webpage dashboard that displays analytics from traffic logs
Diagram of components and interactions:
Tasks:
- Choose a 3rd party API and create simple Java application that can make a request & receive a JSON response.
- Create a MongoDB database on Atlas and create a Java application that can:
- Prompt the user for a string
- Write the string to the database
- Read all documents on the database
- Print the strings in each document.
- Create Android application that has the following:
- Three different types of Views in Layout (ie. TextView, EditText, ImageView, etc)
- Takes input from user
- Makes an HTTP request to web service
- Recieves and parses JSON response
- Displays new information to user from response
- Is repeatable (doesn't require restart for another query)
- Create the webservice that has the following:
- Implements an API
- Receives HTTP request from Android application
- Executes all business logic appropriate to the applicaiton. This includes fetching JSON information from API, and processing the response.
- Replies to the Android application with JSON response.
- Deployed to Heroku using Docker.
- Must use Servlets.
- Application and web service should both test for and handle errors in the following:
- Invalid input in the Android application.
- Invalid server-side input (in the case that application input validation did not catch something).
- Mobile app network failure, or inability to reach server.
- Third-party API unavailability.
- Third-party API invalid data or response.
- Implement logging capabilities with the following requirements:
- Tracks at least 6 metrics (ie time of request, time to reply, information requested, etc)
- Stores data in noSQL database using MongoDB.
- Does CRUD ooperations programmatically from a Java program.
- Create a web-based HTML operations dashboard that:
- Has a unique URL address.
- Displays at least three useful and unique operation analytics.
- Displays the formatted usage logs.
Topics/Skills covered:
- Docker
- Cloud-based application / Heroku
- Android mobile applications / Android Studio
- Servlet programming
- Error handling
- HTML web application
- MVC architecture
- HTTP
- RESTful API
- JSON
- noSQL Databases / MongoDB / Atlas
- CRUD operations
Demonstration of completed tasks:
For my project, I created an Android application that allows users to search for TV shows. The application makes calls to the iTunes API based on the user input, which in this case is the TV Show title. A list of results is then generated, providing the user with the title of the show, the artwork for the show, and the title of the episode. The user can then make another search from the results page, making the application repeatable.
Screenshot of main landing page of app:
Heres a user entering a search for “Avatar”:
Heroku implementation: The “search” method in “itunesGet.java” is where the HTTP request is made, with the following URL:
https://pure-shore-63134.herokuapp.com/getTvShows/(searchterm)
(searchterm) is the user input string
The app is still running on Heroku and a search term can manually be entered to see the JSON reply from the iTunes API! The code that is deployed to Heroku can be found in the Project1Task1 folder. I utilized the method shown in Lab 3 to create a WAR file of my Android application's logic and deploy it to Heroku using Docker.
This tells the web application to enact it’s “doGet” method with that search term, and uses it to get a Json Reply from the itunes API with the given search term.
Same result in a JSON viewer:
Response from Heroku web service displayed in Android application:
Information Logging / Analytics Dashboard
Information logged:
- Device type used to access DB
- Browser used to access DB
- Search term
- Number of results
- Date and time DB was accessed
- Entire JsonReply is stored here
Screenshot from MongoDB:
Screenshot of web-based HTML dashboard:
Three analytics presented: last date the DB was accessed, most recent search query, and a list of all search terms. Note that a better implementation of the "list of all search terms" would only display a single instance of each unique search term, rather than showing multiple instances of the same search term.