Web app for keeping track of buildings in danger of collapsing in the event of an earthquake

Overview

Bulina Roșie

Datree GitHub contributors GitHub last commit License: MPL 2.0

code for romania twitter code for romania facebook code for romania instagram code for romania linkedin

🇷🇴 Un cutremur în București nu este o situație ipotetică. Este o certitudine că acest lucru se va întâmpla. În acest context, la mai bine de 40 de ani de la cutremurul din 1977, memoria colectivă a ascuns în profunzime amintirile acelui dezastru în încercarea de a-și înăbuși teama. Dar realitatea este că, patru decenii mai târziu, Bucureștiul, la fel ca restul orașelor cu risc seismic ridicat, nu ar face față unui asemenea eveniment, iar pierderile de vieți omenești ar fi uriașe. Exercițiul Seism 2018 derulat de DSU arată că cel puţin 4.587 persoane şi-ar pierde viaţa, iar 8.585 ar fost rănite, 6 spitale vor fi distruse, 23 de unităţi spitaliceşti distruse parţial, iar 9 avariate, dar funcţionale. O estimare, am spune noi, destul de optimistă.

Ce putem face pentru a deveni mai puțin vulnerabili? Să știm totul despre oraș, despre clădirile în care locuim astfel încât să putem cere consolidarea lor. Bulina Roșie nu este doar "un nou site de informare", ci o platformă care colectează și validează apoi cu experți date despre clădirile din România, la nivel național, ajută asociațiile de proprietari să își consolideze clădirile, te ține la curent cu legislația și ți-o explică și are grijă să ai la îndemână informații utile la orice moment.

🇬🇧 An earthquake in Bucharest is not a hypothetical situation. It is certain that this will happen. In this context, after more than 40 years from the 1977 earthquake, the collective memory has hidden deep the memories of that disaster in its attempt of stifling its fear. The reality is that, four decades later, Bucharest, as well as the rest of the cities with a high seismic risk, would not stand up tu such an event, and the loss of life would be tremendous. The Earthquake 2018 Exercise conducted by the DSU shows that at least 4,587 people would have died and 8,585 would have been injured, 6 hospitals would be destroyed, 23 more would be partially destroyed, and 9 would be damaged, though still functional. An estimation that we would consider quite optimistic.

What can we do to become less vulnerable? Find out everything about the city, about the buildings in which we live so that we can ask for their consolidation. Bulina Roșie is not just "a new information site", but a platform that collects and then validates with the help of experts data about the buildings in Romania, at a national level, it helps owners associations to consolidate their buildings, it keeps you in touch with the current legislation and explains it to you, and it makes sure that you have useful information at your disposal at all times.

Let's save lives together.

TABLE OF CONTENTS

Contributing

If you would like to contribute to one of our repositories, first identify the scale of what you would like to contribute. If it is small (grammar/spelling, or a bug fix) feel free to start working on a fix. If you are submitting a feature or substantial code contribution, please discuss it with the team and ensure it follows the product roadmap.

Our collaboration model is described here. And make sure you check the workflow document; it helps you keep your environment in a good shape, and it helps everyone move faster with code reviews. If you want to make any change to this repository, please make a fork first.

We don't have a specific set of coding guidelines, so just follow the way the code was written until now, if in doubt, you can use Google's style guide.

Built With

Programming languages

Python 3 JavaScript

Frameworks

API: Django Client: React

Package managers

API: pip Client: npm

Code styling

API: Black Client: Prettier + ESLint + Airbnb style guide

Database technology & provider

PostgreSQL

Getting started

Risc Seismic API is a Django application, built on top of Python 3.7+ with a PostgreSQL database, while the Client is a React single page application.

Pre-requisites

In order to run the project locally, you need to have Docker and docker-compose installed.

You can install the above mentioned packages manually, or you can use our helper commands.

On Ubuntu 18.04+ run:

make install-docker-ubuntu

On MacOS run:

make install-docker-osx

On other platforms please follow the instructions described here:

The Docker versions the Makefile was tested with are:

$ docker --version
Docker version 19.03.5, build 633a0ea
$ docker-compose --version
docker-compose version 1.24.1, build 4667896b

Initial set-up

Initialise the database and development fixtures:

make init-env

External services API keys

In order to have a fully functional project, you have to get two API keys: HERE Maps API Key and hCAPTCHA API Key.

HERE Maps API Key

Tutorial: https://developer.here.com/tutorials/getting-here-credentials/

Keys added to the .env file:

# the same key can be used for both variables
HERE_MAPS_API_KEY
REACT_APP_HERE_MAPS_API_KEY

hCAPTCHA API Key

  1. Create a hCAPTCHA account
  2. Go to your settings page
  3. Add a new key and add it to the environment variables list

Keys added to the .env file:

REACT_APP_CAPTCHA_API_KEY

Starting the project

First check the .env file created by the init command and see if there are any environment variables that you might need to provide or change. This file is used by docker-compose to pass the environment variables to the container it creates.

Get the project up and running:

docker-compose up

You should be able to access the local environment site and admin at the following URLs:

