This repository encompasses both frontend and server code for the election tool developed to be deployed in the HPI Schul-Cloud in Potsdam.
This readme will guide you through the setup steps.
In general you will need NodeJS for both front- and backend as well as MongoDB for the backend. Using the Community Server (linked) is enough. It is however recommended to use a tool like Studio 3T to visualize the database content you create during testing. A local Installation of Git will also be assumed.
All code needed for the election tool frontend is contained in the frontend folder.
-
clone this repository
git clone https://gitlab.hpi.de/lukas.budach/election-tool.git
-
you need to navigate into the election-tool-frontend folder
cd election-tool-frontend
-
download and locally install all required node modules
npm install
Now the frontend is ready to go and you can continue setting up the database and backend.
-
switch into the
election-tool-database
folder and run:docker-compose up
-
install MongoDB
-
add the binary folder at the install location to your system path. The path to this directory usually looks something like this:
C:\Program Files\MongoDB\Server\3.6\bin
-
add the git binary folder to your system path. It may be located in a directory like this:
C:\Program Files\Git\bin
-
restart your terminal
-
create a folder for your database in the election-tool directory, for example
election-tool-database
-
start the database by executing:
mongod --bind_ip 0.0.0.0 --port 3100 --dbpath "C:\..\election-tool\election-tool-database"
This causes it to be hosted on your local ip port 3100. You can access the database at [yourLocalIPv4]:3100 as well as localhost:3100. Now just keep MongoDB running until you are done with working on front- and backend.
-
clone this repository
-
open a terminal and navigate into the election-tool-backend folder
cd election-tool-backend
-
download and locally install all required node modules
npm install
Once you have done this you are ready to run the project.
There are two configurations currently available for this project.
-
localDevelopment sets hosts and paths in a way that only allows the project to run on a single machine. Using this configuration mode requires you to access every part of the front- and backend through localhost:[port]. This mode is recommended for the regular development.
-
multiDeviceDevelopment requires you to set the paths to server and database to your local IPv4 in the config.json files in both frontend and backend. Those can be found in the config directories in both projects. This mode needs to be used when wanting to run server and frontend on multiple different devices within the same network. Front- and backend can be accessed through [yourIP]:[port]. This configuration is recommended for testing the developments made on multiple different devices.
The config mode used by default is localDevelopment. Before running front- or backend you may want to change the used configuration in the following files:
- Frontend
- src\main.js
- config\index.js
- Backend
- config.js
start the database by executing:
mongod --bind_ip 0.0.0.0 --port 3100 --dbpath "C:\..\election-tool\election-tool-database"
OR if using docker:
docker-compose up
-
navigate to the directory
election-tool-backend\dataGeneration
-
to populate the database run
node fillWithDebugData.js
to create elections as well as some candidates and votes!!! If there are errors while populating the database try rerunning the script until no more errors are printed to your console !!!
-
navigate back to the directory
election-tool-backend
-
start the server by calling
node app.js
The server will run on port
3000
-
open a console and navigate to the election-tool-frontend directory
-
start the frontend with:
npm run dev
You should now be able to view the frontend at localhost:8080.
The link above will take you to the regular election selection page and assign you a random student name and id from the database for debug purposes. Upon reloading the page a different student is assigned to your session.
It is however to note, that accessing the election dashboard visible to the election creater through anything but the intended path of using the election selection page (startpage) is not recommended as it may produce undesired results and impair the functions of the page significantly!
There exist a documentation of the backend routes as well as one for the frontend Vue components.
If you are trying to integrate this tool into Schul-Cloud have a look at our thoughts on that.