adriantofan / census

react / node / docker test

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

#problem

You will an extract of US census in us-census.db.gz This file is a SQLite base that contains a table "census_learn_sql” with demographic data.

Goal of this exercice is to create a small web application that visualizes database data.

Application should allow to select a column (amongst demographic data), then display, for each different value in this column, number of lines with this value, and "age" value average. Values must be sorted by decreasing order. One can display only 100 first values.

Page could look like:
|              -------------
|    variable | education v |
|              -------------
|    ---------------------------------------------
|    | value               | count | average age |
|    | less than 1st grade | 1234  | 45,5        |
|    |  PhD                | 123   | 34,4        |
|    ---------------------------------------------
|

For simplicity sake, all columns (except "age") are considered as "string".

Application must be a SPA (Single-Page Application), i.e. user must be able to change variable without reloading page.

Extras

  • if more than 100 different values, one can indicate number of non-displayed values.
  • indicate number of non-displayed lines (i.e. lines corresponding to non-displayed values)
  • extensibility: allow a simple way to change database and variables

Select tech stack that are adapted for exercice (backend and frontend).

Share code on GitHub ou Bitbucket. Note: on Bitbucket, private repositories are free. Otherwise by email

Ideally, share application URL.

Microservice US - CENSUS

| Component  | Docker Container | URL                         |
|------------|------------------|-----------------------------|
| swagger    | swagger          | http://localhost:3003/docs/ |
| React App  | web-service      | http://localhost:3007       |
| DB         | census-db        |                             |
| Census API | census-service   | http://localhost:3000       |

#start

$ docker-compose up --build
$ ./init_db.sh # to seed the db, it takes a long time

unit test

$ docker-compose run web-service npm test # in another terminal

todo

At minimum:

  1. init_db.sh requires census-db to be started
  2. change hardcoded urls to http://localhost to configurable ones
  3. the huge dump should not be part of docker container
  4. docker deployment - use better images appropriate for production (eg: https://github.com/phusion/passenger-docker) and install a reverse proxy (eg: https://traefik.io/)
  5. more comprehensive test overall
  6. redux

end to end tests

Only locally, no docker for the moment.

npm install testcafe@0.15.0 -g
testcafe firefox tests/**/*.js

#Shortcuts

docker exec -it $(docker-compose ps -q census-db) su postgres -c "psql census_dev"

About

react / node / docker test


Languages

Language:JavaScript 90.4%Language:HTML 6.9%Language:Shell 2.4%Language:CSS 0.2%