Overview
PixelTech Colombia uses Cloud Firestore as its primary database. The schema is designed for an e-commerce platform with inventory management, order processing, customer management, and accounting features.Collections Structure
Core Collections
Products
Collection:products
Main product catalog with support for simple products and variants.
Simple Product Schema
Product with Variants Schema
functions/mercadopago.js:224-236)
Subcollection: Product History
Collection:products/{productId}/history
Tracks inventory changes and price modifications (admin only).
Orders
Collection:orders
Customer orders from all sources.
- PENDIENTE_PAGO: Awaiting payment (MercadoPago, ADDI, Sistecrédito)
- PAGADO: Payment confirmed, stock deducted
- PENDIENTE: Ready for fulfillment (COD orders start here)
- DESPACHADO: Shipped to carrier
- EN_RUTA: In transit
- ENTREGADO: Delivered to customer
- CANCELADO: Cancelled by customer/system
- RECHAZADO: Payment rejected
Users
Collection:users
Customer accounts and profiles.
Subcollection: Addresses
Collection:users/{userId}/addresses
Categories
Collection:categories
Brands
Collection:brands
Remissions
Collection:remissions
Picking/packing documents for warehouse operations.
functions/mercadopago.js:286-293)
Warranties
Collection:warranties
Customer warranty claims.
Business Collections
Suppliers
Collection:suppliers
Expenses
Collection:expenses
Accounting transactions (income and expenses).
functions/mercadopago.js:267-275)
Accounts
Collection:accounts
Treasury accounts (bank accounts, payment gateways).
functions/mercadopago.js:261)
Scheduled Transfers
Collection:scheduled_transfers
Automatic bank transfers between accounts.
processScheduledTransfers scheduler (functions/scheduler.js:11)
Communication Collections
Chats
Collection:chats
WhatsApp conversation threads.
Subcollection: Messages
Collection:chats/{chatId}/messages
whatsappWebhook (functions/whatsapp.js:160-167)
Configuration Collections
Config
Collection:config
Singleton documents for site-wide settings.
Shipping Config
Document:config/shipping
Merchant Feed Cache
Document:config/merchant_feed_cache
Google Merchant Center feed cache.
generateProductFeed (functions/google-merchant.js:201-204)
Indexes
File:firestore.indexes.json
Recommended Composite Indexes
These should be added tofirestore.indexes.json for optimal performance:
Data Consistency
Timestamps
All collections use server-side timestamps:Transactions
Critical operations use Firestore transactions:Cascade Deletes
No automatic cascade deletes. Manual cleanup required:Best Practices
1. Document Size
- Keep documents under 1MB
- Use subcollections for large datasets (e.g., chat messages)
- Paginate large arrays (e.g., order history)