Database Schema - avaiaco/get-that-bread GitHub Wiki
Database Schema
Purpose
Detail the structure of the Firestore database used in the app.
Database Diagram
Visual representation of the collections and documents.
Collections and Documents
Description of each collection and the structure of its documents.
Users
- Purpose: The users collection contains user information for a single account.
- Document ID: This is the uid generated automatically to represent this document.
- Document Structure: Each document in the Users collection contains information for a user and fields for their profile and interactions within the app. A user document is structured as follows:
{
"birthday": "May 4, 2025 at 12:00:00 AM UTC-4",
"created_time": "May 4, 2025 at 11:51:42 PM UTC-4",
"display_name": "example_name",
"email": "[email protected]",
"photo_url": "image path",
"uid": "example UID"
}
Reviews
- Purpose: The reviews collection contains documents that store the information for user reviews.
- Document ID: This is the uid generated automatically to represent this document.
- Document Structure: Each document in the Reviews collection contains information for a users review and fields that describe the review's properties like rating. A user document is structured as follows:
{
"date": "May 3, 2025 at 10:42:14 PM UTC-4",
"rating": 5,
"review": "I love the app!!!!",
"uid": "/users/User123"
}
Recipes
- Purpose: The recipes collection contains documents that store the necessary information for saved user recipes.
- Document ID: This is the uid generated automatically to represent this document.
- Document Structure: Each document in the Recipes collection contains information for a saved recipe and fields that describe the recipes' properties like the ingredients. A user document is structured as follows:
{
"category": ["Dinner", "Vegetables", "All"],
"cooktime": 25,
"description": "Colorful vegetables with tamari sauce and rice"
"image": "image path"
"ingredients": "- 2 tablespoons gluten-free soy sauce (or tamari) - 1 tablespoon sesame oil (or any vegetable oil) - 1 tablespoon rice vinegar - 1 tablespoon honey or maple syrup (optional, for sweetness) - 2 garlic cloves, minced - 1 tablespoon fresh ginger, grated - 1 red bell pepper, thinly sliced - 1 yellow bell pepper, thinly sliced - 1 medium zucchini, sliced - 1 cup broccoli florets - 1 medium carrot, julienned - 1/2 cup snap peas - 1/2 cup mushrooms, sliced - 2 green onions, sliced (for garnish) - Sesame seeds (optional, for garnish)"
"name": "Vegetable Stir Fry"
"rating": 4.7
"recipe": "1. Prepare the sauce: In a small bowl, whisk together the gluten-free soy sauce, sesame oil, rice vinegar, and honey/maple syrup (if using). Set it aside. 2. Cook the veggies: Heat a large pan or wok over medium-high heat. Add a splash of oil (vegetable or sesame oil). Once the oil is hot, add the garlic and ginger. Stir-fry for about 30 seconds until fragrant. 3. Stir-fry the vegetables: Add the carrots, bell peppers, zucchini, broccoli, snap peas, and mushrooms to the pan. Stir frequently and cook for about 5-7 minutes, or until the vegetables are tender but still crisp. 4. Add the sauce: Pour the sauce over the vegetables and toss everything together to coat the veggies in the sauce. Stir-fry for another 2-3 minutes, allowing the sauce to heat through. 5. Serve: Remove from heat. Garnish with green onions and sesame seeds (if desired). 6. Enjoy: Serve the stir-fry on its own or with gluten-free rice or noodles."
}
Receipts
- Purpose: The receipts collection contains documents that store the information for user's saved receipts.
- Document ID: This is the uid generated automatically to represent this document.
- Document Structure: Each document in the receipts collection contains information for a user's saved receipts and fields that describe the receipt's properties, like receipt items. A user document is structured as follows:
{
"receipt_image": "image source",
"rceipt_items": [{"gluten_free": true, "item": "GLUTEN FREE BREAD", "price": 5.99}, {"gluten_free": true, "item": "GLUTEN FREE BREAD", "price": 5.99}]
"time_stamp": "May 5, 2025 at 4:51:51 PM UTC-4",
"uid": "XaACvRfnsQYJh3w5T53YgVrVnUF2"
}
moneyLogs
- Purpose: The moneyLogs collection contains documents that store the information for user's saved money logs.
- Document ID: This is the uid generated automatically to represent this document.
- Document Structure: Each document in the moneyLogs collection contains information for a user's saved money log and fields that describe the log's properties, like amount logged. A user document is structured as follows:
{
"amountLogged": 10,
"details": "groceries",
"owner": "/users/iidWadkvwYdnoGfZI81Snmdb9QP2",
"time_created": "May 6, 2025 at 6:05:38 PM UTC-4"
}
Fields and Data Types
Users
- Document field details
- birthday (timestamp): Time the user was born
- created_time (timestamp): Time the user created the account
- display_name (string): The display name of the user
- email (string): The email address of the user
- photo_url (string): The image path for the profile picture of the user
- uid (string): The user ID of the use account generated by Firestore
Reviews
- Document field details
- date (timestamp): Time the user wrote the review
- rating (number): Rating the user gave the app
- review (string): Review the user wrote
- userID (reference): The user ID of the user
Recipes
- Document field details
- category (array): An array of the different categories for the recipe (contains 3 strings)
- cooktime (number): The length of time it would take to cook the recipe
- description (string): A description of the recipe
- image (string): The image path for the image of the finished product
- ingredients (string): A string containing the ingredients to the recipe
- name (string): The name of the recipe
- rating (number): The average rating of the recipe
- recipe (string): The steps to the recipe
Receipts
- Document field details
- receipt_image (string): A string containing the image path for the receipt photo
- receipt_items (array): An array that contains a map of items from the receipt (including a gluten free boolean, string for the item name, and number for the price)
- time_stamp (timestamp): The time the user saved the receipt
- user_id (string): Contains the user ID of the user who saved the receipt
MoneyLogs
- Document field details
- amountLogged (number): Contains the amount of money logged by the user
- details (string): Contains the details of the money log
- owner (reference): Reference to the user ID of the user who created the log
- time_created (timestamp): Contains the timestamp of when the user saved the money log
Relationships Between Collections
- The moneyLogs and Reviews collections have a field in their documents that reference the user ID from the user collection
JSON Schema
This section displays the JSON schema of the documents within the Firestore following the 305Soft standard JSON schema format.
Users:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "User",
"description": "Schema for user documents in Firestore",
"type": "object",
"properties": {
"birthday": {
"description": "The user's birthday",
"type": "string",
"format": "date-time"
},
"created_time": {
"description": "The time when the user account was created",
"type": "string",
"format": "date-time"
},
"display_name": {
"description": "The display name of the user",
"type": "string"
},
"email": {
"description": "The email address of the user",
"type": "string",
"format": "email"
},
"photo_url": {
"description": "The URL or path of the user's profile photo",
"type": "string"
},
"uid": {
"description": "The unique identifier of the user",
"type": "string"
}
},
"required": ["birthday", "created_time", "display_name", "email", "uid"]
}
Reviews:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Review",
"description": "Schema for a review document in Firestore",
"type": "object",
"properties": {
"date": {
"description": "The timestamp of when the review was written",
"type": "string",
"format": "date-time"
},
"rating": {
"description": "Rating given by the user (typically out of 5)",
"type": "integer",
"minimum": 1,
"maximum": 5
},
"review": {
"description": "The written text of the user's review",
"type": "string"
},
"uid": {
"description": "A reference to the user document who wrote the review",
"type": "string"
}
},
"required": ["date", "rating", "review", "uid"]
}
Receipts:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Receipt",
"description": "Schema for receipt documents in Firestore",
"type": "object",
"properties": {
"receipt_image": {
"description": "A string containing the image path for the receipt photo",
"type": "string"
},
"receipt_items": {
"description": "An array of items from the receipt",
"type": "array",
"items": {
"type": "object",
"properties": {
"gluten_free": {
"description": "Whether the item is gluten free",
"type": "boolean"
},
"item": {
"description": "The name of the item",
"type": "string"
},
"price": {
"description": "The price of the item",
"type": "number",
"minimum": 0
}
},
"required": ["gluten_free", "item", "price"]
}
},
"time_stamp": {
"description": "The timestamp when the user saved the receipt",
"type": "string",
"format": "date-time"
},
"user_id": {
"description": "The user ID of the user who saved the receipt",
"type": "string"
}
},
"required": ["receipt_image", "receipt_items", "time_stamp", "user_id"]
}
Recipes:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Recipe",
"description": "Schema for a recipe document in Firestore",
"type": "object",
"properties": {
"category": {
"description": "List of categories the recipe belongs to",
"type": "array",
"items": {
"type": "string"
}
},
"cooktime": {
"description": "Time in minutes required to cook the recipe",
"type": "integer",
"minimum": 0
},
"description": {
"description": "Short description of the recipe",
"type": "string"
},
"image": {
"description": "Path or URL to the recipe image",
"type": "string"
},
"ingredients": {
"description": "List of ingredients, typically formatted as a string with line breaks or bullets",
"type": "string"
},
"name": {
"description": "Name of the recipe",
"type": "string"
},
"rating": {
"description": "Average user rating for the recipe",
"type": "number",
"minimum": 0,
"maximum": 5
},
"recipe": {
"description": "Step-by-step cooking instructions",
"type": "string"
}
},
"required": ["category", "cooktime", "description", "image", "ingredients", "name", "rating", "recipe"]
}
MoneyLogs:
{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"title": "Action",
"description": "Schema for an action or logging event in Firestore",
"type": "object",
"properties": {
"amountLogged": {
"description": "A numeric amount representing what was logged (e.g., dollars, minutes, etc.)",
"type": "number"
},
"details": {
"description": "Text describing the action or category (e.g., 'groceries')",
"type": "string"
},
"owner": {
"description": "Reference to the user document who owns this entry",
"type": "string"
},
"time_created": {
"description": "Timestamp when the action was created",
"type": "string",
"format": "date-time"
}
},
"required": ["amountLogged", "details", "owner", "time_created"]
}