If you have problems starting the project, first check out the FAQ and if that doesn't work, ask someone from the project's channel. Maybe the issue you just had is worth adding to the FAQ, wouldn't it?

To work on running containers that were started using docker-compose up, open another terminal and:

cd path/to/repo
docker-compose exec api bash
# or
docker-compose exec client bash

In order to see all available commands run:

make

Starting the project without docker

Windows platform

Prerequisites
  1. PostgreSQL
  2. Python 3.7
  3. Node.js
Steps to set your environment
  1. In project directory run:
python -m venv .venv
.venv\Scripts\activate.bat
pip install -r ./api/requirements-dev.txt
copy .env.dist .env
  1. Check the .env file created by the copy command and see if there are any environment variables that you might need to provide or change. Double check database config line in .env. It has to follow this pattern: postgres://USER:[email protected]:PORT/NAME

  2. Run following in order to set needed environment variables:

activate_dev_env.bat
  1. Check database connection. If this fails double check database configuration.
python api/wait_for_db.py
  1. Run migrations:
python api/manage.py migrate --noinput
  1. Create admin user (user to login into admin pannel):
python api/manage.py createsuperuser
  1. Load dummy data in database:
python api/manage.py loaddata buildings
python api/manage.py loaddata pages
  1. Install node modules.
cd client
npm install

Steps needed to start development servers

1. Start API server.

Open terminal in project direcotry and run environment activation script, then start the server.

.venv\Scripts\activate.bat
activate_dev_env.bat
python api\manage.py runserver 0.0.0.0:8000

Check functionality at http://localhost:8000 you shoul get 404 page.

2. Start front-end server.

Open terminal in project direcotry and run environment activation script, then start the server.

activate_dev_env.bat
cd client
npm start

Check functionality at http://localhost:3000.

Development

When creating new models in Django, in order to make sure they are generated in a clean environment, it is recommended to generate the migration files using the make command:

make makemigrations && make migrate

When you need to add/remove requirements or restrict the version of a requirement, edit the requirements.in (prod) and the requirements-dev.in (dev) files accordingly. After doing this run:

make update-requirements

This will create a clean environment where it uses the pip-tools library to compile the corresponding requirements.txt files with the versions of the packages pinned. This is important as it guarantees that every environment this service runs in, has the same dependencies installed and minimizes the risk of works on my machine.

Known Issues

Client hot-reload on Windows Docker is not working

Try following these steps:

  1. open up a terminal in seismic-risc_client container

  2. cd ./node_modules/react-scripts/config/

  3. vi webpackDevServer.config.js

  4. on the exported config object, update the value of watchOptions to include the following properties:

    aggregateTimeout: 100,
    poll: 500
  5. save the file and restart the client container

This way, webpack-dev-server should be watching files in polling mode, instead of listening for file change events.

In VS Code, ESLint fails to load the Prettier plugin

Add the following option to user settings in VS Code if ESLint fails to load the Prettier plugin.

{
  "eslint.workingDirectories": [
    {
      "mode": "auto"
    }
  ]
}

Management Commands

The new custom command can be called using python manage.py buildings required arguments:

  • --delete
  • --create
cd path/to/repo
docker-compose exec api bash
[email protected]:/code# python manage.py buildings 30 --create
100% |███████████████████████████████████████████████████████████████████████████████████████████████████████████████| 30/30 [00:00<00:00, 37.89it/s]
Successfully created 30 buildings.
[email protected]:/code# python manage.py buildings 25 --delete
Successfully deleted 25 buildings.

Testing

Local development testing:

cd path/to/repo
docker-compose exec api bash
[email protected]:/code# pytest

Pipeline testing:

make test

Production

In order to get the container ready for production use we need to first build it:

docker build -t seismic-risc:latest ./api

Use the prod.env.dist template file and create a prod.env file with the correct environment variables and run like so:

docker run --env-file prod.env -p HOST_PORT:GUNICORN_PORT seismic-risc:latest

Or, you can provide all the environment variables at runtime:

docker run -e DJANGO_CONFIGURATION=Prod -e DJANGO_SECRET_KEY= -e DATABASE_URL=postgres://USER:[email protected]:PORT/NAME -e GUNICORN_PORT=5000 -e GUNICORN_WORKERS=2 -p HOST_PORT:GUNICORN_PORT seismic-risc:latest

After testing the container runs properly, tag and upload the image to Docker hub:

docker tag seismic-risc:latest code4romania/seismic-risc:latest
docker push code4romania/seismic-risc:latest

Client Deployment

  • Change directory to ./client
  • Build the solution npm install
  • Start a development server npm start
  • Run the tests npm test
  • Build the solution npm run build

Feedback

  • Request a new feature on GitHub.
  • Vote for popular feature requests.
  • File a bug in GitHub Issues.
  • Email us with other feedback [email protected]

License

This project is licensed under the MPL 2.0 License - see the LICENSE file for details

About Code4Ro

Started in 2016, Code for Romania is a civic tech NGO, official member of the Code for All network. We have a community of over 500 volunteers (developers, ux/ui, communications, data scientists, graphic designers, devops, IT security and more) who work pro-bono for developing digital solutions to solve social problems. #techforsocialgood. If you want to learn more details about our projects visit our site or if you want to talk to one of our staff members, please e-mail us at [email protected].

