A Flask and PostgreSQL web application built for a Database Systems course, focused on secure authentication, role-based access control, and safe database operations. Originally a group project; see contributions below.
Tech stack: Python, Flask, PostgreSQL, HTML/CSS
- Role-based access control with secure session management
- Password hashing for credential storage
- Parameterized queries and input whitelisting to prevent SQL injection
- Atomic database transactions using upsert logic
Originally built as a group project for a Database Systems course; this repo has been cleaned up and re-uploaded to showcase my contributions.
My contributions:
- Explained the role-based access control design to my teammate and helped implement it, including session management and password hashing
- Wrote parameterized queries and input whitelisting used to prevent SQL injection
- Designed the atomic transaction logic (upsert-based) and several of the more complex SQL aggregation queries
- Reviewed, debugged, and refined portions of the codebase originally written by my teammates
- Wrote the CSS style sheet and a number of HTML pages
Clone repository then cd to project folder
python -m venv .venv
Windows PowerShell:
.\.venv\Scripts\Activate.ps1
If you get an error about scripts being disabled, run this first:
Set-ExecutionPolicy -Scope Process -ExecutionPolicy Bypass
Then activate again.
pip install -r requirements.txt
Open a terminal and run:
& "C:\Program Files\PostgreSQL\18\bin\psql.exe" -U postgres
Sign into PostgreSQL then run the following:
CREATE DATABASE company_portal_db;
In PowerShell from the project directory:
& "C:\Program Files\PostgreSQL\18\bin\psql.exe" -U postgres -d company_portal_db -f sql\company_v3.02.sql
& "C:\Program Files\PostgreSQL\18\bin\psql.exe" -U postgres -d company_portal_db -f sql\team_setup.sql
(Change the version number in the path if needed.)
- From the project directory create a new file named .env
- (in Powershell, you can run
New-Item -Path .env -ItemType File)
- (in Powershell, you can run
- inside the .env file, enter the following (replace
<your postgres password>with your postgres password):DB_USER=postgres DB_PASSWORD=<your postgres password> DB_HOST=localhost DB_PORT=5432- replace
DB_USER,DB_HOST, andDB_PORTif your credentials do not match the defaults
- replace
From the main project directory, run the command below, and the one in step 9
python insert_user.py
python app.py
You should see the Flask test page with the current date from the database.