Skip to content

123nxxp/Database_Project

Repository files navigation

Database Project

Dispensary Management System

The given problem statement required team to develop a web application using Flask and MySQL to manage a dispensary. The team is divided into two groups, G1 and G2, with G1 responsible for the front-end and G2 for the back-end. The application should support the dynamic execution of database functions, such as insert, rename, update, delete, (CRUD) and where clause. Additionally, the application should have a login page with user and stakeholder authentication.

To develop this application, the team was first needed to design and implement the database schema. We identified the tables and fields required to store information related to the dispensary, such as products, suppliers, employees, customers, and transactions. Once the database schema is in place, G2 began working on the back-end development. We have used Flask to create the API endpoints that interact with the database. These endpoints should implement the required functions, such as inserting new records, updating existing records, deleting records, and executing where clause queries.

Meanwhile, G1 worked on the front-end development. They used Bootstrap, HTML, and CSS to create a user-friendly interface for the web application. The interface allows users to interact with the database by providing forms and buttons to add, update, and delete records. The interface displays the data stored in the database in a clear and organized manner.

As a part of the project, the team implemented user authentication to ensure that only authorized users can access the application. The login page should prompt users to enter their credentials, and upon successful authentication, the user should be redirected to the main page of the application. Finally, the team tested the application to ensure that all functions are working correctly, and the changes made through the application are correctly reflected in the main database and web page. Once the application is ready, it was pushed to GitHub. In summary, this project required the team to develop a web application using Flask and MySQL to manage a dispensary. The application supports the database functions such as insert, update, delete, rename, and where clause, and should have a login page with user authentication. The team also designed the database schema, develop the back-end using Flask, and created a user-friendly front-end using Bootstrap, HTML, and CSS. Finally, the application was be tested and pushed to GitHub for submission.

Installation

Installation requirements to run this project:

  python3 -m venv env_flask
  pip3 install flask
  pip3 install flask-mysqldb
  pip3 install pyyaml

Modules used

To run this project, you will need to add the following modules

from flask import Flask, render_template, request, redirect, url_for, session

from flask_mysqldb import MySQL

from sql_tools import *

from html_tools import *

import flask

import yaml

import MySQLdb.cursors

import re

Note: MySQL Server(workbench) should be installed on the PC. Dump the “dispensary.sql” in the same directory.

These are the major steps to launch the website:

  • Move all the files in one folder. Open folder as code in VS Code.
  • Create virtual environment using command “python -m venv venv”
  • Activate environment using command “./venv/Scripts\activate.ps1”
  • Install required libraries (mentioned above)
  • Run the “app.py” file using command “python ./app.py”
  • Click on the URL

Now after running the server you will get a login page:

image

For the existing users(login details should be available in the database), they can login to their account. Insert email and password and select the role correctly. You will be redirected to the home page.

If you are new user, you can click on “create new” on the bottom of the login page, you will be redirected to registration page:

image

Here, user need to insert username, a not existing email, password and role. You credentials will be saved in the database and now you can click on login. Login with your credentials.

For example, adding these credentials:

Database previously:

image

image

After hitting “Sign up” and refreshing database, new database snapshot, with updated entry:

image

After you are logged in, you will be able to see home page:

image

From here you can explore options. Clicking on “IIT-GN Dispensary logo” will refresh the page, “Home” will return to the same page. “Edit” allows to to update/delete the data from the tables. And “About_us” contains basic information about our project, teammates and motivation.

“Edit” View1:

image

“Edit” View2:

image

Editing particular table(here “equipment”):

image

“About us” view:

image

Content of the repository:

Screenshots of the Web Application showing all the Functionalities

The web application shows the view of the different relations with the Insert, Update, and Delete operations on these relations. Screenshots include the view of the relation with the following operations and the results with the changes in the MySQL database itself. We also include the results which give an error due to some constraints defined by us while making the database, such as primary-key error etc.

Prescription Table

  • View of Prescription Relation

prescription_web_table

  • View of Prescription Relation in Workbench

prescription_on_mysql

  • Inserting Entries in Prescription Relation

insert_on_prescription

  • Inserting Entries Result on MySql

insert_result_on_prescription

  • Updating Entries in Prescription Relation

update_on_prescription

  • Updating Entries Result on Mysql

update_result_on_prescription

  • Deleting Entries in Prescription Relation

delete_on_prescription

  • Deleting Entries Result on Mysql

delete_result_on_prescription

Reason for the error!

Since the delete operation is performed in the Prescription Relation, which consists of the primary key of the patient, in order to hold the foreign key constraint in the delete operation, The above error is shown from MySQL and it is reflected on the page.

Patient Tabe

  • View of Patient Relation

patient_web_table

  • View of Patient Relation in Workbench

