Skip to content

zain2323/prizebond-draw

Repository files navigation

Prizebond Drawer

📜 Project Description

Prize Bond Draw is a web application for managing prize bonds which are a unique method of investment that are essentially lotteries backed by the government.

  1. This is a full stack web application that supports all the CRUD operations.
  2. Supports role based mechanism to authorize the users.
    • Admin Can add denominations and their respective prizes, update the winning list and announce the notifications to all the users.
    • User Can store their bond serials and check the results of either all of their serials or by entering any particular serial.
  3. One unique feature is that you can add your bond serial by just uploading their picture.

If you would like to read more about how prize bond works then check out this link Prize Bond.

NOTE: I have made this website in accordance with how the prize bond works in Pakistan only and I am not sure of the process followed in other countries.

🧑‍💻 Tech Stack

Here's the breif overview of the tech stack I have used:

  • This project uses Flask Microframework. Flask is a open source python web framework that is built with only minimalistic features and easy to extend philosophy.

  • For data storage the project uses Postgresql which is an open source relational database.

  • Various other flask extension have been used to further extend the functionalities as flask only provides the core features.

  • For the User Interface the project uses HTML/CSS , Javascript and Bootstrap V5.0.

  • For the extraction of serial and denomination from the bond picture, the project uses Microsoft Azure Optical Character Recognition service.

🐧 Installation Instructions For Ubuntu 20.04 LTS

🗃️ Database Setup

  1. Install Postgresql on Ubuntu.
sudo apt update
sudo apt install postgresql postgresql-contrib
  1. Access the postgres prompt by running.
sudo -u postgres psql
  1. Create a new database and the user.
CREATE DATABASE prizebond_draw_db;
CREATE USER prizebond_draw_user WITH PASSWORD 'password';
  1. Now grant the access rights to our newly created database user.
GRANT ALL PRIVILEGES ON DATABASE prizebond_draw_db TO prizebond_draw_user;
  1. Now exit the shell.
/q

⬆️ Installing the Project Dependencies

Make sure you have python3 and pip3 installed.

  1. Clone the repository and navigate to the project directory.
git clone https://github.com/zain2323/prizebond-draw.git
cd prizebond-draw
  1. Activate the virtual environment.
source venv/bin/activate
  1. Install this package first as it is a required dependency for psycopg2 library.
sudo apt install python3-dev libpq-dev
  1. Now install all the required dependencies.
pip3 install -r requirements.txt

✔️ Obtaining Azure Subscription_Key and Endpoint

  1. Create Microsoft Azure account if you don't have one.
  2. To obtain subscription_key and endpoint refer to this official guide.

🔧 Setting Up the Application Configurations

  1. navigate to the project directory.
cd prizebond-draw
  1. Copy the secrets.json file to the /etc/ directory.
sudo cp secrets.json /etc/
  1. To generate a secret key for the project run this script in the python shell and copy the output string.
import secrets
secrets.token_hex()
  1. Now open the secrets.json file.
sudo nano /etc/secrets.json
  1. Replace all the necessary details in the file with the correct one.
{
    "SECRET_KEY": "<PASTE YOUR SECRET KEY HERE>",
    "MAIL_USERNAME":"<USERNAME>",
    "MAIL_PASSWORD": "<PASSWORD>",
    "EMAIL": "<EMAIL>",
    "DB_PASSWORD": "<DB_PASSWORD>",
    "DB_ROLE": "<DB_ADMIN>",
    "DB_NAME": "<DB_NAME>",
    "HOST": "<DB_SERVER>",
    "SUBSCRIPTION_KEY": "<YOUR MICROSOFT AZURE SUBSCRIPTION_KEY>",
    "ENDPOINT": "<YOUR MICROSOFT AZURE ENDPOINT>"
}
  1. Make sure to save all the changes.

If you are running this application locally then "HOST": "localhost"

▶️ Running the Application

  1. Initialize the flask environment variable and run the migration script to setup the database schema.
export FLASK_APP=run.py
flask db upgrade
  1. To run the application execute this command.
flask run

Now navigate to the localhost:5000 on your browser to use the application.

Hosted with ❤️ by Azure

🚀 CI/CD

This project uses Github Actions for the deployment.

©️ Copyright

GitHub

About

A web-application developed for the Microsoft Azure Trial Hackathon hosted by https://dev.to/

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published