The shirt-store API is built on three Mongoose models: User, Product, and Cart. Each model maps directly to a MongoDB collection, and together they capture everything from account credentials to purchase history. Understanding these schemas — and the embedded-document pattern that connects them — will help you build against the API with confidence.Documentation Index
Fetch the complete documentation index at: https://mintlify.com/fredy-rizo/Ecommerce/llms.txt
Use this file to discover all available pages before exploring further.
User model
TheUser document represents every registered account, whether a shopper or an admin. Authentication state, personal details, and role assignments all live here.
timestamps: true instructs Mongoose to automatically manage createdAt and updatedAt fields on every document. You do not need to set these manually.Field reference
OAuth 2.0 subject identifier returned by Google Sign-In. Empty string for email/password accounts.
Current session or refresh token issued to the user. Rotated on each login.
User’s given name.
User’s family name.
Email address. Stored in lowercase regardless of how it was submitted.
Hashed password. Empty string for Google OAuth accounts.
Contact phone number stored as a plain integer.
Gender selection. One of
"Masculino", "Femenino", or "Otro".Government-issued ID number (numeric portion).
Type of identity document. One of
"CC" (Cédula de Ciudadanía), "CE" (Cédula de Extranjería), or "Pasaporte".Date of birth stored as a free-form string (e.g.,
"1990-06-15").Array of
{ name, value } objects that grant access levels.Array of
{ name, value } objects that describe account status.One-time code sent during a passwordless or two-step login flow.
Confirmation token set once
login_code has been verified.Temporary code issued when a password-reset request is initiated.
Confirmation token set once the password-reset code has been consumed.
Timestamp of document creation, managed automatically by Mongoose (
timestamps: true).Timestamp of the last document update, managed automatically by Mongoose (
timestamps: true).Product model
AProduct document represents a single shirt listing. It holds merchandising data, size availability, pricing, stock count, and references to four image variants generated at upload time.
Field reference
Snapshot of the admin who created the listing. Embedding prevents the listing from breaking if the admin account is later modified.
Display name of the shirt (e.g.,
"Classic Oxford Shirt").Long-form product description shown on the detail page.
Available sizes for this listing. Each entry is one of
"XS", "S", "M", "L", "XL", or "XXL".Base price in the store’s local currency (integer or float).
Principal image — full-size portrait (1500×2000 px, 3:4 ratio). Used as the primary product photo on listing and detail pages. See Image Processing for the full pipeline.
Thumbnail — small portrait (500×666 px, 3:4 ratio). Used in search results, carousels, and anywhere a compact image is needed.
Detail/zoom — high-resolution portrait (2000×2667 px, 3:4 ratio). Loaded on demand when the shopper activates the zoom viewer.
Square catalog — square crop (1080×1080 px, 1:1 ratio). Used in grid-layout catalog views and social-media sharing cards.
Human-readable discount label (e.g.,
"10% OFF"). Defaults to "Sin descuento" when no promotion is active.The promotional price as a string when a discount is active. Empty string when
discount is "Sin descuento".Available stock count. Decremented when units are purchased. A value of
0 indicates the product is out of stock.Listing creation date. Defaults to
Date.now at insert time. Distinct from createdAt — kept for legacy compatibility.Automatic Mongoose timestamp for document creation.
Automatic Mongoose timestamp for the last update.
Cart model
ACart document represents one shopping session or historical order for a user. Rather than referencing products by ID, the cart embeds full product snapshots at the moment items are added. This means price changes, stock updates, or product deletions after the item was added to the cart will never silently alter what the customer sees at checkout.
Field reference
Array of product snapshot objects. Each entry is a copy of the product’s fields at add-to-cart time, augmented with purchase-specific fields.
Snapshot of the buyer’s profile at the time the cart was created or last updated.
Total number of individual units across all line items in the cart.
Grand total for the entire cart — the sum of all
products[].subtotal values.Timestamp recorded when the cart was first created on the client side. Defaults to
Date.now.Automatic Mongoose timestamp for document creation.
Automatic Mongoose timestamp for the last update.
The embedded-document pattern
All three models make deliberate use of embedded documents rather than foreign-key references (ObjectId + populate).
Data consistency at a point in time
When a product is snapshotted into a cart, or when an admin’s identity is embedded inside a product, those values are frozen. Future edits to the source document do not cascade — the historical record stays intact.
Fewer round-trips
A single MongoDB read returns the cart complete with all product and buyer data. There are no secondary queries needed to resolve references, which reduces latency on hot paths like checkout and order history.
Simpler queries for analytics
Aggregation pipelines operating on the
carts collection have direct access to product titles, prices, and buyer info without $lookup joins, making sales reports straightforward to write.Trade-off: storage vs. flexibility
Embedding increases document size and means edits (e.g., correcting a product title) don’t propagate to existing carts. This is intentional for order integrity but should be considered when designing admin tooling.