The Ocha API stores its data in MongoDB through five Mongoose models:Documentation Index
Fetch the complete documentation index at: https://mintlify.com/floriansalvi/HEIG-VD_Ocha-api/llms.txt
Use this file to discover all available pages before exploring further.
User, Product, Store, Order, and OrderItem. Each model defines the shape of its documents, enforces validation rules, and controls which fields are exposed in API responses. The sections below document every field for each model as defined in the source schemas.
User
AUser represents a registered account. Passwords are hashed with bcrypt before storage and are excluded from all query results via select: false.
MongoDB-generated unique identifier for the user document.
The user’s email address. Stored in lowercase. Must be unique across all accounts.
The user’s chosen display name. Must be unique across all accounts.
Optional phone number. Not validated against a format at the schema level.
Access level for the account. Accepted values:
user, admin. Determines which protected endpoints the account can reach.Bcrypt-hashed password. This field is excluded from all query results (
select: false) and is never returned by the API.Timestamp set automatically when the account is created.
Example User document
The
password field is never included in API responses. Do not attempt to read it from returned JSON.Product
AProduct represents a menu item available in Ocha stores. Products have size variants with per-size price surcharges. Mongoose timestamps adds createdAt and updatedAt automatically.
MongoDB-generated unique identifier.
URL-safe unique identifier derived from the product name. Generated automatically.
Human-readable product name. Must be unique.
Product category (e.g.,
"matcha latte", "cold brew").Full text description of the product.
Base price in Swiss francs. Minimum value:
0. The final price for a given size is basePriceCHF + extra_chf[size].Controls visibility. When
false, the product is excluded from the active products listing (GET /products?active=true).Cloudinary URL pointing to the product image.
Array of available sizes for this product. Each value must be one of
S, M, or L.Per-size price surcharge in CHF added on top of
basePriceCHF.Automatically managed by Mongoose
timestamps.Automatically managed by Mongoose
timestamps. Updated on every save.Example Product document
Store
AStore represents a physical Ocha matcha shop location. Coordinates are stored as a GeoJSON Point to enable geospatial queries via the $near operator. The slug is generated automatically from name using slugify.
MongoDB-generated unique identifier.
Store display name. Must be unique and between 3 and 50 characters long.
URL-safe unique identifier generated from
name. Lowercased and auto-updated when name changes.Contact email for the store. Must be unique and pass email format validation.
Optional contact phone number. Validated as a valid mobile phone number if provided.
Physical mailing address of the store.
GeoJSON Point used for geospatial proximity queries.
Whether the store is currently active. Inactive stores are excluded from nearby-store queries.
Array of exactly 7 entries, one per day of the week starting from Sunday (index 0). Each entry is either an empty array
[] (store closed that day) or a two-element array ["HH:MM", "HH:MM"] representing opening and closing times in 24-hour format.Default: Sunday closed, Monday–Saturday ["09:00", "17:00"].Timestamp set when the store document is first created.
Timestamp updated automatically on every save via a
pre('save') hook.Example Store document
coordinates follows the GeoJSON convention of [longitude, latitude] — longitude first, latitude second.Order
AnOrder groups items purchased by a user at a specific store for a scheduled pickup. Mongoose timestamps adds createdAt and updatedAt automatically.
MongoDB-generated unique identifier.
Reference to the
User who placed the order.Reference to the
Store where the order will be picked up.Current lifecycle state of the order. Accepted values:
"en préparation"— order received, being prepared"prête"— order ready for pickup"récupérée"— order collected by the customer
Scheduled date and time for the customer to collect the order.
Total cost of the order in Swiss francs. Minimum value:
0.Automatically managed by Mongoose
timestamps.Automatically managed by Mongoose
timestamps.Example Order document
OrderItem
AnOrderItem represents a single product line within an Order. Prices are snapshotted from the Product at creation time via a pre('validate') hook, so they remain accurate even if the product price changes later.
MongoDB-generated unique identifier.
Reference to the parent
Order.Reference to the
Product being ordered.Snapshot of the product’s
name at the time the item was created. Preserved even if the product is later renamed.Selected size for this line item. Must be one of
S, M, or L.Number of units ordered. Minimum:
1, maximum: 100.Snapshot of the product’s
basePriceCHF at order creation time.Snapshot of the size surcharge (
extra_chf[size]) from the product at order creation time.Total unit price:
base_price_chf + extra_chf. Computed automatically before validation.Automatically managed by Mongoose
timestamps.Automatically managed by Mongoose
timestamps.Example OrderItem document
base_price_chf, extra_chf, and final_price_chf are computed and stored at creation time. They are not recalculated if the underlying product changes after the order is placed.