#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.
| 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
$ docker-compose run web-service npm test # in another terminal
At minimum:
- init_db.sh requires census-db to be started
- change hardcoded urls to http://localhost to configurable ones
- the huge dump should not be part of docker container
- docker deployment - use better images appropriate for production (eg: https://github.com/phusion/passenger-docker) and install a reverse proxy (eg: https://traefik.io/)
- more comprehensive test overall
- redux
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"