Skip to content

Project 3 Wiki

nmcorn21 edited this page Dec 3, 2024 · 17 revisions

Project Wiki: Panda Express POS and Customer Ordering Kiosk

Project Overview

Welcome to the project-3-team-9b repository! This project is a software solution designed for Panda Express to enhance operational efficiency and improve customer engagement. The system includes the following major components:

  1. Static Menu Board: A visually engaging menu display that updates in real-time.
  2. POS System with Manager Statistics: A robust point-of-sale system allowing managers to track inventory, employee productivity, and sales.
  3. Customer Ordering Kiosk: A self-service kiosk for customers to place their orders quickly and easily.

Project Folder Structure

This sections provides the breakdown and organization of our project. While it is clearly large that is due to the fact that this is a very large project and took roughly two months of effort. It is import to note that many of the small file received a quick and concise summary while the larger files that we spent more time on received the class and function breakdown. The following is the project breakdown into the several folders and many files that make it up:

datasets/:

Contains preprocessed datasets used to simulate customer queries and provide assistant responses for training or testing conversational assistants.

  • dataset_prepared.jsonl: A JSONL file containing simulated conversations about Panda Express menu items.

scrums/:

Contains meeting notes documenting the progress and tasks discussed during Scrum meetings.

  • Scrum 10/25.pdf: Discusses the first meeting, where the team set up project organization and task assignments.
  • Scrum 10/28.pdf: Reviews the first sprint's progress, including database interaction and basic feature implementation like the login page.
  • Scrum 11/4.pdf: Reflects on Sprint 1 accomplishments, detailing progress on manager and cashier views, and planning for Sprint 2.
  • Scrum 11/6.pdf: Discusses planning for Sprint 2, task assignments, and issues to address during the next phase of development.
  • Scrum 11/13.pdf: Updates the team on tasks for accessibility, styling, and APIs, as well as refining views and functionality.
  • Scrum 11/18.pdf: Focuses on progress with the shopping cart and manager view, along with accessibility improvements.
  • Scrum 11/20.pdf: Marks the completion of shopping cart functionality, Google authentication, and plans for dynamic pricing.
  • Scrum 11/22.pdf: Discusses major updates, including the manager view and additional features like chatbot API integration.
  • Scrum 11/25.pdf: A final check-in before the presentation, focusing on completing and testing tasks, especially related to the manager view and chatbot dataset.

public/:

Contains all image assets used across the project, including menu items, weather icons, and system graphics.

  • Menu Items:

    • ApplePieRoll.png: Image of Panda Express Apple Pie Roll dessert.
    • BeijingBeef.png: Beijing Beef dish with crispy beef and peppers.
    • BlackPepperSirloinSteak.png: Black Pepper Sirloin Steak entree.
    • BroccoliBeef.png: Broccoli and beef entree.
    • ChickenEggRoll.png: Fried Chicken Egg Rolls.
    • ChowMein.png: Panda Express Chow Mein side dish.
    • CreamCheeseRangoon.png: Cream Cheese Rangoons appetizer.
    • Dumplings.png: Dumplings served as an appetizer.
    • FriedRice.png: Classic Fried Rice side dish.
    • GrilledTeriyakiChicken.png: Grilled Teriyaki Chicken entree.
    • HoneySesameChickenBreast.png: Honey Sesame Chicken Breast entree.
    • HoneyWalnutShrimp.png: Honey Walnut Shrimp entree.
    • HotOnesBlazingBourbonChicken.png: Blazing Bourbon Chicken entree from Hot Ones.
    • KungPaoChicken.png: Kung Pao Chicken entree with peanuts and veggies.
    • MushroomChicken.png: Mushroom Chicken entree with vegetables.
    • StringBeanChickenBreast.png: String Bean Chicken Breast entree.
    • SweetFireChickenBreast.png: Sweet Fire Chicken Breast entree with pineapple.
    • TheOriginalOrangeChicken.png: Iconic Original Orange Chicken entree.
    • VeggieOrangeChicken.png: Plant-based Veggie Orange Chicken entree.
    • VeggieSpringRoll.png: Fried Veggie Spring Rolls served as an appetizer.
    • WhiteSteamedRice.png: Classic White Steamed Rice side dish.
  • Drinks:

    • Coca-Cola.png: Glass of Coca-Cola.
    • DietCoke.png: Glass of Diet Coke.
    • IcedTea.png: Glass of iced tea.
    • MinuteMaidLemonade.png: Glass of Minute Maid Lemonade.
    • Sprite.png: Glass of Sprite.
    • FantaOrange.png: Glass of Fanta Orange soda.
    • BottledWater.png: Bottled water available in Panda Express.
  • Weather Icons:

    • cloudy.png: Icon representing cloudy weather.
    • rainy.png: Icon representing rainy weather.
    • sunny.png: Icon representing sunny weather.
  • Other Pictures:

    • a_la_carte.png: Represents the customizable a la carte menu.
    • bigger_plate.png: Panda Express Bigger Plate combination image.
    • Bowl.png: Example of a Panda Express bowl option.
    • ShoppingCart.png: Icon representing a shopping cart.
    • MenuBoard.png: Screenshot of the Panda Express menu board.
    • Plate.png: Example of a Panda Express plate option.

