Developed by E.SUN COMMERCIAL BANK, LTD.
This system is a voting system that enables people who want to organize events and count votes to create and use voting services.
- This system uses various Google Cloud Platform components, including VM instances and Cloud SQL, to be built.
- The front-end and back-end of this system are separated, with the front-end using Vue, the back-end using FastAPI, load balancing using NGINX, and the database using Postgres. All services can be enabled using Docker Compose.
Supports the function of one or more votes.
- You will need Docker, and it is recommended to use Docker Desktop. Docker can be used to start all services directly on your local machine.
- You can configure GCP machines according to the system architecture diagram.
- Run Development Mode with Docker
# Launch the dev mode
docker-compose -f ./docker-compose-dev.yml up -d
# Stop the dev mode
docker-compose -f ./docker-compose-dev.yml down
-
Enter localhost:5000/docs in the browser URL to open the API file.
-
Execute
/db/init
to initialize the DB through the API file.
-
Enter localhost in the browser URL to open the front-end webpage.
-
The default username is "admin" and the default password is "12345678". You can also click the registration page to register a new account.
/db/init
:The data table can be created, and this step must be performed before use.
/time/change
:It is used to change the time of the voting checkpoint. The frontend will display "Voting in progress", "Voting has not yet started", and "Voting has ended".
/login
:login function.
/teams/get_menu
:Get team information according to gid.
/vote/now
:Take the server time, datetime.now is the GMT time in the Taiwan time zone, and send it back to the front end through timedelta + 8 hours./vote/who
:query who to vote for/vote/vote
:Used for voting, adding token can increase security./vote/race
:Provides calculations for counting votes./vote/race/sing
:Provides calculations for counting votes (Fake Data)./vote/race/talent
:Provides calculations for counting votes (Fake Data)./vote/delete
:delete the vote/vote/download
:Download the voting results of each group and calculate the number of votes for each group.
/vote/download2
:Download the voting overview, including calculating the total number of votes, the number of voters, the number of votes for the singing group, and the number of votes for the talent group.
/vote/count
:Calculate the number of votes, which can be used to make a bar graph (You can implement the function of viewing the bar graph during the voting process).
- docker exec -it {postgres CONTAINER ID} /bin/sh
- psql -U postgres
- Set up the load balancer. For related settings, please refer to the load_balance folder.
- Build the front-end for the production environment. Run the command.
npm run build
- Use NGINX to serve the front-end page, and the directory is set in the front-end's dist folder.
- The backend can set one or more IP locations according to your usage.
- Set up Cloud SQL.
- When using
docker-compose -f ./docker-compose.yml up
to create a container, remember to adjust theSQLALCHEMY_DATABASE_URL
setting in the backend to the IP of Cloud SQL, and adjustaxios.defaults.baseURL
in the frontend to avoid CORS errors.
Copyright (C) 2023 E.SUN BANK.
This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2.1 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.