Last, but not least, we rely on donations to ensure the infrastructure, logistics and management of our community that is widely spread across 11 timezones, coding for social change to make Romania and the world a better place. If you want to support us, you can do it here.

Owner
Code for Romania
Together, we build tech tools for a stronger society
Code for Romania
Retrieve bank transactions and categorize for budgeting use

Budgeting After trying out some budgeting software, I decided to make my own. selenium_scraper Using the selenium package, this script runs an instanc

Marc 1 Nov 10, 2021
NExT-Ford-aula4 - NExT Ford aula4

Questão 1: vocês deveram fazer o passo a passo de como ficará as pilhas(Stack) e

Gerson 1 Jan 06, 2022
We are building an open database of COVID-19 cases with chest X-ray or CT images.

🛑 Note: please do not claim diagnostic performance of a model without a clinical study! This is not a kaggle competition dataset. Please read this pa

Joseph Paul Cohen 2.9k Dec 30, 2022
BridgeWalk is a partially-observed reinforcement learning environment with dynamics of varying stochasticity.

BridgeWalk is a partially-observed reinforcement learning environment with dynamics of varying stochasticity. The player needs to walk along a bridge to reach a goal location. When the player walks o

Danijar Hafner 6 Jun 13, 2022
The first Python 1v1.lol triggerbot working with colors !

1v1.lol TriggerBot Afin d'utiliser mon triggerbot, vous devez activer le plein écran sur 1v1.lol sur votre naviguateur (quelque-soit ce dernier). Vous

Venax 5 Jul 25, 2022
SHF TEST BACKEND

➰ SHF TEST BACKEND ➿ 🐙 Goals Dada una matriz de números enteros. Obtenga el elemento máximo en la matriz que produce la suma más pequeña al agregar t

Wilmer Rodríguez S 1 Dec 19, 2021
Blender Add-on That Provides Quick Access to Render Controls

Blender Render Buttons Blender Add-on That Provides Quick Access to Render Controls A Blender 3.0 compatablity update of Blender2.8x-RenderButton v0.0

Don Schnitzius 3 Oct 18, 2022
A module to prevent invites and joins to Matrix rooms by checking the involved server(s)' domain.

Synapse Domain Rule Checker A module to prevent invites and joins to Matrix rooms by checking the involved server(s)' domain. Installation From the vi

matrix.org 4 Oct 24, 2022
Class and mathematical functions for quaternion numbers.

Quaternions Class and mathematical functions for quaternion numbers. Installation Python This is a Python 3 module. If you don't have Python installed

3 Nov 08, 2022
Usando Multi Player Perceptron e Regressão Logistica para classificação de SPAM

Relatório dos procedimentos executados e resultados obtidos. Objetivos Treinar um modelo para classificação de SPAM usando o dataset train_data. Class

André Mediote 1 Feb 02, 2022
This is a Poetry plugin that will make it possible to build projects using custom TOML files

Poetry Multiproject Plugin This is a Poetry plugin that will make it possible to build projects using custom TOML files. This is especially useful whe

David Vujic 69 Dec 25, 2022
A basic tool to generate Hydrogen drum machine kits.

Generate Hydrogen Kit A basic tool to generate drumkit.xml files for Hydrogen drum machine. Saves a bit of time when making kits. Supply it with a nam

Luna Langton 2 Nov 28, 2021
Easytile blender - Simple Blender 2.83 addon for tiling meshes easily

easytile_blender Dead simple, barebones Blender (2.83) addon for placing meshes as tiles. Installation In Blender, go to Edit Preferences Add-ons

Sam Gibson 6 Jul 19, 2022
The worst and slowest programming language you have ever seen

VenumLang this is a complete joke EXAMPLE: fizzbuzz in venumlang x = 0

Venum 7 Mar 12, 2022
Lectures for Udemy - Complete Python Bootcamp Course

Complete-Python-Bootcamp Welcome to the Repository for the Complete Python Bootcamp! This is the Repository for the Udemy course - "Complete Python Bo

Marci 2k Dec 28, 2022
Performance monitoring and testing of OpenStack

Browbeat Browbeat is a performance tuning and analysis tool for OpenStack. Browbeat is free, Open Source software. Analyze and tune your Cloud for opt

cloud-bulldozer 83 Dec 14, 2022
LPCV Winner Solution of Spring Team

LPCV Winner Solution of Spring Team

22 Jul 20, 2022
GWCelery is a simple and reliable package for annotating and orchestrating LIGO/Virgo alerts

GWCelery is a simple and reliable package for annotating and orchestrating LIGO/Virgo alerts, built from widely used open source components.

Min-A Cho Zeno 1 Nov 02, 2021
A class to draw curves expressed as L-System production rules

A class to draw curves expressed as L-System production rules

Juna Salviati 6 Sep 09, 2022
Build a grocery store management application.

python_projects_grocery_webapp In this python project, we will build a grocery store management application. It will be 3 tier application, Front end:

codebasics 54 Dec 29, 2022