---
# System prepended metadata

title: PlateHero B/E Entities

---

# PlateHero B/E Entities

## Entities
### Addresses
- Stores all the addresses
### Cuisines
- What cuisine a kitchen cooks
- Cuisines exist globally and chefs can assign them to their kitchen
- Example: `mexican`, `italian`
### Delivery Orders
- A delivery order user ordered via subscription
- Is delivered on the specific day
- Might contain multiple order collections (each order collection is from different chef)
### *Order Collection*
- Chef's collection of orders that is delivered to the user
- Is groupped by `pickUpDate`
- Might contain `X` orders depending on the subscription selected
- Might contain multiple dishes
- Example:
    - User selects a subscription of 5 orders
    - User chooses 3x Burger and 2x Spaghetti
        - 5 orders
        - 2 dishes
### Dish Labels
- Dish labels exist globally and chefs can assign them to their dishes within the kitchen
- Example:
    - Type `ALLERGEN` -> `wheat`, `eggs`, `fish`
    - Type `DIET` -> `gluten free`, `vegetarian`, `halal` 

### Dishes
- Specific dish a kitchen cooks
    - Example: Burger, Spaghetti
### Images
- Image uploaded to GCP Bucket
- B/E stores path to the file
### Kitchens
- Chef is a user that has a kitchen
### Orders
- An order to the chef
- Each portion of the dish being cooked
### Subscription Plans
- General type of the subscription user can select
- Has price and number of dishes
### Subscriptions
- Specific to the user after user selects the subscription type
- linked to the user, delivery address, delivery orders
### Reviews
- User can review a chef once within a specific delivery order
- Chef can see anonymous list of reviews
- B/E has `user` or `chef` reviews queries depending on what perspective we want to look at them
### Users
- Stores all the Platehero users (chefs and regular users)
---

## Visualization
![](https://i.imgur.com/geNodqH.png)

---

## Functionality
### Kitchen Revenue

4 Cards:
- **Total Revenue**
    - `amount`
        - total revenue of `COMPLETED` orders until **now** (`new Date()`)
    - `change`
        - change is calculated based on `Total revenue until now` and `Total Revenue until previous period`
        - Example:
            - Total revenue until start of this week is `800` and yesterday there were `2 orders COMPLETED`; chef gets `80 SEK/order`
            - `(((800 + (2*80)) - 800) / 800) * 100` => `20%`
- **Revenue this week *(Expected)***
    - `amount`
        - revenue of this **week** `COMPLETED or ACTIVE` orders
        - we take into account also the `ACTIVE` state so we do not display `0` for most of the days in the week
    - `change`
        - `((Current week revenue - Last week revenue) / Last week Revenue) * 100`
- **Revenue this month *(Expected)***
    - `amount`
        - revenue of this **month** `COMPLETED or ACTIVE` orders
    - `change`
        - `((Current month revenue - Last month revenue) / Last month Revenue) * 100`
- **Total Orders**
    - `amount`
        - total amount of `COMPLETED` orders until **now** (`new Date()`)
    - `change`
        - change is calculated based on `Total Orders until now` and `Total Orders until previous period`
        - Example:
            - Total Orders until start of this week is `10` and yesterday there were `2 orders COMPLETED`
            - `(((10 + 2) - 10) / 10) * 100` => `20%`