A platform for profiling candidates in Brazilian 2018 General Election, based entirely on open data.
This project requires Docker and Docker Compose.
To run the API, you must copy the .env.sample to a .env file and
edit it accordingly.
Starting the application:
$ docker-compose upThe website and API will be available at
localhost:8000 and the Jupyter at
localhost:8888.
You should create your database by applying migrations:
$ docker-compose run django ./manage.py migrateYour local data/ directory is mapped, inside the container, to /mnt/data.
Each command uses a CSV (compressed as .xz or not) from a public and
available source. Use --help for more info. Yet some extra data can be
generated with some Django custom commands.
Once you have download the datasets to data/, the roadmap is:
$ docker-compose run django python manage.py load_affiliations /mnt/data/filiacao.csv
$ docker-compose run django python manage.py load_candidates /mnt/data/candidatura.csv
$ docker-compose run django python manage.py link_affiliations_and_candidates
$ docker-compose run django python manage.py link_politicians_and_election_results
$ docker-compose run django python manage.py load_assets /mnt/data/bemdeclarado.csv
$ docker-compose run django python manage.py load_bills /mnt/data/senado.csv
$ docker-compose run django python manage.py load_bills /mnt/data/camara.csvList all candidates from a certain state to a given post. For example:
/api/candidate/2018/df/deputado-distrital/
Post options for 2018 are:
1o-suplente2o-suplentedeputado-distritaldeputado-estadualdeputado-federalgovernadorpresidentesenadorvice-governadorvice-presidente
State options are the abbreviation of the 27 Brazilian states, plus br for
national election posts.
Returns the details of a given candidate.
Get national statistics for a given characteristic in a elected post.
Post options are:
deputado-distritaldeputado-estadualdeputado-federalgovernadorprefeitosenadorvereador
Characteristic options are:
ageeducationethnicitygendermarital_statusoccupationparty
Same as above but aggregated by state.
$ docker-compose run django py.test
$ docker-compose run django black . --check