Backend repo for voting system
- Clone the repo
- Open test coverage folder
./test_coverage/
- Open the file
index.html
to view the test coverage report
- Visit dockerhub the latest docker image (https://hub.docker.com/repository/docker/rising2392/sn-backend-api)
- View the models used in backend (https://dbdiagram.io/d/629c499b54ce2635275fd31d)
-
Clone the project
git clone https://github.com/super-novae/sn-backend.git
-
Create virtual environment
python3 -m venv env --prompt=sn-backend
-
Activate virtual environment
source env/bin/activate
-
Install project dependencies
pip install -r requirements.txt
-
Create needed databases for development in PostgreSQL shell
CREATE DATABASE supernovae_dev_db; CREATE DATABASE supernovae_test_db;
-
Create file for environment variables
touch .env
-
Add contents to the .env file
FLASK_ENV=dev FLASK_APP=run.py SECRET_KEY=super_secret_key SWAGGER_UI_CSS=https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/4.11.1/swagger-ui.min.css SWAGGER_UI_BUNDLE_JS=https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/4.11.1/swagger-ui-bundle.min.js SWAGGER_UI_STANDALONE_PRESET_JS=https://cdnjs.cloudflare.com/ajax/libs/swagger-ui/4.11.1/swagger-ui-standalone-preset.min.js REDOC_STANDALONE_JS=https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js DEV_DATABASE_URL=postgresql://postgres:password@localhost:5432/supernovae_dev_db TEST_DATABASE_URL=postgresql://postgres:password@localhost:5432/supernovae_test_db MAIL_SERVER=smtp.gmail.com MAIL_PORT=465 MAIL_USERNAME=username@email.com MAIL_PASSWORD=superuserpassword
-
Perform initial migrations
flask db init flask db migrate flask db upgrade
-
Create a super user by opening
flask shell
and running the following commandsfrom api.superuser.models import Superuser from api.extensions import db su = Superuser(name="Super User", username="super_u", email="superu@email.com") su.password = "helloworld__" db.session.add(su) db.session.commit()
-
Run application
flask run
Note
There are two databases for development, DEV & TEST. Both of these databases are supposed to have the same structure at all times. I'm working on a script to handle that but for migrations would have to be manually applied to the test database as well.