Skip to main content
Trevor Grafton

PROJECT 05 / Full stack

Full-Stack Restaurant App

A Flask and MySQL staff app for a restaurant, with face-recognition login and a chatbot.

Built
  • Flask
  • MySQL
  • JavaScript
  • OpenCV
  • face_recognition
  • OpenAI API
Type
Full stack
Source
Public on GitHub
Role
My own project; I am the only author.
Built with
Flask, MySQL, JavaScript

01 / Overview

Overview

  1. Sign in with your face

    The browser webcam sends a frame and the server checks it against a stored staff face.

  2. Manage the restaurant

    Pages for customers, menu, reservations, orders, order items and employees, each with add, update and delete.

  3. Ask the chatbot

    A separate console chatbot answers questions about the data in plain English.

02 / Context and problem

Context and problem

A database app built end to end: a nine-table MySQL schema, a Flask server, browser pages and an unusual login.

03 / My role

My role

My own project; I am the only author.

04 / How it works

How it works

  1. Capture

    JavaScript grabs a webcam frame and posts it to the server.

  2. Match

    The server encodes the face and compares it with the known staff face. No face or no match returns a message.

  3. Session

    A match marks the session as logged in; logout clears it.

  4. Validate and save

    Pages check the input, then run parameterised SQL. Errors show as flash messages.

  5. Chatbot

    The chatbot asks a model for a single SELECT query, runs it, and turns the rows into a plain-English answer.

Flask app

Routes and 17 HTML templates for the six areas of the app.

MySQL schema, 9 tables

Customer, Employee, DiningTable, Reservation, MenuItem, Category, MenuItemCategory, Order and OrderItem.

Validation rules

Letters-only names, 10-digit phones, a reservation date that is valid and not in the past, and a party size that fits the table.

Chatbot

A separate console program using the OpenAI API, with chat history.

05 / Walkthrough

Walkthrough

  1. Entity-relationship diagram of the nine restaurant tables and their keys

    Step 01

    Nine tables in third normal form

    Customers, employees, dining tables, reservations, menu items, categories, orders and order items, normalized to third normal form. Primary and foreign keys enforce the relationships, and MySQL's default Repeatable Read isolation keeps reads stable inside a transaction.

  2. SQL for the OrderSummary view

    Step 02

    A view for order totals

    The OrderSummary view joins orders, customers, order items and menu items to give each order's total price.

  3. SQL for the CreateOrder stored procedure

    Step 03

    A stored procedure to open an order

    CreateOrder inserts a new pending order for a customer and the employee taking it, stamped with the current time.

  4. SQL for the GetOrderTotal function

    Step 04

    A function for one order's total

    GetOrderTotal adds up quantity times price for an order and returns 0 when the order has no items.

  5. SQL for the order item quantity validation trigger

    Step 05

    A trigger that guards quantities

    A BEFORE INSERT trigger on order items rejects a quantity of zero or less with a custom SQL error.

  6. SQL for the top customers by spending report

    Step 06

    A report of top customers

    An aggregate query ranks customers by total spending across their orders.

06 / Results and numbers

Results and numbers

9

tables in the MySQL schema

Checked in codeSchema export in the source repo

17

page templates

Checked in codeTemplates folder in the source repo

07 / Limitations

Limitations

  • No automated tests.
  • Face login matches one known staff face only.
  • The chatbot's read-only rule is enforced by its prompt, not by database permissions.
  • No duplicate-reservation check, and the chatbot is console only.
  • The public repository holds the database SQL file, which lists eight tables; the nine-table version with its view, procedure, function and trigger is shown in the walkthrough above.

08 / What's next

What's next

  • Reservation editing and multi-staff login.
  • Duplicate-reservation prevention and more validation.
  • Logging of login attempts and UI styling.

09 / Media gallery

Media gallery

The restaurant app home page with its navigation menu: Home, Customers, Add Customer, Menu and Reservations
The menu page: add a menu item with name, description and price, with a table of items and delete buttons
Face login: the webcam matched a staff face and the app reported the login
Watch on YouTube (opens in a new tab)
Restaurant management app demo

10 / Next project

Next project

Roblox Games →