> For the complete documentation index, see [llms.txt](https://docs.airdev.co/ecommerce-platform-template/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.airdev.co/ecommerce-platform-template/general-information/data-structure.md).

# Data Structure

The database structure for the template

All objects and some selected fields in the template are explained below. Please refer to our [Bubble Best Practices](https://docs.airdev.co/bubble-development-guide/steps/plan/database-structure) document for guidance on how the Bubble database should be structured.

{% hint style="warning" %}
All data types and a few select fields are explained below. A good general rule to follow is that you shouldn't delete any fields that are included with the template and instead only add new ones.
{% endhint %}

## Block entry

This data type is used to store content that goes into each homepage block. Each homepage block (template) will have a maximum number of block entries:

* Testimonials section: Multiple entries
* Featured section: Up to 3 entries
* Process section: Up to 3 entries
* Slideshow section: Between 3 to 5 entries
* Capabilities section: Up to 9 entries
* Video section: 1 entry
* Press section: Between 3 to 5 entries
* About section: 1 entry
* Call-to-action section: 1 entry
* Contact section: 0 entries

## Cart

This data type represents the shopping cart for the current user. A `Cart` can be created and used while logged in or logged out. The `Cart` essentially links the selected set of `Line items` to the current user, which are transferred to an `Order` instance when the user checks out. A user should only ever have **one unpaid** `Cart` active at a time.

| Field name | Type             | Description                                                                                                                                                                                                             |
| ---------- | ---------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Line items | Line item (list) | The list of `Line items` associated with this `Cart`. A cart should have at least **one** `Line item`. Each `Line item` is associated with exactly **one** `Product`, but with a variable `Quantity`                    |
| Paid?      | yes / no         | Signifies if the `Cart` has successfully gone through the checkout and payment process. Once a `Cart` has its `Paid?` set to **yes**, it no longer serves a functional purpose in the app and exists only for reference |
| Subtotal   | number           | The overall cost of the `Cart` before factoring in shipping costs. This is equivalent to the **sum** of each `Line item`’s `Quantity` multiplied by its `Product`’s `Price`                                             |
| Total      | number           | The total cost for the `Cart`. This is calculated by adding the shipping cost to the `Cart`’s `Subtotal`                                                                                                                |
| User       | User             | The `User` associated with the `Cart`. This can be **either** a logged in **or** logged out user (logged out users are recognized through browser cookies). When identifying the current cart                           |

## Category

This data type represents the different categorizations of `Products` on the platform. A `Category` is created, modified, and deleted all from the owner’s portal.

| Field name | Type | Description              |
| ---------- | ---- | ------------------------ |
| Name       | text | The name of the category |

## Dummy

This data type allows you to quickly preview your page layout by it as your data source.

## Feature backlog

This data type represents each feature that an Owner has added into the Backlog section of the Owner's Portal.

## Homepage block template

The data type is used for the homepage maker. App owners can add any number of homepage blocks / homepage sections straight from the owner's portal by starting from a homepage block template.

## Homepage block

App Owners can add an unlimited number of homepage blocks. They can control the content and settings from the Owner's Portal.

## Image

This data type represents a single image that is associated with a particular `Product`. This image may be a primary image or standard image for a product.

| **Field name** | Type    | Description                                                |
| -------------- | ------- | ---------------------------------------------------------- |
| Image          | image   | The actual image for this `Image` instance                 |
| Product        | Product | The `Product` that this image was added for and represents |

## Line item

This data type represents a single line item for a shopping cart. A line item essentially consists of a `Product` and a `Quantity`. Price calculations for an order come directly from the `Cart`’s `Line items`.

| Field name  | Type     | Description                                                                                                                                |
| ----------- | -------- | ------------------------------------------------------------------------------------------------------------------------------------------ |
| Cart        | Cart     | The `Cart` that this line item belongs to. A `Line item` should always be linked to a `Cart`                                               |
| Order       | Order    | The `Order` instance created from this line item’s `Cart`. This is populated after payment is processed                                    |
| Paid?       | yes / no | Indicates whether the `Line item`’s `Cart` has checked out and been paid for                                                               |
| Product     | Product  | The `Product` this line item is associated with                                                                                            |
| Quantity    | number   | The quantity of the `Product` to be ordered                                                                                                |
| Total price | number   | The total price of the line item. This is equivalent to the `Product`’s price multiplied by the line item’s `Quantity` at time of checkout |
| Unit price  | number   | The per unit price for the line item. This is equivalent to the price of the `Product` at time of checkout                                 |

## Order

This data type represents an order stemming from a user’s `Cart`. An order is created when a user successfully completes the checkout process and processes a payment. Certain fields, such as the address and CC fields, are stored for reference purposes (on order confirmation views) and to pre-populate the buyer address for future purchases.

| Field name                    | Type             | Description                                                                                                                                                                                                                                                                                                                                                                     |
| ----------------------------- | ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Address 1                     | text             | The first address line of the buyer address                                                                                                                                                                                                                                                                                                                                     |
| Address 2                     | text             | The second address line of the buyer address                                                                                                                                                                                                                                                                                                                                    |
| Cart                          | Cart             | The `Cart` this order was created from                                                                                                                                                                                                                                                                                                                                          |
| CC brand                      | text             | he name brand of the credit card used by the buyer. This is used only for the order confirmation page and reusable                                                                                                                                                                                                                                                              |
| CC last four                  | text             | The last four digits of the credit card used by the user. This is used only for the order confirmation page and reusable                                                                                                                                                                                                                                                        |
| Charge ID                     | text             | The ID of the payment processed for this order’s transaction. This value is returned from **Stripe** and corresponds with a particular payment in your Stripe dashboard                                                                                                                                                                                                         |
| City                          | text             | The city of the buyer address                                                                                                                                                                                                                                                                                                                                                   |
| Customer                      | User             | The `User` facilitating this order                                                                                                                                                                                                                                                                                                                                              |
| Line items                    | Line item (list) | The line items associated with this `Order`’s `Cart`                                                                                                                                                                                                                                                                                                                            |
| Paid?                         | yes / no         | Indicates whether this order has been paid. All `Orders` should have this field set to **yes**                                                                                                                                                                                                                                                                                  |
| Payment date                  | date             | The date that this order was processed. This should be basically equivalent to the `Order`’s `Creation` date                                                                                                                                                                                                                                                                    |
| Shipping fee                  | number           | The shipping cost used for this order. This is included in the total price calculation and may be 0                                                                                                                                                                                                                                                                             |
| State                         | text             | The state of the buyer address                                                                                                                                                                                                                                                                                                                                                  |
| Status                        | text             | The status of the order. This can be either **New**, **Shipped**, or **Cancelled**. This is only used for display and reference purposes and is updated from the owner’s portal                                                                                                                                                                                                 |
| Subtotal                      | number           | The overall cost of this order’s `Cart` before factoring in shipping costs. This is equivalent to the **sum** of each `Line item`’s `Quantity` multiplied by its `Product`’s `Price`                                                                                                                                                                                            |
| Total                         | number           | The total cost for this order’s `Cart`. This is calculated by adding the shipping cost to the `Cart`’s `Subtotal`. This is equivalent to the amount passed in for the **Charge a user using saved CC** workflow                                                                                                                                                                 |
| Total amount charged          | number           | The overall amount (in US **dollars**) that was charged in this order’s transaction. This value is returned from **Stripe**, then divided by 100 to convert to a dollar amount                                                                                                                                                                                                  |
| Total amount charged (Stripe) | number           | The overall amount (in US **cents**) that was charged in this order’s transaction. This should be equivalent to the `Total amount charged` multiplied by 100 (so essentially the total charge amount converted to cents). This value is returned from **Stripe** and populated following a successful payment for the order. This field exists primarily for reference purposes |
| Tracking number               | text             | The status of the order. This is only used for display and reference purposes and is updated from the owner’s portal                                                                                                                                                                                                                                                            |
| Zip code                      | text             | The zip code of the buyer address                                                                                                                                                                                                                                                                                                                                               |

## Palette color

This data type is color palette list is referenced in the Air Color Picker plugin / element. Feel free to add more color entries for quick access when using the Air Color Picker element.

## Product

This data type represents a product created for the platform. Products are publicly searchable and viewable and can be “purchased” by logged in users. Products are created and managed entirely from the owner’s portal.

| Field name     | Type            | Description                                                                                                                                                                                        |
| -------------- | --------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Average rating | number          | The average number of every `Review`’s `Rating` submitted for this product                                                                                                                         |
| Categories     | Category (list) | The list of `Categories` linked to this product                                                                                                                                                    |
| Description    | text            | The description of the product                                                                                                                                                                     |
| Image main     | Image           | The primary `Image` for this product                                                                                                                                                               |
| Images         | Image (list)    | The list of all the `Images` for this product. This is **inclusive** of `Image main`                                                                                                               |
| Price          | number          | The numeric price of the product. This is used to calculate order costs                                                                                                                            |
| Reviews        | Review (list)   | The list of `Reviews` created for this product                                                                                                                                                     |
| Title          | text            | The title of the product                                                                                                                                                                           |
| Total in stock | number          | The total amount of this item available for shipment. This is added during product creation, decrements each time an order with this product is placed, and can be updated from the owner’s portal |
| Told sold      | number          | The total number of units sold for this product. This is equivalent to the sum of all **paid** `Line items` whose `Product` is this product                                                        |

## Push token

This represents a unique token to be used with **OneSignal** for push notification integrations for wrapped mobile apps.

## Review

This data type represents a user-written review for a product. A `Review` is created when a user submits a review from a product's details page. A user can only review a `Product` that they've ordered at least once.

| Field name | Type    | Description                                                                                       |
| ---------- | ------- | ------------------------------------------------------------------------------------------------- |
| Product    | Product | The `Product` that this review is associated with. A user can create **one** `Review` per product |
| Rating     | number  | The numeric rating that the user has selected for this review. This can range from **1 to 5**     |
| Text       | Title   | The description/explanation for this review                                                       |
| Title      | text    | The title of this review                                                                          |

## User

The user data type represents each person who has an account in your application.

| Field name                            | Type     | Description                                                                              |
| ------------------------------------- | -------- | ---------------------------------------------------------------------------------------- |
| Date agreed to terms and privacy docs | date     | Date agreed to terms and privacy docs during sign up                                     |
| Inactive                              | yes / no | User is marked as inactive = yes when App owner deletes the user from the Owner's Portal |
| Last login                            | date     | Captures the last date that the user loaded any page in the app                          |
| Owner?                                | yes / no | If Owner is yes then they will have access to the Owner's Portal                         |
| Signup method                         | text     | E.g., E-mail, LinkedIn, Facebook, Twitter, or etc.                                       |

## Website

This data type includes fields for all app-wide settings. Most of the data fields are controlled by the App Owner from the Owner's portal. There should only be a single object of this data type.

| Field name       | Type                    | Description                                                                                                                                                                               |
| ---------------- | ----------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Ask for cookies? | yes / no                | App Owner can control whether or not to ask users to accept cookies (if yes, a cookies banner will show on the homepage)                                                                  |
| Email            | text                    | Contact / support email that all emails in the application come from. Whenever a new email action is created in the application, it should refer to this field instead of being hardcoded |
| Email HTML       | text                    | Used in the [SendGrid API call for "send emails"](https://docs.airdev.co/canvas/quickstart-guide#step-2-setting-up-your-email) that generates a nicely-formatted HTML email               |
| List of blocks   | List of homepage blocks | Homepage blocks / sections                                                                                                                                                                |
| Name             | text                    | Name of your app / website. This is the field that should be referenced anywhere where the name is used (instead of hardcoded).                                                           |
| Primary color    | text                    | App and email template primary color                                                                                                                                                      |
| Usersnap off?    | yes / no                | This turns off the Usersnap tool, which AirDev uses with its clients to submit feedback and bug reports.                                                                                  |
