CocoLi7777 / aq-test

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

REAL-TIME AQI BOARD APP

Content

Introduction

This project is to build an AQI information display board and provide the function of searching AQI information all around the world.

The tasks are:

  1. Consume an API from the community and retrieve the AQI data for local and cities being searched.
  2. Get the nearest station close to the user location, based on the IP adress information. Display the local monitoring station, measurement time infomration, real-time AQI and webpage associated to the the monitoring station.
  3. Get the real-time AQI for the searched station, diplay the name of the city, time and AQI.
  4. Diplay all names and AQI of monitoring stations associated to the the searched city.

Live Demo

This application is deployed to Heroku, here is the link

Details:

Highlights

  • Consume 3 API for retrieving data for city feed, gelocalized feed(ip based) and all stations.
  • Getting data from third-party API service and updating application automatically.
  • Using React to create reusable components.
  • Responsive UI using Material-UI, mobile friendly.
  • Spinner solution used when data loading.
  • Alert solution used when improper searching.
  • Setup Continuous Deployment using Github and Heroku, having continuously improvement to the application.
  • Using cors-anywhere solution to enable cross-origin requests.

Running unit test

  1. run npm run dev first and keep the program running

  2. npm run test to lauch the test

  3. Using Jest to have unit testing for aqi service Test Image 1

Running end-to-end test

  1. run npm run dev first and keep the program running

  2. npm run test-e2e to lauch the test

Test Demo

New Improvement...

  • Issue: I got CORS (Cross-Origin Resource Sharing) “issues” when I deployed the application on Heroku.
  • First solution: I used cors-anywhere service(https://cors-anywhere.herokuapp.com/) but found there is limited visit and the response speed is very slow.
  • Improved solution: I improved it creating back-end proxy service to avoid CORS issues.

Prerequisites

NPM - Install NPM for all dependencies.

Quick Start

Install dependencies: npm install

Running locally

Run the client & server with concurrently:

npm run dev

Run the Express server only:

npm run server

Run the React client only:

npm run client

Server runs on http://localhost:5000 and client on http://localhost:3000

One highlight when running locally

Go to config.js and uncomment the second API_URL and comment the first API_URL. It can get local AQI information.

About


Languages

Language:JavaScript 94.4%Language:HTML 4.9%Language:CSS 0.7%