import streamlit as st import sqlite3 import qrcode import io # SQLite setup DB_NAME = "cafe.db" def init_db(): conn = sqlite3.connect(DB_NAME) c = conn.cursor() c.execute('''CREATE TABLE IF NOT EXISTS reservations ( id INTEGER PRIMARY KEY AUTOINCREMENT, name TEXT NOT NULL, guests INTEGER, date TEXT, time TEXT )''') conn.commit() conn.close() def get_db_connection(): return sqlite3.connect(DB_NAME) def generate_qr_code(link): qr = qrcode.make(link) buf = io.BytesIO() qr.save(buf) buf.seek(0) return buf # Initialize DB on startup init_db() # Constants GOOGLE_MAPS_URL = "https://www.google.com/maps/place/Brew+%26+Bite+Cafe" WHATSAPP_LINK = "https://wa.me/923001234567?text=Hi%20I%20want%20to%20place%20an%20order" # Menu deals = { "DEAL-1": "Small Pizza (Special) + 345ml Drink - Rs. 749", "DEAL-2": "Medium Pizza (Special) + 500ml Drink - Rs. 1199", "DEAL-3": "Large Pizza (Special) + 1L Drink - Rs. 1799", "DEAL-4": "Large Pizza + Medium Pizza + 1.5L Drink - Rs. 2899", "DEAL-5": "Two Large Pizzas (Special) + 1.5L Drink - Rs. 3399", "DEAL-6": "X-Large Pizza (Special) + 2 Chicken Burgers + 1.5L Drink - Rs. 3199", "DEAL-7": "Pasta + Large Pizza + 2 Chicken Burgers + 1.5L Drink + Fries - Rs. 2499", "DEAL-8": "Zinger Burger + 345ml Drink + Fries - Rs. 649", "DEAL-9": "Smoky Sensation or Famous Star Burger + 345ml Drink + Fries - Rs. 849", "DEAL-10": "Tabahi Burger + 345ml Drink + Fries - Rs. 1049", "DEAL-11": "3 Zinger Burgers + 1L Drink + Behari Roll + Fries - Rs. 1999", "DEAL-12": "3 Smoky Sensation or Famous Star Burgers + Behari Roll + 1L Drink + Fries - Rs. 2499" } sauces = [ "Ranch Sauce - Rs. 70", "Garlic Sauce - Rs. 70", "Dip Sauce - Rs. 70", "Flaming Sauce - Rs. 70", "Peeri Peeri - Rs. 70", "Shahi Sauce - Rs. 70" ] drinks = [ "345ml - Rs. 80", "500ml - Rs. 120", "1 Liter - Rs. 180", "1.5 Liter - Rs. 220" ] waters = [ "500ml - Rs. 60", "1.5 Liter - Rs. 100" ] # UI st.set_page_config(page_title="CheezeMan Cafe Chatbot", layout="centered") st.title("Welcome to CheezeMan Cafe Chatbot") # Replace sidebar with main menu buttons st.markdown("### Main Menu") option = st.selectbox("Choose an action:", [ "View Full Menu", "Place Order", "Ask a Question", "Reserve Table", "Our Location", "Scan Menu QR" ]) if option == "View Full Menu": st.subheader("Deals") for name, details in deals.items(): st.write(f"{name}: {details}") st.subheader("Sauces & Add-ons") for item in sauces: st.write(f"- {item}") st.subheader("Drinks") for item in drinks: st.write(f"- {item}") st.subheader("Water") for item in waters: st.write(f"- {item}") elif option == "Place Order": st.subheader("WhatsApp Order") st.markdown(f"[Click Here to Place Order on WhatsApp]({WHATSAPP_LINK})") elif option == "Ask a Question": st.subheader("Ask a Question") question = st.text_area("Ask us anything!") if st.button("Submit"): st.success("We'll get back to you shortly via WhatsApp or Email!") elif option == "Reserve Table": st.subheader("Reserve Your Table") name = st.text_input("Name") guests = st.number_input("Number of Guests", min_value=1, max_value=20) date = st.date_input("Date") time = st.time_input("Time") if st.button("Book Table"): conn = get_db_connection() cursor = conn.cursor() cursor.execute("INSERT INTO reservations (name, guests, date, time) VALUES (?, ?, ?, ?)", (name, guests, str(date), str(time))) conn.commit() conn.close() st.success("Table reserved successfully!") elif option == "Our Location": st.subheader("Find Us Here") st.markdown(f"[Open in Google Maps]({GOOGLE_MAPS_URL})") elif option == "Scan Menu QR": st.subheader("Scan to Open Menu") qr_buffer = generate_qr_code("https://your-cafe-website.com/chatbot") st.image(qr_buffer, caption="Scan with your phone to view the menu") st.download_button("Download QR Code", qr_buffer, "menu_qr.png", mime="image/png")