Giter Site home page Giter Site logo

zkid18 / countryrank Goto Github PK

View Code? Open in Web Editor NEW

This project forked from gangiman/countryrank

0.0 0.0 0.0 14.68 MB

Using your preferences rank all countries based on existing rankings.

License: GNU General Public License v3.0

Shell 1.18% JavaScript 1.99% Python 56.77% TypeScript 35.55% CSS 0.55% HTML 2.59% Mako 0.74% Dockerfile 0.63%

countryrank's Introduction

CountryRank

Slides explaining roadmap.

Simple project that given your preferences for different country attributes returns a ranked list of countries.

The original design was:

  1. rankings submodule that imports and pre-processes data series.
  2. restrict list of countries being compared.
  3. join data series into DataFrame using countries as index.
  4. rank DataFrame using your preference weights.
  5. return ranked list of countries.

There was a original version, but it was lost due to accidentally killed container, all that remained is this screenshot.

List of my preferences and some links to data

Currently downloaded rankings

  1. Social mobility by WorldBank source, data
  2. IMF GDP per Capita source, data
  3. MIPEX Immigrant Integration ranking 2015 source, data
  4. Human development report source, data
  5. Freedom of the Internet report 2018 source, data
  6. Passport Index Data original source, source, data

Other rankings

We are aware of the following rankings, but they have not been integrated yet:

  1. Corruption Perception Index by Transparency International: source

CountryRank API

Features

  • FastAPI with Python 3.8
  • React 16 with Typescript, Redux, and react-router
  • Postgres
  • SqlAlchemy with Alembic for migrations
  • Pytest for backend tests
  • Jest for frontend tests
  • Perttier/Eslint (with Airbnb style guide)
  • Docker compose for easier development
  • Nginx as a reverse proxy to allow backend and frontend on the same port

Development

The only dependencies for this project should be docker and docker-compose.

Quick Start

Starting the project with hot-reloading enabled (the first time it will take a while):

docker-compose up -d

To run the alembic migrations (for the users table):

docker-compose run --rm backend alembic upgrade head

And navigate to http://localhost:8000

Note: If you see an Nginx error at first with a 502: Bad Gateway page, you may have to wait for webpack to build the development server (the nginx container builds much more quickly).

Auto-generated docs will be at http://localhost:8000/api/docs

Rebuilding containers:

docker-compose build

Restarting containers:

docker-compose restart

Bringing containers down:

docker-compose down

Frontend Development

Alternatively to running inside docker, it can sometimes be easier to use npm directly for quicker reloading. To run using npm:

cd frontend
npm install
npm start

This should redirect you to http://localhost:3000

Frontend Tests

cd frontend
npm install
npm test

Migrations

Migrations are run using alembic. To run all migrations:

docker-compose run --rm backend alembic upgrade head

To create a new migration:

alembic revision -m "create users table"

And fill in upgrade and downgrade methods. For more information see Alembic's official documentation.

Testing

There is a helper script for both frontend and backend tests:

./scripts/test.sh

Backend Tests

docker-compose run backend pytest

any arguments to pytest can also be passed after this command

Frontend Tests

docker-compose run frontend test

This is the same as running npm test from within the frontend directory

Logging

docker-compose logs

Or for a specific service:

docker-compose logs -f name_of_service # frontend|backend|db

Project Layout

backend
└── app
    ├── alembic
    │   └── versions # where migrations are located
    ├── api
    │   └── api_v1
    │       └── endpoints
    ├── core    # config
    ├── db      # db models
    ├── tests   # pytest
    └── main.py # entrypoint to backend

frontend
└── public
└── src
    ├── components
    │   └── Home.tsx
    ├── config
    │   └── index.tsx   # constants
    ├── __tests__
    │   └── test_home.tsx
    ├── index.tsx   # entrypoint
    └── App.tsx     # handles routing

countryrank's People

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.