src/app:

  • _components/:

    • login.js: Manages Google Login, decodes JWT tokens, and fetches employee data from the backend.
    • logout.js: Handles Google Logout by clearing session data and providing user feedback.
    • shoppingCart.tsx: Displays and manages the shopping cart, including item adjustments and dynamic price updates.
    • shoppingData.tsx: Manages the data structure and logic for items in the shopping cart, including quantity updates and data synchronization.
  • api/:

    • chatBot/:

      • route.ts:
        • Function: POST(req: Request)
          • Purpose: Handles POST requests to the API route, processes user input, and returns a response from the OpenAI API.
          • Parameters:
            • req (Request): The incoming HTTP request object containing the user's message in the body.
          • Logic:
            1. Parses the request body to extract the message field.
            2. Validates the presence of the message. If missing, returns a 400 Bad Request response with an error message.
            3. Sends the message to the OpenAI API using the fine-tuned GPT-3.5-turbo model.
            4. Retrieves the assistant's reply from the API response.
            5. If the reply is missing, returns a 500 Internal Server Error response with an error message.
            6. Returns the generated reply in a JSON response.
          • Error Handling:
            • Logs errors to the console and returns a 500 Internal Server Error response if the request fails.
    • checkout/:

      • route.ts:
        • Function: POST(request: Request)
          • Purpose: Processes a list of food items from the request, decrements their quantities in the database, and handles errors with transaction management.
          • Parameters:
            • request (Request): The incoming HTTP request containing a JSON array of food names.
          • Logic:
            1. Establishes a connection to the PostgreSQL database using a connection pool.
            2. Begins a transaction with BEGIN.
            3. Iterates through the array of food names from the request body:
              • Executes an UPDATE query to decrement the quantity of each food item.
              • Throws an error if the food item is not found in the database.
            4. Commits the transaction if all updates succeed.
            5. Rolls back the transaction if any error occurs during processing.
            6. Releases the database client after the operation.
            7. Returns a success message or an error response depending on the outcome.
          • Error Handling:
            • Logs and rolls back the transaction on errors during processing.
            • Logs errors in establishing database connections or transaction handling.
            • Returns a 500 Internal Server Error response if the operation fails.
    • decrementIngredients/:

      • route.ts:
        • Function: POST(request: Request)
          • Purpose: Processes a list of customer orders, retrieves the ingredients required for each food item, and updates the ingredient inventory in the database.
          • Parameters:
            • request (Request): The incoming HTTP request containing a JSON object with an orders array.
          • Logic:
            1. Extracts the orders array from the request body.
            2. Establishes a connection to the PostgreSQL database using a connection pool.
            3. Begins a transaction with BEGIN.
            4. Iterates through each order and its associated items:
              • Retrieves the food_id for each item.
              • Fetches the ingredient_id for all ingredients required for the food item.
              • Decrements the quantity of each ingredient in the database.
            5. Commits the transaction if all updates succeed.
            6. Rolls back the transaction if an error occurs during processing.
            7. Releases the database client after the operation.
            8. Returns a success message or an error response depending on the outcome.
          • Error Handling:
            • Logs errors encountered during database interactions or transaction handling.
            • Returns a 500 Internal Server Error response if the operation fails.
    • employeeLookup/:

      • route.ts:
        • Function: POST(request: Request)
          • Purpose: Looks up an employee in the database by email and returns their details.
          • Parameters:
            • request (Request): The incoming HTTP request containing a JSON object with an email field.
          • Logic:
            1. Extracts the email field from the request body.
            2. Validates the presence of the email. If missing, returns a 400 Bad Request response.
            3. Queries the employees table in the database for the provided email.
            4. If a match is found, returns the employee's details (employee_id, name, position, email) in a JSON response.
          • Error Handling:
            • If no match is found, returns a 404 Not Found response.
            • Handles errors by logging them and returning a 500 Internal Server Error response.
    • fetchAppetizers/:

      • route.ts:
        • Function: GET()
          • Purpose: Fetches all food items categorized as "appetizers" from the database.
          • Logic:
            1. Executes a parameterized SQL query to select all records from the food table where type = 'appetizer'.
            2. Returns the list of appetizers in a JSON response.
          • Error Handling:
            • Logs errors and returns a 500 Internal Server Error response if the query fails.
    • fetchDrinks/:

      • route.ts:
        • Function: GET()
          • Purpose: Fetches all food items categorized as "drinks" from the database.
          • Logic:
            1. Executes a parameterized SQL query to select all records from the food table where type = 'drink'.
            2. Returns the list of drinks in a JSON response.
          • Error Handling:
            • Logs errors and returns a 500 Internal Server Error response if the query fails.
    • fetchEmployees/:

      • route.ts:
        • Function: GET()
          • Purpose: Fetches all employee records from the database.
          • Logic:
            1. Executes a SQL query (SELECT * FROM employees;) to retrieve all rows from the employees table.
            2. Returns the list of employees in a JSON response.
          • Error Handling:
            • Logs errors and returns a 500 Internal Server Error response if the query fails.
    • fetchEntrees/:

      • route.ts:
        • Function: GET()
          • Purpose: Fetches all food items categorized as "entrees" from the database.
          • Logic:
            1. Executes a parameterized SQL query to select all records from the food table where type = 'entree'.
            2. Returns the list of entrees in a JSON response.
          • Error Handling:
            • Logs errors and returns a 500 Internal Server Error response if the query fails.
    • fetchInventory/:

      • route.ts:
        • Function: GET()
          • Purpose: Fetches all ingredient records from the database.
          • Logic:
            1. Executes a SQL query (SELECT * FROM ingredients;) to retrieve all rows from the ingredients table.
            2. Returns the list of ingredients in a JSON response.
          • Error Handling:
            • Logs errors and returns a 500 Internal Server Error response if the query fails.
    • fetchItemIngredientCount/:

      • route.ts:
        • Function: GET()
          • Purpose: Fetches the total number of ingredients used in each menu item from the database.
          • Logic:
            1. Executes a SQL query that joins the Food, Food_Ingredients, and Ingredients tables to count the number of ingredients associated with each menu item (Food_Name).
            2. Groups the results by Food_Name to calculate the total ingredients used per menu item.
            3. Returns the results in a JSON response.
          • Error Handling:
            • Logs errors and returns a 500 Internal Server Error response if the query fails.
    • fetchPeakSalesDay/:

      • route.ts:
        • Function: GET()
          • Purpose: Fetches the top 10 days with the highest total sales from the database.
          • Logic:
            1. Executes a SQL query that:
              • Groups transactions by their date (Transaction_Date).
              • Sums the total prices (Total_Price) of transactions for each date.
              • Orders the results in descending order of total sales.
              • Limits the results to the top 10 days with the highest sales.
            2. Returns the results in a JSON response.
          • Error Handling:
            • Logs errors and returns a 500 Internal Server Error response if the query fails.
    • fetchRealisticSalesHistory/:

      • route.ts:
        • Function: GET()
          • Purpose: Fetches hourly sales data, including total orders and revenue, grouped by hour of the day.
          • Logic:
            1. Executes a SQL query that:
              • Extracts the hour from the transaction time (Time).
              • Groups transactions by the hour of the day.
              • Counts the total number of transactions (Transaction_ID) for each hour.
              • Sums the total prices (Total_Price) of transactions for each hour.
              • Orders the results by the hour of the day.
            2. Returns the results in a JSON response.
          • Error Handling:
            • Logs errors and returns a 500 Internal Server Error response if the query fails.
    • fetchSides/:

      • route.ts:
        • Function: GET()
          • Purpose: Fetches all food items categorized as "sides" from the database.
          • Logic:
            1. Executes a parameterized SQL query to select all records from the food table where type = 'side'.
            2. Returns the list of sides in a JSON response.
          • Error Handling:
            • Logs errors and returns a 500 Internal Server Error response if the query fails.
    • fetchSizes/:

      • route.ts:
        • Function: GET()
          • Purpose: Fetches all size records from the database.
          • Logic:
            1. Executes a SQL query (SELECT * FROM sizes;) to retrieve all rows from the sizes table.
            2. Returns the list of sizes in a JSON response.
          • Error Handling:
            • Logs errors and returns a 500 Internal Server Error response if the query fails.
    • fetchWeather/:

      • route.ts:
        • Function: GET(request: Request)
          • Purpose: Retrieves current weather information for a specified city.
          • Logic:
            1. Parses the city name from the query parameters in the request URL.
            2. Validates the presence of the city parameter.
            3. Fetches the latitude and longitude for the city using the open-meteo geocoding API.
            4. Fetches the current weather data for the city's coordinates using the open-meteo weather API.
            5. Maps the weather condition to an appropriate icon URL and structures the response.
            6. Returns the weather data as a JSON object.
          • Error Handling:
            • Returns a 400 Bad Request if the city parameter is missing.
            • Logs errors and returns a 500 Internal Server Error response for failures during geolocation or weather data fetching.
    • fetchWeeklySalesHistory/:

      • route.ts:
        • Function: GET()
          • Purpose: Retrieves the weekly sales history, including the total number of orders grouped by week number.
          • Logic:
            1. Executes a SQL query that:
              • Extracts the week number from the Transaction_Date field using EXTRACT(WEEK FROM Transaction_Date).
              • Groups transactions by week number.
              • Counts the total number of transactions (Transaction_ID) for each week.
              • Orders the results by week number in ascending order.
            2. Returns the grouped data as a JSON response.
          • Error Handling:
            • Logs errors and returns a 500 Internal Server Error response if the query fails.
    • fetchXReport/:

      • route.ts:
        • Function: GET()
          • Purpose: Generates an X-Report summarizing hourly sales and the top employee for each hour on a specific transaction date.
          • Logic:
            1. Defines a WITH query using two Common Table Expressions (CTEs):
              • RankedEmployees:
                • Calculates the total orders and sales for each employee grouped by the hour of the day.
                • Ranks employees for each hour based on the number of orders they handled.
              • HourlyTotals:
                • Aggregates total sales for each hour of the specified transaction date.
            2. Joins the CTEs to retrieve the top-ranked employee for each hour along with the total sales.
            3. Formats the total_sales_for_hour field as a string with two decimal places.
            4. Returns the report as a JSON response.
          • Error Handling:
            • Logs errors and returns a 500 Internal Server Error response if the query or formatting fails.
    • fetchZReport/:

      • route.ts:
        • Function: GET()
          • Purpose: Generates a Z-Report summarizing total sales for the day and details about the top-performing employee.
          • Logic:
            1. Defines a WITH query using two Common Table Expressions (CTEs):
              • DaySummary:
                • Groups transactions by employee and calculates the total orders and sales for each employee.
                • Assigns a rank to each employee based on the number of orders they handled (descending).
              • TotalSalesForDay:
                • Calculates the total sales for the specified transaction date.
            2. Combines the CTEs to retrieve the top-ranked employee and the total sales for the day.
            3. Returns the report as a JSON response.
          • Error Handling:
            • Logs errors and returns a 500 Internal Server Error response if the query fails.
            • Returns a message if no transactions are found for the specified date.
    • finishCashierTransaction/:

      • route.ts:
        • Function: POST(req: Request)

          • Purpose: Submits a new transaction, including associated orders and food items, to the database.
          • Logic:
            1. Parses the transaction details (employeeId, orders, and totalPrice) from the request body.
            2. Begins a database transaction to ensure all operations are atomic.
            3. Retrieves and increments the last transaction_id from the transactions table.
            4. Inserts the transaction details into the transactions table.
            5. Retrieves and increments the last order_id from the orders table.
            6. For each item in the order:
              • Fetches the corresponding food_id from the food table.
              • Calculates the price for premium or appetizer items.
              • Inserts the order details into the orders table with the incremented order_id.
            7. Commits the transaction if all operations are successful.
            8. Rolls back the transaction if an error occurs.
            9. Returns the transaction ID and a success message as a JSON response.
          • Error Handling:
            • Rolls back the transaction on any error during database operations.
            • Logs errors and returns a 500 Internal Server Error response with an appropriate message.
        • Function: getSizeId(size: string): number

          • Purpose: Maps size names (e.g., "Bowl", "Plate") to their corresponding size IDs.
          • Logic:
            • Uses a switch statement to return the appropriate size ID.
            • Throws an error if the size is invalid.
    • appetizers/:

      • page.tsx:
        • Component: Appetizers

          • Purpose: Displays available appetizers, allows customers to select an appetizer, and adds it to the shopping cart.
          • Logic:
            • Fetches appetizers using /api/fetchAppetizers API.
            • Updates the shopping cart with the selected appetizer and its price.
            • Highlights the selected appetizer with a visual indicator.
          • State Variables:
            • appetizers: Array of appetizers fetched from the backend.
            • selectedAppetizer: Tracks the currently selected appetizer.
            • shoppingData: Context for managing cart data, including items and total price.
        • Function: removeSpace(str: string)

          • Purpose: Removes spaces from a string (used to format image file paths).
          • Logic:
            • Uses str.replace(/\s/g, '') to replace all spaces with an empty string.
        • Function: useEffect (Fetching Appetizers)

          • Purpose: Fetches appetizer data from the backend when the component mounts.
          • Logic:
            1. Sends a GET request to /api/fetchAppetizers.
            2. Updates the appetizers state with the fetched data.
        • Function: handleAppetizerSelect(foodId: number)

          • Purpose: Toggles the selection of an appetizer by its food_id.
          • Logic:
            • If the clicked appetizer is already selected, deselect it.
            • Otherwise, set it as the selected appetizer.
        • Function: handleAddToCart()

          • Purpose: Adds the selected appetizer to the shopping cart.
          • Logic:
            1. Finds the currently selected appetizer from the appetizers array.
            2. Updates shoppingData:
              • Increments the total price by $2.
              • Adds the selected appetizer (formatted as food_name + "/a") to the cart.
            3. Deselects the appetizer after adding it to the cart.
  • cashierView/:

    • page.tsx:
      • Component: CashierView

        • Purpose: Renders the cashier interface for managing customer orders and transactions.
        • Logic:
          • Displays tabs for menu categories (sides, entrees, appetizers, drinks).
          • Handles order creation, size selection, item addition, and transaction submission.
          • Integrates with backend APIs for fetching menu items and submitting transaction data.
        • State Variables:
          • activeTab: Tracks the currently selected menu tab.
          • selectedSize: The chosen size for the current order.
          • currentOrder: Stores items added to the current order.
          • previousOrders: Maintains a list of completed orders in the current transaction.
          • totalCost: Accumulates the total transaction cost.
          • currentOrderSubtotal: Tracks the subtotal for the current order.
          • items: Holds the fetched menu items for the selected tab.
          • loading: Indicates loading state for menu item fetching.
          • error: Stores any errors encountered during item fetching.
          • isALaCarte: Determines if the current order is "A La Carte."
      • Function: useEffect (Fetching Menu Items)

        • Purpose: Fetches menu items for the active tab (e.g., sides, entrees) when the tab changes.
        • Logic:
          1. Determines the API endpoint based on the active tab.
          2. Fetches menu data and processes it to mark item availability.
          3. Updates the items state or sets an error message.
      • Function: handleTabChange(tab: string)

        • Purpose: Changes the active menu tab and resets the item state.
        • Logic:
          • Sets the new active tab.
          • Resets the items state and error state.
          • Triggers the loading state for fetching new data.
      • Function: handleSizeSelection(size: 'Bowl' | 'Plate' | 'Bigger Plate' | 'A La Carte')

        • Purpose: Selects the size for the current order and resets order-specific states.
        • Logic:
          1. Updates selectedSize and initializes the currentOrder.
          2. Sets the base price for the selected size.
          3. Updates the total transaction cost.
      • Function: handleAddToOrder(item: Food)

        • Purpose: Adds a selected item to the current order.
        • Logic:
          1. Checks if the item can be added based on size limits and availability.
          2. Calculates additional costs for premium items, appetizers, drinks, and "A La Carte" pricing.
          3. Updates currentOrder, currentOrderSubtotal, and totalCost.
      • Function: handleSubmitOrder()

        • Purpose: Submits the current order after validating size and item requirements.
        • Logic:
          1. Ensures the order meets size limits or is "A La Carte."
          2. Alerts the cashier if more items are needed.
          3. Finalizes the order by adding it to previousOrders and resetting the order state.
      • Function: handleFinishTransaction()

        • Purpose: Finalizes the transaction by submitting all orders and updating the backend.
        • Logic:
          1. Checks if there are orders to submit.
          2. Sends the transaction data to the backend via the /api/finishCashierTransaction endpoint.
          3. Updates inventory ingredient quantities by calling /api/decrementIngredients.
          4. Resets all transaction-related states.
      • Function: handleReset()

        • Purpose: Resets the current order without affecting the total transaction cost.
        • Logic:
          • Clears the selected size and current order.
          • Deducts the current order subtotal from the total cost.
  • chatBotView/:

    • page.tsx:
      • Component: Chatbot

        • Purpose: Provides an interactive chatbot UI for user input and bot responses.
        • Logic:
          • Accepts user input via a text field.
          • Sends the input to the chatbot API (/api/chatBot) for processing.
          • Displays the conversation history with styled messages for the user and bot.
          • Supports toggling between minimized and expanded states.
      • Function: handleInputChange

        • Purpose: Updates the state with the user's input.
        • Logic:
          1. Captures the value entered in the text input field.
          2. Updates the input state with the new value.
      • Function: handleSubmit

        • Purpose: Sends the user's message to the chatbot API and displays the response.
        • Logic:
          1. Validates that the input is not empty.
          2. Sends a POST request to the /api/chatBot endpoint with the message.
          3. Parses the response and appends both the user's message and the bot's reply to the responses state.
          4. Clears the input field after submission.
          5. Handles errors by displaying an error message in the chat window.
      • Function: toggleMinimize

        • Purpose: Toggles the chatbot UI between minimized and expanded states.
        • Logic:
          1. Updates the isMinimized state to show or hide the chat content.
  • customerView/:

    • page.tsx:
      • Component: CustomerView

        • Purpose: Enables customers to view and choose meal sizes while dynamically updating the shopping data context for the selected size.
        • Logic:
          • Fetches meal size data from the /api/fetchSizes endpoint on component load.
          • Displays meal size options as clickable cards.
          • Updates the shopping data context to reflect the selected size, price, and number of entrees.
          • Redirects customers to the sides selection page upon choosing a size.
      • Function: useEffect

        • Purpose: Fetches meal size data from the server when the component is mounted.
        • Logic:
          1. Sends a GET request to /api/fetchSizes.
          2. Stores the fetched data in the sizes state.
          3. Handles potential errors by logging them to the console.
      • Function: changeShoppingData (via Link click handler)

        • Purpose: Updates the shopping data context with the selected size details.
        • Logic:
          1. Determines the selected size based on size_id.
          2. Updates the shopping data context (shoppingData) with:
            • Number of entrees (numEntrees).
            • Current price (currentPrice).
            • Selected size ID (size).
  • drinks/:

    • page.tsx:
      • Component: Drinks

        • Purpose: Displays a list of drink options for customers to select and add to their shopping cart.
        • Logic:
          • Fetches drink data from the /api/fetchDrinks endpoint on component load.
          • Displays each drink as a card with its image, name, calorie count, and availability status.
          • Updates the shopping cart context upon selecting a drink.
      • Function: useEffect

        • Purpose: Fetches the list of drinks from the backend when the component is mounted.
        • Logic:
          1. Sends a GET request to /api/fetchDrinks.
          2. Processes the response and stores the drink data in the drinks state.
          3. Logs the fetched data for debugging purposes.
      • Function: removeSpace

        • Purpose: Removes spaces from a string to generate valid file paths for images.
        • Logic:
          1. Accepts a string as input.
          2. Replaces all spaces with empty strings.
          3. Returns the modified string.
      • Function: handleDrinkSelect

        • Purpose: Toggles the selection of a drink.
        • Logic:
          1. Checks if the selected drink is already active.
          2. Toggles selection by updating the selectedDrink state.
      • Function: handleAddToCart

        • Purpose: Adds the selected drink to the shopping cart.
        • Logic:
          1. Finds the selected drink in the drinks state using the selectedDrink ID.
          2. Updates the shoppingData context:
            • Increments the current price by $2.
            • Appends the selected drink to the cart items.
          3. Resets the selectedDrink state.
  • employees/:

    • page.tsx:
      • Component: EmployeesPage

        • Purpose: Displays a list of employees with details such as name, position, gender, and salary in a card format.
        • Logic:
          • Fetches employee data from the /api/fetchEmployees endpoint when the component mounts.
          • Maps the fetched data to display employee information in individual cards.
      • Function: useEffect

        • Purpose: Fetches the list of employees from the backend on component mount.
        • Logic:
          1. Sends a GET request to /api/fetchEmployees.
          2. Parses the response JSON to retrieve employee data.
          3. Updates the employees state with the retrieved data.
          4. Logs any errors that occur during the fetch.
  • entrees/:

    • page.tsx:
      • Component: Entrees

        • Purpose: Displays a list of entree items for selection and integrates with the shopping cart to manage selections.
      • Function: useEffect

        • Purpose: Fetches entree data from the server upon component mount.
        • Logic:
          1. Sends a GET request to /api/fetchEntrees.
          2. Parses the response JSON to retrieve entree data.
          3. Updates the entrees state with the fetched data.
      • Function: removeSpace

        • Purpose: Removes spaces from a string (used to format file paths for images).
        • Logic:
          • Takes a string as input and returns a new string with all spaces removed.
      • Function: handleEntreeSelect

        • Purpose: Handles the selection of an entree.
        • Logic:
          • Toggles selection of the entree when clicked.
          • Allows only one entree to be selected at a time.
      • Function: handleAddToCart

        • Purpose: Adds the selected entree to the shopping cart.
        • Logic:
          1. Checks if an entree is selected and available.
          2. Adjusts the price based on:
            • Premium status.
            • Meal size.
          3. Updates the shopping cart context with the selected entree and updated price.
          4. Resets the selectedEntree state to null.
  • inventory/:

    • page.tsx:
      • Component: InventoryPage

        • Purpose: Provides an overview of the ingredient inventory, including their names and quantities.
      • Function: useEffect

        • Purpose: Fetches ingredient data from the server upon component mount.
        • Logic:
          1. Sends a GET request to /api/fetchInventory.
          2. Parses the response JSON to retrieve ingredient data.
          3. Updates the ingredients state with the fetched data.
          4. Handles and logs errors if the API call fails.
  • itemIngredientCount/:

    • page.tsx:
      • Component: ItemIngredientCountPage

        • Purpose: Provides a breakdown of the number of ingredients used for each menu item.
      • Function: useEffect

        • Purpose: Fetches menu item ingredient count data from the server upon component mount.
        • Logic:
          1. Sends a GET request to /api/fetchItemIngredientCount.
          2. Parses the response JSON to retrieve menu item data.
          3. Updates the items state with the fetched data.
          4. Handles and logs errors if the API call fails.
  • managerView/:

    • page.tsx:
      • Component: ManagerView

        • Purpose: To provide a comprehensive dashboard for managers to manage and monitor business operations.
      • Function: fetchData

        • Purpose: Fetches data for the active tab when the tab changes.
        • Logic:
          • Determines the API endpoint based on the activeTab.
          • Fetches data and updates the corresponding state variable.
          • Handles errors gracefully by logging them.
      • Function: handleTabChange

        • Purpose: Changes the active tab.
        • Logic:
          • Updates the activeTab state to the selected tab.
      • Function: handleUpdatePrice

        • Purpose: Updates the price of a menu item based on the input.
        • Logic:
          • Sends a POST request with the new price and size ID.
          • Updates the local state with the new price.
  • menuBoardView/:

    • page.tsx:
      • Component: MenuBoardView

        • Purpose: Displays the full menu board for users in an organized and visually appealing format.
      • Function: foodDisplaySquare

        • Purpose: Creates a visual display for a single menu item, including its image and name.
        • Parameters:
          • urlName: A string representing the URL of the menu item's image.
          • name: A string representing the menu item's name.
        • Return Value: A JSX element displaying the menu item's image and name in a styled container.
  • peakSalesDay/:

    • page.tsx:
      • Component: PeakSalesDayPage
        • Purpose: Displays a historical list of peak sales days and their associated revenue.
        • Features:
          • Fetches peak sales data from the /api/fetchPeakSalesDay endpoint.
          • Renders the sales date and total revenue for each record in a visually appealing card format.
  • realisticSalesHistory/:

    • page.tsx:
      • Component: RealisticSalesHistoryPage
        • Purpose: Presents a breakdown of sales data on an hourly basis, including the number of orders and revenue for each hour.
        • Features:
          • Fetches sales history data from the /api/fetchRealisticSalesHistory endpoint.
          • Displays the data in responsive cards for each hour of the day.
  • sides/:

    • page.tsx:
      • Component: Sides
        • Purpose: Displays available sides and allows customers to add selected sides to their shopping cart.
        • Features:
          • Fetches sides data dynamically from the API.
          • Supports interactive selection and visual feedback for selected items.
          • Integrates with a global shopping cart context to track selected items.
  • weather/:

    • page.tsx:

      • Component: Sides
        • Purpose: Displays available sides and allows customers to add selected sides to their shopping cart.
        • Features:
          • Fetches sides data dynamically from the API.
          • Supports interactive selection and visual feedback for selected items.
          • Integrates with a global shopping cart context to track selected items.
    • WeatherWidget.tsx:

      • Component: WeatherWidget
        • Purpose: Displays current weather data for College Station in a compact widget.
        • Features:
          • Fetches weather data from an API endpoint.
          • Handles errors gracefully with user-friendly messages.
          • Displays weather details, including temperature, condition, and an icon.
  • weeklySalesHistory/:

    • page.tsx:
      • Component: WeeklySalesHistoryPage
        • Purpose: Fetch and display the weekly sales history, including the total orders processed for each week.
        • Features:
          • Dynamically fetches sales data for each week.
          • Displays the data in a grid layout with a card for each week.
          • Provides responsive design and hover effects for a polished look.
  • xReport/:

    • page.tsx:
      • Component: XReportPage
        • Purpose: Fetch and display hourly sales and employee data for the X Report.
        • Features:
          • Retrieves hourly sales data and the top-performing employee for each hour.
          • Renders the data in an intuitive card-based layout.
  • zReport/:

    • page.tsx:
      • Page is not used.

Root Files:

The root directory contains configuration and setup files essential for managing and running the Panda Express POS project. Below is a detailed description of each file:

  • .env: Environment configuration file for storing sensitive data like API keys and environment variables.
  • .eslintrc.json: ESLint configuration file that enforces coding standards and best practices for the project.
  • .gitignore: A file specifying files and directories to be ignored by Git.
  • next.config.ts: A configuration file for customizing the Next.js framework.
  • next-env.d.ts: A TypeScript declaration file for enabling type definitions specific to Next.js.
  • package.json: Metadata file for managing the project's dependencies, scripts, and settings.
  • package-lock.json: Locks the exact versions of dependencies installed, ensuring consistency across environments.
  • postcss.config.mjs: Configures PostCSS for processing CSS files and enabling Tailwind CSS.
  • README.md: A markdown file providing a high-level overview of the project.
  • tailwind.config.ts: Tailwind CSS configuration file for customizing the framework’s styling.
  • tsconfig.json: The TypeScript configuration file.
  • upload.py: A Python script used for uploading datasets and fine-tuning models using OpenAI's API.