ElectorZ is a political game based on geographical strategies.
This repository hosts the backend of the ElectorZ web application, written in FastAPI. The code of the frontend is available in the Electorz Frontend repository.
The entire project configuration is defined in an environment file, of which a template is present in the repository. To bootstrap the configuration, launch the following command:
make .env
You may then modify the following environment variables to configure the ElectorZ backend:
APP_HOST
: IP address on which the server listensAPP_PORT
: port on which the server listensFRONTEND_URL
: URL of the frontend (to enable CORS)MONGO_HOST
: host of the MongoDB instanceMONGO_PORT
: port on which the MongoDB instance listensMONGO_DB_NAME
: name of the MongoDB databaseMONGO_USERNAME
: name of the MongoDB userMONGO_PASSWORD
: password of the MongoDB userMONGO_TLS
: boolean that indicates if TLS must be enabled to connect to the MongoDB instanceMONGO_MAX_CONNECTIONS
: maximum number of connections to the MongoDB instanceMONGO_MIN_CONNECTIONS
: minimum number of connections to the MongoDB instance
You can install the pip
requirements by launching the following command:
make install
If you do not have a MongoDB instance available for the ElectorZ application, you can launch a dockerized version of MongoDB by launching the following command:
make stack
It will automatically provision the database with the JSON files present in the db-init directory.
Note that a mongo-express
image has been added to the docker-compose file to help you manage the database: it provides a web administration tool available at http://localhost:8081.
Once a MongoDB database is available with the configuration options provided in the environment file, the ElectorZ backend application may be launched with the following command:
make start
FastAPI provides automatic documentations thanks to the Swagger & Redoc modules: you can for instance visit http://localhost:8080/docs to get all information about the API and test the routes.
This application started as personal project, but I welcome community contributions to it. If you find problems, please open an issue or create a PR against the ElectorZ Backend repository.
You can also reach me by email at me@just1not2.org
.
Mozilla Public License Version 2.0.
See LICENSE to see the full text.
This application was created in 2022 by Justin Béra.