patient_mysql_table

  • Inserting Entries in Patient Relation

insert_on_patient

  • Inserting Entries Result on Mysql insert_result_on_patient

  • Updating Entries in Patient Relation

update_on_patient

  • Updating Entries Result on Mysql

update_result_on_patient

  • Deleting Entries in Patient Relation

delete_on_patient

  • Deleting Entries Result on Mysql

delete_result_on_patient

General Visit Table

  • View of General Visit Relation

generalvisit_web_table

  • View of General Visit Relation in Workbench

generalvisit_mysql_table

  • Inserting General Visit in Prescription Relation

insert_on_generalvisit

  • Inserting General Visit Result on Mysql

insert_result_on_generalvisit

  • Updating Entries in General Visit Relation

update_on_generalvisit

  • Updating Entries in General Visit Result on Mysql

update_result_on_generalvisit

  • Deleting Entries in General Visit Relation

delete_on_generalvisit

  • Deleting Entries in General Visit Result on Mysql

delete_result_on_generalvisit

Medicine Table

  • View of Medicine Relation

medicine_web_table

  • View of Medicine Relation in Workbench

medicine_on_mysql

  • Inserting Medicine in Prescription Relation

insert_on_medicine

  • Inserting Medicine in Prescription Result on Mysql

insert_result_on_medicine

  • Updating Entries in Medicine Relation

update_on_medicine

  • Updating Entries in Medicine Result on Mysql

update_result_on_medicine

  • Deleting Entries in Medicine Relation

delete_on_medicine

  • Deleting Entries in Medicine Result on Mysql

delete_on_medicine

Doctor Table

  • View of Doctor Relation

doctors_web_table

  • View of Doctor Relation in Workbench

doctors_on_mysql

  • Inserting Doctor in Prescription Relation

insert_on_doctors

  • Inserting Doctor in Prescription Result on Mysql

insert_result_on_doctors

  • Updating Entries in Doctor Relation

update_on_doctors

  • Updating Entries in Doctor Result on Mysql

update_result_on_doctors

  • Deleting Entries in Doctor Relation

delete_on_doctors

  • Deleting Entries in Doctor Result on Mysql

delete_result_on_doctors

Employee Table

  • View of Employee Relation

employee_on_web

  • View of Employee Relation in Workbench

employee_on_mysql

  • Inserting Entries in Employee Relation

insert_on_employee

  • Inserting Entries in Employee Result on Mysql

insert_result_on_employee

  • Updating Entries in Employee Relation

update_on_employee

  • Updating Entries in Employee Result on Mysql

update_result_on_employee

  • Deleting Entries in Employee Relation

delete_on_employee

  • Deleting Entries in Employee Result on Mysql

delete_result_on_employee

Medical Products

  • View of Medical Products Relation

medicalproducts_web_table

  • View of Medical Products Relation in Workbench

medicalproducts_on_mysql

  • Inserting Entries in Medical Products Relation

insert_on_medicalproducts

  • Inserting Entries in Medical Products Result on Mysql

insert_result_on_medicalproducts

  • Updating Entries in Medical Products Relation

update_on_medicalproducts

  • Updating Entries in Medical Products Result on Mysql

update_results_on_medicalproducts

  • Deleting Entries in Medical Products Relation

delete_on_medicalproducts

  • Deleting Entries in Medical Products Result on Mysql

delete_result_on_medicalproducts

Here is the link for other tables snapshots

Note:

Because of a foreign key constraint error on insertion/deletion of a record, we faced a few issues with implementing deletion and insertion on some tables. We plan to resolve this issue in further iterations of the webpage.

Contribution of group Members

  • Aishwarya Omar (20110008): User authentification frontend, Connected authentication frontend with backend, Integrated webapp, Report Documentation

  • Akshat Shrivastava (20110009): Frontend debugging, Backend Development, Report documentation.

  • Amaan Ansari (20110011): Integrated frontend and developed the UI, Report compilation, Frontend Development.

  • Mahesh Dange (20110050): Frontend designing, Frontend Development, Backend Development, integrated frontend and backend, Made Readme File, Report documentaion.

  • Dhakad Bhagat Singh (20110055): Backend debugging, Backend Development, Report compilation.

  • Govardhan Ingale (20110070): Connected database backend, Frontend Development, Report compilation.

  • Ronak Hingonia (20110170): Report compilation

  • Ojas Washimkar (20110234):

  • Yash Adhiya (20110235): Backend Development,Frontend designing, Report documentation.

  • Yash Kokane (20110237): User authentification backend, Frontend designing, connected database backend for authtification, report compilation.

  • Shubham Kumar (19110137): Backend Development, Frontend debugging, Report compilation.

Refrences

Here are some refrences used -

Flask Tutorial

Database Connection

Youtube Tutorial

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published