Skip to content

triviapatente/backend

Repository files navigation

Trivia Patente - Backend

Table of Contents

Introduction

TriviaPatente is a mobile application (iOS, Android) that makes it easier and funnier to learn the theory of the driving license, connecting you with your friends. This repository contains the native Android application.

Screenshots
drawing drawing drawing

Getting started

In order to run the backend, follow these steps.

On the M1/M2 chips, preliminary do

brew install postgresql@15
brew install libpq libpq-dev --build-from-source
brew install openssl@1.1

export LDFLAGS="-L/opt/homebrew/opt/postgresql@15/lib -L/opt/homebrew/opt/openssl@1.1/lib -L/opt/homebrew/opt/libpq/lib"
export CPPFLAGS="-I/opt/homebrew/opt/postgresql@15/include -I/opt/homebrew/opt/openssl@1.1/include -I/opt/homebrew/opt/libpq/include"
export PATH="/opt/homebrew/opt/postgresql@15/bin:$PATH"

Clone the repo:

git clone git@github.com:triviapatente/backend.git

Optionally, configure a virtual environment as

cd backend
python -m venv .
pip install --upgrade pip
pip install --upgrade setuptools
pip install –-upgrade wheel

and install the dependencies with

pip install -r requirements.txt

Finally, to configure the database, do:

brew services run postgresql@15
createuser -P -s -e triviapatente``` with password "triviapatente
createdb triviapatente -O triviapatente
createdb triviapatente_test -O triviapatente

Notes:

  • In this project we considered the password "triviapatente". If you wish to use another username/password, you shall adapt the configurations in config.py.
  • To run postgresql engine at computer startup automatically, use brew services start postgresql@15.
  • To run postgresql on devices different than MacOS, check https://www.postgresql.org.

Installing

Before running the backend, you need to populate the database with questions and answers. This repository contains a crawler that gets from the internet ~7000 driver's license questions. The data is crawled from the website https://www.patentati.it/:

python run_crawler.py

Deploying

To run the webservice, use

python run.py

Testing

To run all the tests, use

python run_tests.py

Features

This part of the project enjoys some features we were extremely proud at the time:

  • RESTful APIs and Websockets
  • Test Driven Development, test coverage of 100%
  • Role-based authentication
  • Push notifications

Contribute

We still need to set up an easy way to contribute, and provide a list of updates that might improve the project. You can save your ☕️s until then or, you can drop an email to help us:

  • Set up coding style guidelines
  • Wiki
  • Documentation
  • Set up contribution workflow

Authors

This project was developed with ❤️ and a giant dose of curiosity and passion from some very young folks (we were in our teens at the time), in 2017 as a side project.

Authors
drawing Luigi Donadel
drawing Antonio Terpin
drawing Gabriel Ciulei

License

This project is licensed under the MIT License - see the LICENSE file for details.