Restaurant Management System
Restaurant Management System
MANAGEMENT SYSTEM
WELCOME TO
EPICURE’S DELIGHT
🍽 A FAMILY RESTAURANT!! 🍽
INDEX
S No TOPIC PAGE NO
HARDWARE / SOFTWARE
2. 4
REQUIREMENTS
3. FUNCTIONS 5
4. MODULES 6
5. SOURCE CODE 7
6. OUTPUT 16
7. BIBLIOGRAPHY 18
2
OBJECTIVE OF THE PROJECT:
The primary objective of a food delivery app is to provide a convenient and
efficient platform for users to order food from their favorite restaurants and have it
delivered to their doorstep. Here are some key objectives:
3
HARDWARE REQUIREMENTS:
1.Processor: Intel Pentium 4 or later or compatible
2.Hard Disk: 410GB or more
3.RAM: 1GB or more
4.Printer: Any
5.Monitor: SVGA color monitor (touch screen or simple)
6.Pointing Device: Touch pad or keys
SOFTWARE REQUIREMENTS:
1.Python 3.9.0 or higher
2.MYSQL 8.0
4
FUNCTION:
A function is a block of code, which only runs when it is called. You can pass data,
known as parameters, into a function. A function can return data as a result.
1. Built-in functions: These predefined functions are always
available for use. Eg:- len(), int() etc.
2. Functions defined in modules: These are predefined functions available in
specific modules and can be used only when that module is imported. Eg:
random.randint() gives a random integer value in a given interval. This is available
in the random module.
3. User defined functions: the user defines these functions.
cursor() menu()
execute() adddata()
print() update()
int() delete()
fetchall() display()
commit() set_database()
fetchone() user_signup
connect() main()
5
MODULES:
A Python module is a file containing Python definitions and statements. A module
can define functions, classes, and variables.
6
SOURCE CODE
import mysql.connector
from mysql.connector import Error, IntegrityError
def setup_database(cursor):
cursor.execute("CREATE DATABASE IF NOT EXISTS food_delivery")
cursor.execute("USE food_delivery")
cursor.execute("""
CREATE TABLE IF NOT EXISTS veg_menu (
id INT AUTO_INCREMENT PRIMARY KEY,
type ENUM('starters', 'main_course', 'combo'),
name VARCHAR(255) UNIQUE,
price DECIMAL(10, 2)
)
""")
cursor.execute("""
CREATE TABLE IF NOT EXISTS non_veg_menu (
id INT AUTO_INCREMENT PRIMARY KEY,
type ENUM('starters', 'main_course', 'combo'),
name VARCHAR(255) UNIQUE,
price DECIMAL(10, 2)
)
7
""")
cursor.execute("""
CREATE TABLE IF NOT EXISTS desserts (
id INT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(255) UNIQUE,
price DECIMAL(10, 2)
)
""")
cursor.execute("""
CREATE TABLE IF NOT EXISTS users (
id INT AUTO_INCREMENT PRIMARY KEY,
username VARCHAR(255) UNIQUE,
password VARCHAR(255)
)
""")
def insert_data(cursor):
# Check if the tables are empty before inserting
cursor.execute("SELECT COUNT(*) FROM veg_menu")
if cursor.fetchone()[0] == 0:
veg_menu_data = [
('starters', 'Vegetable Spring Rolls', 150),
('starters', 'Paneer Tikka', 200),
('starters', 'Vegetable Samosa', 100),
('starters', 'Hara Bhara Kebab', 150),
8
('main_course', 'Paneer Butter Masala', 250),
('main_course', 'Dal Makhani', 180),
('combo', 'Veg Thali', 300)
]
for item in veg_menu_data:
try:
cursor.execute("INSERT INTO veg_menu (type, name, price) VALUES
(%s, %s, %s)", item)
except IntegrityError:
pass
9
if cursor.fetchone()[0] == 0:
desserts_data = [
('Gulab Jamun', 100),
('Ras Malai', 120)
]
for item in desserts_data:
try:
cursor.execute("INSERT INTO desserts (name, price) VALUES (%s,
%s)", item)
except IntegrityError:
pass
def user_signup(cursor):
username = input("Enter a username: ").strip()
password = input("Enter a password: ").strip() # Consider hashing this
try:
cursor.execute("INSERT INTO users (username, password) VALUES (%s,
%s)", (username, password))
mydb.commit()
print("\nSign up successful!\n")
except IntegrityError:
print("\nUsername already exists. Please try again.")
def user_login(cursor):
username = input("Enter your username: ").strip()
password = input("Enter your password: ").strip()
10
cursor.execute("SELECT * FROM users WHERE username = %s AND
password = %s", (username, password))
user = cursor.fetchone()
if user:
print("\n\nLogin successful!\n")
return True
else:
print("\nInvalid credentials. Please try again.\n")
return False
def fetch_desserts(cursor):
cursor.execute("SELECT DISTINCT * FROM desserts")
return cursor.fetchall()
def display_desserts(desserts):
11
print("\nDesserts Menu:")
for dessert in desserts:
print(f"ID: {dessert[0]}, Name: {dessert[1]}, Price: {dessert[2]}")
print("**************************************************************
******************")
print("**************************************************************
******************")
print("\n------------------- Bill ---------------------")
print(f" Restaurant: {restaurant_name} ")
total = 0
for item in order_items:
print(f"{item[0]} : ₹{item[1]}")
total += item[1]
print("------------------------------------------------")
print(f"Total : ₹{total} ")
print("------------------------------------------------")
print("Thank you for ordering from Epicure's Delight!\n")
def main():
try:
setup_database(cursor)
insert_data(cursor) # Call only once
12
print("**************************************************************
******************")
print(" Welcome to Epicure's Delight! ")
print(" A family Restaurant! ")
print("**************************************************************
******************")
while True:
action = input("Would you like to 'signup' or 'login'?\nPress 1 to SignUp and
2 to Login: ").strip().lower()
if action == '1':
user_signup(cursor)
elif action == '2':
if user_login(cursor):
break
else:
print("Invalid choice. Please type 'signup' or 'login'.")
print("**************************************************************
******************")
food_type = input("Would you like to see the 'veg' or 'non-veg' menu?
").strip().lower()
if food_type not in ['veg', 'non-veg']:
print("Invalid choice. Please choose 'veg' or 'non-veg'.")
return
menu = fetch_menu(cursor, food_type)
display_menu(menu, food_type)
13
# Display desserts
desserts = fetch_desserts(cursor)
display_desserts(desserts)
print("\nWould you like to order anything from the menu? (yes/no)")
if input().strip().lower() == 'yes':
order_items = []
while True:
item_id = int(input("Enter the ID of the item to order (or 0 to finish): "))
if item_id == 0:
break
# Verify if the item exists in the menu
cursor.execute("SELECT name, price FROM veg_menu WHERE id =
%s", (item_id,))
veg_item = cursor.fetchone()
cursor.execute("SELECT name, price FROM non_veg_menu WHERE id
= %s", (item_id,))
non_veg_item = cursor.fetchone()
cursor.execute("SELECT name, price FROM desserts WHERE id = %s",
(item_id,))
dessert_item = cursor.fetchone()
if veg_item:
item_name, item_price = veg_item
elif non_veg_item:
item_name, item_price = non_veg_item
elif dessert_item:
item_name, item_price = dessert_item
14
else:
print("Item not found. Please enter a valid ID.")
continue
order_items.append((item_name, item_price))
if order_items:
generate_bill(order_items, restaurant_name="Epicure's Delight")
elif input().strip().lower() == 'no':
print("Thanks for wasting our time")
else:
print("Please enter YES or NO")
except mysql.connector.Error as err:
print(f"Error: {err}")
finally:
cursor.close()
mydb.close()
main()
15
OUTPUT
16
17
BIBLIOGRAPHY
Book- Python by Sumita Arora
www.python.org
https://www.geeksforgeeks.com
18