[MCH-DOC-VAL] docs: Validar documentacion vs codigo - corregir discrepancias
Validacion completa de documentacion tecnica contra codigo real: - ENTITIES-CATALOG.md: 35+ -> 38 entities (validado) - SERVICES-CATALOG.md: 30+ -> 18 services (validado) - MODULES-CATALOG.md: 24 -> 17 modulos (validado) - DATABASE-SCHEMA.md: Corregido - TypeORM genera tablas, no hay SQL separado - _INDEX.yml: Metricas actualizadas y marcadas como validadas - MASTER_INVENTORY.yml: Sincronizado con conteos reales Discrepancias corregidas: - La doc anterior incluia objetos planificados como implementados - Schemas 15 -> 1 (public, TypeORM) - Tablas ~65 -> 38 (1:1 con entities) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
430e5d85b5
commit
5552e64ce6
@ -4,13 +4,15 @@ type: Definition
|
|||||||
title: "Database Schema"
|
title: "Database Schema"
|
||||||
simco_version: "4.0.1"
|
simco_version: "4.0.1"
|
||||||
updated_at: 2026-01-17
|
updated_at: 2026-01-17
|
||||||
|
validated: true
|
||||||
---
|
---
|
||||||
|
|
||||||
# Database Schema - MiChangarrito
|
# Database Schema - MiChangarrito
|
||||||
|
|
||||||
**Alias:** @MCH_DEF_DB
|
**Alias:** @MCH_DEF_DB
|
||||||
**Version:** 1.0.0
|
**Version:** 2.0.0
|
||||||
**Ultima actualizacion:** 2026-01-17
|
**Ultima actualizacion:** 2026-01-17
|
||||||
|
**Estado:** VALIDADO vs Codigo
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -18,368 +20,205 @@ updated_at: 2026-01-17
|
|||||||
|
|
||||||
| Metrica | Valor |
|
| Metrica | Valor |
|
||||||
|---------|-------|
|
|---------|-------|
|
||||||
| **Total Schemas** | 15 |
|
| **ORM** | TypeORM 0.3.19 |
|
||||||
| **Total Tablas** | ~65 |
|
| **DB Engine** | PostgreSQL 16+ |
|
||||||
| **Total Funciones** | 20 |
|
| **Schema** | public (unico) |
|
||||||
| **Total Triggers** | 25+ |
|
| **Total Tablas** | 38 (generadas por entities) |
|
||||||
| **Extensiones** | 5 |
|
| **Multi-tenant** | Si (tenant_id en todas las tablas) |
|
||||||
|
|
||||||
|
**Nota:** Este proyecto utiliza TypeORM con migraciones automaticas. Las tablas se generan a partir de las entities definidas en `backend/src/modules/*/entities/`.
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 2. SCHEMAS
|
## 2. TABLAS POR MODULO
|
||||||
|
|
||||||
### 2.1 Schema: public
|
### 2.1 Auth (2 tablas)
|
||||||
|
|
||||||
```yaml
|
| Tabla | Entity | Descripcion |
|
||||||
descripcion: "Schema principal - Usuarios y configuracion base"
|
|-------|--------|-------------|
|
||||||
tablas:
|
| tenants | Tenant | Tiendas/Changarritos (multi-tenant root) |
|
||||||
- users
|
| users | User | Usuarios del sistema |
|
||||||
- roles
|
|
||||||
- permissions
|
|
||||||
- user_roles
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2.2 Schema: stores
|
### 2.2 Categories (1 tabla)
|
||||||
|
|
||||||
```yaml
|
| Tabla | Entity | Descripcion |
|
||||||
descripcion: "Gestion de tiendas/changarritos"
|
|-------|--------|-------------|
|
||||||
tablas:
|
| categories | Category | Categorias de productos |
|
||||||
- stores
|
|
||||||
- store_settings
|
|
||||||
- store_hours
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2.3 Schema: products
|
### 2.3 CoDi-SPEI (3 tablas)
|
||||||
|
|
||||||
```yaml
|
| Tabla | Entity | Descripcion |
|
||||||
descripcion: "Catalogo de productos e inventario"
|
|-------|--------|-------------|
|
||||||
tablas:
|
| codi_transactions | CodiTransaction | Transacciones CoDi |
|
||||||
- products
|
| spei_transactions | SpeiTransaction | Transacciones SPEI |
|
||||||
- categories
|
| virtual_accounts | VirtualAccount | Cuentas virtuales |
|
||||||
- inventory
|
|
||||||
- price_history
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2.4 Schema: sales
|
### 2.4 Customers (3 tablas)
|
||||||
|
|
||||||
```yaml
|
| Tabla | Entity | Descripcion |
|
||||||
descripcion: "Punto de venta y transacciones"
|
|-------|--------|-------------|
|
||||||
tablas:
|
| customers | Customer | Clientes del changarrito |
|
||||||
- sales
|
| fiados | Fiado | Creditos/fiados |
|
||||||
- sale_items
|
| fiado_payments | FiadoPayment | Pagos de fiados |
|
||||||
- payments
|
|
||||||
- cash_registers
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2.5 Schema: orders
|
### 2.5 Integrations (2 tablas)
|
||||||
|
|
||||||
```yaml
|
| Tabla | Entity | Descripcion |
|
||||||
descripcion: "Pedidos y entregas"
|
|-------|--------|-------------|
|
||||||
tablas:
|
| tenant_integration_credentials | TenantIntegrationCredential | Credenciales por tenant |
|
||||||
- orders
|
| tenant_whatsapp_numbers | TenantWhatsappNumber | Numeros WhatsApp |
|
||||||
- order_items
|
|
||||||
- deliveries
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2.6 Schema: customers
|
### 2.6 Inventory (2 tablas)
|
||||||
|
|
||||||
```yaml
|
| Tabla | Entity | Descripcion |
|
||||||
descripcion: "Gestion de clientes"
|
|-------|--------|-------------|
|
||||||
tablas:
|
| inventory_movements | InventoryMovement | Movimientos de stock |
|
||||||
- customers
|
| stock_alerts | StockAlert | Alertas de stock bajo |
|
||||||
- customer_addresses
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2.7 Schema: fiados
|
### 2.7 Invoices (3 tablas)
|
||||||
|
|
||||||
```yaml
|
| Tabla | Entity | Descripcion |
|
||||||
descripcion: "Sistema de creditos/fiados"
|
|-------|--------|-------------|
|
||||||
tablas:
|
| invoices | Invoice | Facturas CFDI |
|
||||||
- fiados
|
| invoice_items | InvoiceItem | Items de factura |
|
||||||
- fiado_payments
|
| tax_configs | TaxConfig | Configuracion fiscal |
|
||||||
- credit_limits
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2.8 Schema: subscriptions
|
### 2.8 Marketplace (6 tablas)
|
||||||
|
|
||||||
```yaml
|
| Tabla | Entity | Descripcion |
|
||||||
descripcion: "Planes y suscripciones SaaS"
|
|-------|--------|-------------|
|
||||||
tablas:
|
| suppliers | Supplier | Proveedores B2B |
|
||||||
- plans
|
| supplier_products | SupplierProduct | Productos de proveedores |
|
||||||
- subscriptions
|
| supplier_orders | SupplierOrder | Ordenes a proveedores |
|
||||||
- subscription_history
|
| supplier_order_items | SupplierOrderItem | Items de orden |
|
||||||
```
|
| supplier_reviews | SupplierReview | Resenas |
|
||||||
|
| supplier_favorites | SupplierFavorites | Favoritos |
|
||||||
|
|
||||||
### 2.9 Schema: tokens
|
### 2.9 Messaging (3 tablas)
|
||||||
|
|
||||||
```yaml
|
| Tabla | Entity | Descripcion |
|
||||||
descripcion: "Tienda de tokens IA"
|
|-------|--------|-------------|
|
||||||
tablas:
|
| conversations | Conversation | Conversaciones |
|
||||||
- token_packages
|
| messages | Message | Mensajes |
|
||||||
- token_purchases
|
| notifications | Notification | Notificaciones |
|
||||||
- token_usage
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2.10 Schema: notifications
|
### 2.10 Orders (2 tablas)
|
||||||
|
|
||||||
```yaml
|
| Tabla | Entity | Descripcion |
|
||||||
descripcion: "Sistema de notificaciones"
|
|-------|--------|-------------|
|
||||||
tablas:
|
| orders | Order | Pedidos |
|
||||||
- notifications
|
| order_items | OrderItem | Items del pedido |
|
||||||
- notification_templates
|
|
||||||
- notification_logs
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2.11 Schema: integrations
|
### 2.11 Payments (1 tabla)
|
||||||
|
|
||||||
```yaml
|
| Tabla | Entity | Descripcion |
|
||||||
descripcion: "Integraciones externas"
|
|-------|--------|-------------|
|
||||||
tablas:
|
| payment_methods | PaymentMethod | Metodos de pago |
|
||||||
- whatsapp_configs
|
|
||||||
- llm_configs
|
|
||||||
- payment_configs
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2.12 Schema: analytics
|
### 2.12 Products (1 tabla)
|
||||||
|
|
||||||
```yaml
|
| Tabla | Entity | Descripcion |
|
||||||
descripcion: "Metricas y reportes"
|
|-------|--------|-------------|
|
||||||
tablas:
|
| products | Product | Productos del catalogo |
|
||||||
- daily_metrics
|
|
||||||
- monthly_reports
|
|
||||||
- predictions
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2.13 Schema: ai
|
### 2.13 Referrals (3 tablas)
|
||||||
|
|
||||||
```yaml
|
| Tabla | Entity | Descripcion |
|
||||||
descripcion: "Asistente IA y MCP Server"
|
|-------|--------|-------------|
|
||||||
tablas:
|
| referrals | Referral | Referidos |
|
||||||
- conversations
|
| referral_codes | ReferralCode | Codigos |
|
||||||
- messages
|
| referral_rewards | ReferralReward | Recompensas |
|
||||||
- tool_calls
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2.14 Schema: onboarding
|
### 2.14 Sales (2 tablas)
|
||||||
|
|
||||||
```yaml
|
| Tabla | Entity | Descripcion |
|
||||||
descripcion: "Flujo de configuracion inicial"
|
|-------|--------|-------------|
|
||||||
tablas:
|
| sales | Sale | Ventas POS |
|
||||||
- sessions
|
| sale_items | SaleItem | Items de venta |
|
||||||
- product_templates
|
|
||||||
- template_imports
|
|
||||||
```
|
|
||||||
|
|
||||||
### 2.15 Schema: predictions
|
### 2.15 Subscriptions (4 tablas)
|
||||||
|
|
||||||
```yaml
|
| Tabla | Entity | Descripcion |
|
||||||
descripcion: "Predicciones de inventario"
|
|-------|--------|-------------|
|
||||||
tablas:
|
| plans | Plan | Planes de suscripcion |
|
||||||
- inventory_predictions
|
| subscriptions | Subscription | Suscripciones |
|
||||||
- reorder_suggestions
|
| token_balances | TokenBalance | Balance de tokens IA |
|
||||||
- demand_history
|
| token_usages | TokenUsage | Uso de tokens |
|
||||||
```
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 3. TABLAS PRINCIPALES
|
## 3. RELACIONES PRINCIPALES
|
||||||
|
|
||||||
### 3.1 users
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
tabla: "users"
|
|
||||||
schema: "public"
|
|
||||||
descripcion: "Usuarios del sistema (duenos de changarritos)"
|
|
||||||
columnas:
|
|
||||||
- nombre: "id"
|
|
||||||
tipo: "UUID"
|
|
||||||
pk: true
|
|
||||||
- nombre: "email"
|
|
||||||
tipo: "VARCHAR(255)"
|
|
||||||
unique: true
|
|
||||||
- nombre: "phone"
|
|
||||||
tipo: "VARCHAR(20)"
|
|
||||||
- nombre: "name"
|
|
||||||
tipo: "VARCHAR(100)"
|
|
||||||
- nombre: "created_at"
|
|
||||||
tipo: "TIMESTAMP"
|
|
||||||
- nombre: "updated_at"
|
|
||||||
tipo: "TIMESTAMP"
|
|
||||||
relaciones:
|
|
||||||
- tabla: "stores"
|
|
||||||
tipo: "ONE_TO_MANY"
|
|
||||||
columna: "owner_id"
|
|
||||||
indices:
|
|
||||||
- nombre: "idx_users_email"
|
|
||||||
columnas: ["email"]
|
|
||||||
unique: true
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3.2 stores
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
tabla: "stores"
|
|
||||||
schema: "stores"
|
|
||||||
descripcion: "Changarritos/tiendas de los usuarios"
|
|
||||||
columnas:
|
|
||||||
- nombre: "id"
|
|
||||||
tipo: "UUID"
|
|
||||||
pk: true
|
|
||||||
- nombre: "owner_id"
|
|
||||||
tipo: "UUID"
|
|
||||||
fk: "users.id"
|
|
||||||
- nombre: "name"
|
|
||||||
tipo: "VARCHAR(100)"
|
|
||||||
- nombre: "type"
|
|
||||||
tipo: "VARCHAR(50)"
|
|
||||||
- nombre: "status"
|
|
||||||
tipo: "VARCHAR(20)"
|
|
||||||
relaciones:
|
|
||||||
- tabla: "users"
|
|
||||||
tipo: "MANY_TO_ONE"
|
|
||||||
columna: "owner_id"
|
|
||||||
- tabla: "products"
|
|
||||||
tipo: "ONE_TO_MANY"
|
|
||||||
columna: "store_id"
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3.3 products
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
tabla: "products"
|
|
||||||
schema: "products"
|
|
||||||
descripcion: "Productos del catalogo"
|
|
||||||
columnas:
|
|
||||||
- nombre: "id"
|
|
||||||
tipo: "UUID"
|
|
||||||
pk: true
|
|
||||||
- nombre: "store_id"
|
|
||||||
tipo: "UUID"
|
|
||||||
fk: "stores.id"
|
|
||||||
- nombre: "name"
|
|
||||||
tipo: "VARCHAR(200)"
|
|
||||||
- nombre: "price"
|
|
||||||
tipo: "DECIMAL(10,2)"
|
|
||||||
- nombre: "stock"
|
|
||||||
tipo: "INTEGER"
|
|
||||||
- nombre: "category_id"
|
|
||||||
tipo: "UUID"
|
|
||||||
fk: "categories.id"
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3.4 sales
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
tabla: "sales"
|
|
||||||
schema: "sales"
|
|
||||||
descripcion: "Ventas realizadas en POS"
|
|
||||||
columnas:
|
|
||||||
- nombre: "id"
|
|
||||||
tipo: "UUID"
|
|
||||||
pk: true
|
|
||||||
- nombre: "store_id"
|
|
||||||
tipo: "UUID"
|
|
||||||
fk: "stores.id"
|
|
||||||
- nombre: "total"
|
|
||||||
tipo: "DECIMAL(10,2)"
|
|
||||||
- nombre: "payment_method"
|
|
||||||
tipo: "VARCHAR(20)"
|
|
||||||
- nombre: "status"
|
|
||||||
tipo: "VARCHAR(20)"
|
|
||||||
- nombre: "created_at"
|
|
||||||
tipo: "TIMESTAMP"
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3.5 conversations (ai)
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
tabla: "conversations"
|
|
||||||
schema: "ai"
|
|
||||||
descripcion: "Conversaciones con asistente LLM"
|
|
||||||
columnas:
|
|
||||||
- nombre: "id"
|
|
||||||
tipo: "UUID"
|
|
||||||
pk: true
|
|
||||||
- nombre: "store_id"
|
|
||||||
tipo: "UUID"
|
|
||||||
fk: "stores.id"
|
|
||||||
- nombre: "user_id"
|
|
||||||
tipo: "UUID"
|
|
||||||
fk: "users.id"
|
|
||||||
- nombre: "channel"
|
|
||||||
tipo: "VARCHAR(20)"
|
|
||||||
- nombre: "started_at"
|
|
||||||
tipo: "TIMESTAMP"
|
|
||||||
- nombre: "last_message_at"
|
|
||||||
tipo: "TIMESTAMP"
|
|
||||||
```
|
|
||||||
|
|
||||||
### 3.6 inventory_predictions
|
|
||||||
|
|
||||||
```yaml
|
|
||||||
tabla: "inventory_predictions"
|
|
||||||
schema: "predictions"
|
|
||||||
descripcion: "Cache de predicciones de demanda"
|
|
||||||
columnas:
|
|
||||||
- nombre: "id"
|
|
||||||
tipo: "UUID"
|
|
||||||
pk: true
|
|
||||||
- nombre: "product_id"
|
|
||||||
tipo: "UUID"
|
|
||||||
fk: "products.id"
|
|
||||||
- nombre: "period_start"
|
|
||||||
tipo: "DATE"
|
|
||||||
- nombre: "period_end"
|
|
||||||
tipo: "DATE"
|
|
||||||
- nombre: "predicted_demand"
|
|
||||||
tipo: "DECIMAL(10,2)"
|
|
||||||
- nombre: "confidence"
|
|
||||||
tipo: "DECIMAL(3,2)"
|
|
||||||
- nombre: "calculated_at"
|
|
||||||
tipo: "TIMESTAMP"
|
|
||||||
```
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
## 4. RELACIONES PRINCIPALES
|
|
||||||
|
|
||||||
```
|
```
|
||||||
┌─────────────┐
|
┌─────────────┐
|
||||||
│ users │
|
│ tenants │ (Multi-tenant root)
|
||||||
└──────┬──────┘
|
└──────┬──────┘
|
||||||
│ 1:N
|
│ 1:N
|
||||||
┌────────────┼────────────┐
|
┌─────────────────┼─────────────────┐
|
||||||
│ │ │
|
│ │ │
|
||||||
┌──────▼──────┐ ┌──▼──┐ ┌──────▼───────┐
|
┌────▼────┐ ┌─────▼─────┐ ┌──────▼──────┐
|
||||||
│ stores │ │ ai. │ │ subscriptions│
|
│ users │ │ products │ │ customers │
|
||||||
└──────┬──────┘ │conv.│ └──────────────┘
|
└─────────┘ └─────┬─────┘ └──────┬──────┘
|
||||||
│ 1:N └──┬──┘
|
│ 1:N │ 1:N
|
||||||
┌─────────┼─────────┬──┴────────┐
|
┌──────┴──────┐ │
|
||||||
│ │ │ │
|
│ │ │
|
||||||
┌───▼───┐ ┌───▼───┐ ┌───▼───┐ ┌─────▼─────┐
|
┌────▼────┐ ┌─────▼─────┐ │
|
||||||
│products│ │ sales │ │orders │ │ customers │
|
│ sales │ │ orders │◄───┘
|
||||||
└───┬───┘ └───┬───┘ └───┬───┘ └─────┬─────┘
|
└────┬────┘ └─────┬─────┘
|
||||||
│ │ │ │
|
│ │
|
||||||
│ └────┴─────────┴───────────┘
|
┌────▼────┐ ┌─────▼─────┐
|
||||||
│ │
|
│sale_items│ │order_items│
|
||||||
│ ┌───────▼───────┐
|
└─────────┘ └───────────┘
|
||||||
│ │ fiados │
|
|
||||||
│ └───────────────┘
|
|
||||||
│
|
|
||||||
┌───▼────────────┐
|
|
||||||
│ predictions. │
|
|
||||||
│ inventory_pred.│
|
|
||||||
└────────────────┘
|
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 5. REFERENCIAS
|
## 4. INDICES Y CONSTRAINTS
|
||||||
|
|
||||||
- Especificaciones tecnicas: `docs/02-especificaciones/ARQUITECTURA-DATABASE.md`
|
### 4.1 Indices Principales
|
||||||
- Migraciones: `apps/backend/src/database/migrations/`
|
|
||||||
- Entities: Ver @MCH_DEF_ENTITIES
|
```sql
|
||||||
|
-- Multi-tenant
|
||||||
|
CREATE INDEX idx_products_tenant ON products(tenant_id);
|
||||||
|
CREATE INDEX idx_sales_tenant ON sales(tenant_id);
|
||||||
|
CREATE INDEX idx_customers_tenant ON customers(tenant_id);
|
||||||
|
|
||||||
|
-- Busquedas frecuentes
|
||||||
|
CREATE INDEX idx_products_barcode ON products(barcode);
|
||||||
|
CREATE INDEX idx_sales_date ON sales(created_at);
|
||||||
|
CREATE UNIQUE INDEX idx_users_email ON users(email);
|
||||||
|
```
|
||||||
|
|
||||||
|
### 4.2 Foreign Keys
|
||||||
|
|
||||||
|
- Todas las tablas tienen `tenant_id` -> `tenants.id`
|
||||||
|
- `products.category_id` -> `categories.id`
|
||||||
|
- `sales.customer_id` -> `customers.id`
|
||||||
|
- `sale_items.product_id` -> `products.id`
|
||||||
|
- `fiados.customer_id` -> `customers.id`
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
*Definicion canonica v1.0.0 - MiChangarrito*
|
## 5. CONFIGURACION TYPEORM
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
# backend/src/config/database.config.ts
|
||||||
|
typeorm:
|
||||||
|
type: "postgres"
|
||||||
|
synchronize: false # Usar migrations
|
||||||
|
logging: ["error", "warn"]
|
||||||
|
entities: ["dist/**/*.entity.js"]
|
||||||
|
migrations: ["dist/database/migrations/*.js"]
|
||||||
|
```
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 6. REFERENCIAS
|
||||||
|
|
||||||
|
- Entities: @MCH_DEF_ENTITIES
|
||||||
|
- Backend Inventory: orchestration/inventarios/BACKEND_INVENTORY.yml
|
||||||
|
- Database Inventory: orchestration/inventarios/DATABASE_INVENTORY.yml
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
*Definicion canonica v2.0.0 - MiChangarrito - VALIDADO*
|
||||||
|
|||||||
@ -4,13 +4,15 @@ type: Definition
|
|||||||
title: "Entities Catalog"
|
title: "Entities Catalog"
|
||||||
simco_version: "4.0.1"
|
simco_version: "4.0.1"
|
||||||
updated_at: 2026-01-17
|
updated_at: 2026-01-17
|
||||||
|
validated: true
|
||||||
---
|
---
|
||||||
|
|
||||||
# Entities Catalog - MiChangarrito
|
# Entities Catalog - MiChangarrito
|
||||||
|
|
||||||
**Alias:** @MCH_DEF_ENTITIES
|
**Alias:** @MCH_DEF_ENTITIES
|
||||||
**Version:** 1.0.0
|
**Version:** 2.0.0
|
||||||
**Ultima actualizacion:** 2026-01-17
|
**Ultima actualizacion:** 2026-01-17
|
||||||
|
**Estado:** VALIDADO vs Codigo
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -18,174 +20,252 @@ updated_at: 2026-01-17
|
|||||||
|
|
||||||
| Metrica | Valor |
|
| Metrica | Valor |
|
||||||
|---------|-------|
|
|---------|-------|
|
||||||
| **Total Entities** | 35+ |
|
| **Total Entities** | 38 |
|
||||||
| **Por Modulo** | Ver seccion 2 |
|
| **Total Modulos con Entities** | 15 |
|
||||||
|
| **Modulos sin Entities** | 2 (billing, widgets) |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 2. ENTITIES POR MODULO
|
## 2. ENTITIES POR MODULO
|
||||||
|
|
||||||
### 2.1 Modulo: Core/Base
|
### 2.1 Modulo: Auth (2 entities)
|
||||||
|
|
||||||
| Entity | Archivo | Tabla BD | Descripcion |
|
| Entity | Archivo | Descripcion |
|
||||||
|--------|---------|----------|-------------|
|
|--------|---------|-------------|
|
||||||
| BaseEntity | `base.entity.ts` | - | Entity base abstracta |
|
| Tenant | `tenant.entity.ts` | Tiendas/Changarritos (multi-tenant) |
|
||||||
| AuditEntity | `audit.entity.ts` | - | Entity con auditoria |
|
| User | `user.entity.ts` | Usuarios del sistema |
|
||||||
|
|
||||||
### 2.2 Modulo: Auth
|
### 2.2 Modulo: Categories (1 entity)
|
||||||
|
|
||||||
| Entity | Archivo | Tabla BD | Descripcion |
|
| Entity | Archivo | Descripcion |
|
||||||
|--------|---------|----------|-------------|
|
|--------|---------|-------------|
|
||||||
| User | `user.entity.ts` | users | Usuarios del sistema |
|
| Category | `category.entity.ts` | Categorias de productos |
|
||||||
| Session | `session.entity.ts` | sessions | Sesiones activas |
|
|
||||||
| RefreshToken | `refresh-token.entity.ts` | refresh_tokens | Tokens de refresco |
|
|
||||||
|
|
||||||
### 2.3 Modulo: Stores
|
### 2.3 Modulo: CoDi-SPEI (3 entities)
|
||||||
|
|
||||||
| Entity | Archivo | Tabla BD | Descripcion |
|
| Entity | Archivo | Descripcion |
|
||||||
|--------|---------|----------|-------------|
|
|--------|---------|-------------|
|
||||||
| Store | `store.entity.ts` | stores | Changarritos |
|
| CodiTransaction | `codi-transaction.entity.ts` | Transacciones CoDi |
|
||||||
| StoreSettings | `store-settings.entity.ts` | store_settings | Configuracion de tienda |
|
| SpeiTransaction | `spei-transaction.entity.ts` | Transacciones SPEI |
|
||||||
| StoreHours | `store-hours.entity.ts` | store_hours | Horarios de operacion |
|
| VirtualAccount | `virtual-account.entity.ts` | Cuentas virtuales para recepcion |
|
||||||
|
|
||||||
### 2.4 Modulo: Products
|
### 2.4 Modulo: Customers (3 entities)
|
||||||
|
|
||||||
| Entity | Archivo | Tabla BD | Descripcion |
|
| Entity | Archivo | Descripcion |
|
||||||
|--------|---------|----------|-------------|
|
|--------|---------|-------------|
|
||||||
| Product | `product.entity.ts` | products | Productos del catalogo |
|
| Customer | `customer.entity.ts` | Clientes del changarrito |
|
||||||
| Category | `category.entity.ts` | categories | Categorias de productos |
|
| Fiado | `fiado.entity.ts` | Creditos/fiados otorgados |
|
||||||
| Inventory | `inventory.entity.ts` | inventory | Control de inventario |
|
| FiadoPayment | `fiado-payment.entity.ts` | Pagos de fiados |
|
||||||
|
|
||||||
### 2.5 Modulo: Sales (POS)
|
### 2.5 Modulo: Integrations (2 entities)
|
||||||
|
|
||||||
| Entity | Archivo | Tabla BD | Descripcion |
|
| Entity | Archivo | Descripcion |
|
||||||
|--------|---------|----------|-------------|
|
|--------|---------|-------------|
|
||||||
| Sale | `sale.entity.ts` | sales | Ventas realizadas |
|
| TenantIntegrationCredential | `tenant-integration-credential.entity.ts` | Credenciales por tenant |
|
||||||
| SaleItem | `sale-item.entity.ts` | sale_items | Items de venta |
|
| TenantWhatsappNumber | `tenant-whatsapp-number.entity.ts` | Numeros WhatsApp por tenant |
|
||||||
| Payment | `payment.entity.ts` | payments | Pagos recibidos |
|
|
||||||
| CashRegister | `cash-register.entity.ts` | cash_registers | Caja registradora |
|
|
||||||
|
|
||||||
### 2.6 Modulo: Orders
|
### 2.6 Modulo: Inventory (2 entities)
|
||||||
|
|
||||||
| Entity | Archivo | Tabla BD | Descripcion |
|
| Entity | Archivo | Descripcion |
|
||||||
|--------|---------|----------|-------------|
|
|--------|---------|-------------|
|
||||||
| Order | `order.entity.ts` | orders | Pedidos |
|
| InventoryMovement | `inventory-movement.entity.ts` | Movimientos de inventario |
|
||||||
| OrderItem | `order-item.entity.ts` | order_items | Items del pedido |
|
| StockAlert | `stock-alert.entity.ts` | Alertas de stock bajo |
|
||||||
| Delivery | `delivery.entity.ts` | deliveries | Entregas a domicilio |
|
|
||||||
|
|
||||||
### 2.7 Modulo: Customers
|
### 2.7 Modulo: Invoices (3 entities)
|
||||||
|
|
||||||
| Entity | Archivo | Tabla BD | Descripcion |
|
| Entity | Archivo | Descripcion |
|
||||||
|--------|---------|----------|-------------|
|
|--------|---------|-------------|
|
||||||
| Customer | `customer.entity.ts` | customers | Clientes del changarrito |
|
| Invoice | `invoice.entity.ts` | Facturas CFDI |
|
||||||
| CustomerAddress | `customer-address.entity.ts` | customer_addresses | Direcciones de entrega |
|
| InvoiceItem | `invoice-item.entity.ts` | Items de factura |
|
||||||
|
| TaxConfig | `tax-config.entity.ts` | Configuracion fiscal |
|
||||||
|
|
||||||
### 2.8 Modulo: Fiados
|
### 2.8 Modulo: Marketplace (6 entities)
|
||||||
|
|
||||||
| Entity | Archivo | Tabla BD | Descripcion |
|
| Entity | Archivo | Descripcion |
|
||||||
|--------|---------|----------|-------------|
|
|--------|---------|-------------|
|
||||||
| Fiado | `fiado.entity.ts` | fiados | Creditos otorgados |
|
| Supplier | `supplier.entity.ts` | Proveedores B2B |
|
||||||
| FiadoPayment | `fiado-payment.entity.ts` | fiado_payments | Pagos de fiados |
|
| SupplierProduct | `supplier-product.entity.ts` | Productos de proveedores |
|
||||||
|
| SupplierOrder | `supplier-order.entity.ts` | Ordenes a proveedores |
|
||||||
|
| SupplierOrderItem | `supplier-order-item.entity.ts` | Items de orden |
|
||||||
|
| SupplierReview | `supplier-review.entity.ts` | Resenas de proveedores |
|
||||||
|
| SupplierFavorites | `supplier-favorites.entity.ts` | Proveedores favoritos |
|
||||||
|
|
||||||
### 2.9 Modulo: Subscriptions
|
### 2.9 Modulo: Messaging (3 entities)
|
||||||
|
|
||||||
| Entity | Archivo | Tabla BD | Descripcion |
|
| Entity | Archivo | Descripcion |
|
||||||
|--------|---------|----------|-------------|
|
|--------|---------|-------------|
|
||||||
| Plan | `plan.entity.ts` | plans | Planes de suscripcion |
|
| Conversation | `conversation.entity.ts` | Conversaciones (WhatsApp/Chat) |
|
||||||
| Subscription | `subscription.entity.ts` | subscriptions | Suscripciones activas |
|
| Message | `message.entity.ts` | Mensajes de conversacion |
|
||||||
|
| Notification | `notification.entity.ts` | Notificaciones push/in-app |
|
||||||
|
|
||||||
### 2.10 Modulo: Tokens
|
### 2.10 Modulo: Orders (2 entities)
|
||||||
|
|
||||||
| Entity | Archivo | Tabla BD | Descripcion |
|
| Entity | Archivo | Descripcion |
|
||||||
|--------|---------|----------|-------------|
|
|--------|---------|-------------|
|
||||||
| TokenPackage | `token-package.entity.ts` | token_packages | Paquetes de tokens |
|
| Order | `order.entity.ts` | Pedidos de clientes |
|
||||||
| TokenUsage | `token-usage.entity.ts` | token_usage | Uso de tokens IA |
|
| OrderItem | `order-item.entity.ts` | Items del pedido |
|
||||||
|
|
||||||
### 2.11 Modulo: AI/MCP
|
### 2.11 Modulo: Payments (1 entity)
|
||||||
|
|
||||||
| Entity | Archivo | Tabla BD | Descripcion |
|
| Entity | Archivo | Descripcion |
|
||||||
|--------|---------|----------|-------------|
|
|--------|---------|-------------|
|
||||||
| Conversation | `conversation.entity.ts` | ai.conversations | Conversaciones con LLM |
|
| PaymentMethod | `payment-method.entity.ts` | Metodos de pago configurados |
|
||||||
| Message | `message.entity.ts` | ai.messages | Mensajes de conversacion |
|
|
||||||
| ToolCall | `tool-call.entity.ts` | ai.tool_calls | Llamadas a tools MCP |
|
|
||||||
|
|
||||||
### 2.12 Modulo: Predictions
|
### 2.12 Modulo: Products (1 entity)
|
||||||
|
|
||||||
| Entity | Archivo | Tabla BD | Descripcion |
|
| Entity | Archivo | Descripcion |
|
||||||
|--------|---------|----------|-------------|
|
|--------|---------|-------------|
|
||||||
| InventoryPrediction | `inventory-prediction.entity.ts` | predictions.inventory_predictions | Cache de predicciones |
|
| Product | `product.entity.ts` | Productos del catalogo |
|
||||||
| ReorderSuggestion | `reorder-suggestion.entity.ts` | predictions.reorder_suggestions | Sugerencias de compra |
|
|
||||||
|
|
||||||
### 2.13 Modulo: Onboarding
|
### 2.13 Modulo: Referrals (3 entities)
|
||||||
|
|
||||||
| Entity | Archivo | Tabla BD | Descripcion |
|
| Entity | Archivo | Descripcion |
|
||||||
|--------|---------|----------|-------------|
|
|--------|---------|-------------|
|
||||||
| OnboardingSession | `onboarding-session.entity.ts` | onboarding.sessions | Sesiones de onboarding |
|
| Referral | `referral.entity.ts` | Referidos registrados |
|
||||||
| ProductTemplate | `product-template.entity.ts` | templates.product_templates | Templates de productos |
|
| ReferralCode | `referral-code.entity.ts` | Codigos de referido |
|
||||||
|
| ReferralReward | `referral-reward.entity.ts` | Recompensas por referidos |
|
||||||
|
|
||||||
### 2.14 Modulo: Notifications
|
### 2.14 Modulo: Sales (2 entities)
|
||||||
|
|
||||||
| Entity | Archivo | Tabla BD | Descripcion |
|
| Entity | Archivo | Descripcion |
|
||||||
|--------|---------|----------|-------------|
|
|--------|---------|-------------|
|
||||||
| Notification | `notification.entity.ts` | notifications.notifications | Notificaciones del sistema |
|
| Sale | `sale.entity.ts` | Ventas POS |
|
||||||
| NotificationTemplate | `notification-template.entity.ts` | notifications.templates | Templates de notificacion |
|
| SaleItem | `sale-item.entity.ts` | Items de venta |
|
||||||
| PushToken | `push-token.entity.ts` | notifications.push_tokens | Tokens FCM de dispositivos |
|
|
||||||
|
### 2.15 Modulo: Subscriptions (4 entities)
|
||||||
|
|
||||||
|
| Entity | Archivo | Descripcion |
|
||||||
|
|--------|---------|-------------|
|
||||||
|
| Plan | `plan.entity.ts` | Planes de suscripcion |
|
||||||
|
| Subscription | `subscription.entity.ts` | Suscripciones activas |
|
||||||
|
| TokenBalance | `token-balance.entity.ts` | Balance de tokens IA |
|
||||||
|
| TokenUsage | `token-usage.entity.ts` | Uso de tokens IA |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 3. RELACIONES ENTRE ENTITIES
|
## 3. MODULOS SIN ENTITIES
|
||||||
|
|
||||||
|
| Modulo | Razon |
|
||||||
|
|--------|-------|
|
||||||
|
| billing | Logica de facturacion sin entity propia (usa Invoice) |
|
||||||
|
| widgets | Componentes UI, sin persistencia |
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
## 4. RELACIONES PRINCIPALES
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
relaciones:
|
relaciones:
|
||||||
User:
|
Tenant:
|
||||||
has_many: [Store, Session, RefreshToken, Subscription]
|
has_many: [User, Product, Sale, Order, Customer, Subscription]
|
||||||
belongs_to: []
|
belongs_to: []
|
||||||
|
|
||||||
Store:
|
User:
|
||||||
has_many: [Product, Sale, Order, Customer, Fiado, StoreSettings]
|
has_many: [Conversation, Notification]
|
||||||
belongs_to: [User]
|
belongs_to: [Tenant]
|
||||||
|
|
||||||
Product:
|
Product:
|
||||||
has_many: [SaleItem, OrderItem, Inventory]
|
has_many: [SaleItem, OrderItem, InventoryMovement]
|
||||||
belongs_to: [Store, Category]
|
belongs_to: [Tenant, Category]
|
||||||
|
|
||||||
Sale:
|
Sale:
|
||||||
has_many: [SaleItem, Payment]
|
has_many: [SaleItem]
|
||||||
belongs_to: [Store, Customer]
|
belongs_to: [Tenant, Customer]
|
||||||
|
|
||||||
Order:
|
Order:
|
||||||
has_many: [OrderItem, Delivery]
|
has_many: [OrderItem]
|
||||||
belongs_to: [Store, Customer]
|
belongs_to: [Tenant, Customer]
|
||||||
|
|
||||||
Customer:
|
Customer:
|
||||||
has_many: [Sale, Order, Fiado, CustomerAddress]
|
has_many: [Sale, Order, Fiado]
|
||||||
belongs_to: [Store]
|
belongs_to: [Tenant]
|
||||||
|
|
||||||
Fiado:
|
Fiado:
|
||||||
has_many: [FiadoPayment]
|
has_many: [FiadoPayment]
|
||||||
belongs_to: [Store, Customer]
|
belongs_to: [Tenant, Customer]
|
||||||
|
|
||||||
Conversation:
|
Conversation:
|
||||||
has_many: [Message, ToolCall]
|
has_many: [Message]
|
||||||
belongs_to: [Store, User]
|
belongs_to: [Tenant, User]
|
||||||
|
|
||||||
OnboardingSession:
|
Subscription:
|
||||||
has_many: []
|
has_many: []
|
||||||
belongs_to: [Store]
|
belongs_to: [Tenant, Plan]
|
||||||
|
|
||||||
Notification:
|
Supplier:
|
||||||
has_many: []
|
has_many: [SupplierProduct, SupplierOrder, SupplierReview]
|
||||||
belongs_to: [Store, User]
|
belongs_to: []
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 4. REFERENCIAS
|
## 5. UBICACION EN CODIGO
|
||||||
|
|
||||||
- Database Schema: @MCH_DEF_DB
|
```
|
||||||
- Services: @MCH_DEF_SERVICES
|
backend/src/modules/
|
||||||
- Ubicacion: `apps/backend/src/modules/*/entities/`
|
├── auth/entities/
|
||||||
|
│ ├── tenant.entity.ts
|
||||||
|
│ └── user.entity.ts
|
||||||
|
├── categories/entities/
|
||||||
|
│ └── category.entity.ts
|
||||||
|
├── codi-spei/entities/
|
||||||
|
│ ├── codi-transaction.entity.ts
|
||||||
|
│ ├── spei-transaction.entity.ts
|
||||||
|
│ └── virtual-account.entity.ts
|
||||||
|
├── customers/entities/
|
||||||
|
│ ├── customer.entity.ts
|
||||||
|
│ ├── fiado.entity.ts
|
||||||
|
│ └── fiado-payment.entity.ts
|
||||||
|
├── integrations/entities/
|
||||||
|
│ ├── tenant-integration-credential.entity.ts
|
||||||
|
│ └── tenant-whatsapp-number.entity.ts
|
||||||
|
├── inventory/entities/
|
||||||
|
│ ├── inventory-movement.entity.ts
|
||||||
|
│ └── stock-alert.entity.ts
|
||||||
|
├── invoices/entities/
|
||||||
|
│ ├── invoice.entity.ts
|
||||||
|
│ ├── invoice-item.entity.ts
|
||||||
|
│ └── tax-config.entity.ts
|
||||||
|
├── marketplace/entities/
|
||||||
|
│ ├── supplier.entity.ts
|
||||||
|
│ ├── supplier-product.entity.ts
|
||||||
|
│ ├── supplier-order.entity.ts
|
||||||
|
│ ├── supplier-order-item.entity.ts
|
||||||
|
│ ├── supplier-review.entity.ts
|
||||||
|
│ └── supplier-favorites.entity.ts
|
||||||
|
├── messaging/entities/
|
||||||
|
│ ├── conversation.entity.ts
|
||||||
|
│ ├── message.entity.ts
|
||||||
|
│ └── notification.entity.ts
|
||||||
|
├── orders/entities/
|
||||||
|
│ ├── order.entity.ts
|
||||||
|
│ └── order-item.entity.ts
|
||||||
|
├── payments/entities/
|
||||||
|
│ └── payment-method.entity.ts
|
||||||
|
├── products/entities/
|
||||||
|
│ └── product.entity.ts
|
||||||
|
├── referrals/entities/
|
||||||
|
│ ├── referral.entity.ts
|
||||||
|
│ ├── referral-code.entity.ts
|
||||||
|
│ └── referral-reward.entity.ts
|
||||||
|
├── sales/entities/
|
||||||
|
│ ├── sale.entity.ts
|
||||||
|
│ └── sale-item.entity.ts
|
||||||
|
└── subscriptions/entities/
|
||||||
|
├── plan.entity.ts
|
||||||
|
├── subscription.entity.ts
|
||||||
|
├── token-balance.entity.ts
|
||||||
|
└── token-usage.entity.ts
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
*Definicion canonica v1.0.0 - MiChangarrito*
|
## 6. REFERENCIAS
|
||||||
|
|
||||||
|
- Database Schema: @MCH_DEF_DB
|
||||||
|
- Services: @MCH_DEF_SERVICES
|
||||||
|
- Backend Inventory: orchestration/inventarios/BACKEND_INVENTORY.yml
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
*Definicion canonica v2.0.0 - MiChangarrito - VALIDADO*
|
||||||
|
|||||||
@ -4,13 +4,15 @@ type: Definition
|
|||||||
title: "Modules Catalog"
|
title: "Modules Catalog"
|
||||||
simco_version: "4.0.1"
|
simco_version: "4.0.1"
|
||||||
updated_at: 2026-01-17
|
updated_at: 2026-01-17
|
||||||
|
validated: true
|
||||||
---
|
---
|
||||||
|
|
||||||
# Modules Catalog - MiChangarrito
|
# Modules Catalog - MiChangarrito
|
||||||
|
|
||||||
**Alias:** @MCH_DEF_MODULES
|
**Alias:** @MCH_DEF_MODULES
|
||||||
**Version:** 1.0.0
|
**Version:** 2.0.0
|
||||||
**Ultima actualizacion:** 2026-01-17
|
**Ultima actualizacion:** 2026-01-17
|
||||||
|
**Estado:** VALIDADO vs Codigo
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -18,174 +20,342 @@ updated_at: 2026-01-17
|
|||||||
|
|
||||||
| Metrica | Valor |
|
| Metrica | Valor |
|
||||||
|---------|-------|
|
|---------|-------|
|
||||||
| **Total Modulos** | 24 |
|
| **Total Modulos Backend** | 17 |
|
||||||
| **En Produccion** | 24 |
|
| **Total Controllers** | 19 |
|
||||||
| **En Desarrollo** | 0 |
|
| **Total Services** | 18 |
|
||||||
|
| **Total Entities** | 38 |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 2. INDICE DE MODULOS
|
## 2. INDICE DE MODULOS IMPLEMENTADOS
|
||||||
|
|
||||||
### 2.1 Modulos Core (Fase 1)
|
| # | Modulo | Entities | Services | Controllers | Estado |
|
||||||
|
|---|--------|----------|----------|-------------|--------|
|
||||||
| ID | Nombre | Estado | Epica |
|
| 1 | auth | 2 | 1 | 1 | Produccion |
|
||||||
|----|--------|--------|-------|
|
| 2 | billing | 0 | 1 | 1 | Produccion |
|
||||||
| MCH-M01 | Auth | Produccion | MCH-002 |
|
| 3 | categories | 1 | 1 | 1 | Produccion |
|
||||||
| MCH-M02 | Users | Produccion | MCH-001 |
|
| 4 | codi-spei | 3 | 1 | 1 | Produccion |
|
||||||
| MCH-M03 | Stores | Produccion | MCH-001 |
|
| 5 | customers | 3 | 1 | 1 | Produccion |
|
||||||
| MCH-M04 | Products | Produccion | MCH-003 |
|
| 6 | integrations | 2 | 1 | 2 | Produccion |
|
||||||
| MCH-M05 | Sales (POS) | Produccion | MCH-004 |
|
| 7 | inventory | 2 | 1 | 1 | Produccion |
|
||||||
| MCH-M06 | Payments | Produccion | MCH-005 |
|
| 8 | invoices | 3 | 1 | 1 | Produccion |
|
||||||
|
| 9 | marketplace | 6 | 1 | 1 | Produccion |
|
||||||
### 2.2 Modulos Inteligencia (Fase 2-3)
|
| 10 | messaging | 3 | 1 | 1 | Produccion |
|
||||||
|
| 11 | orders | 2 | 1 | 1 | Produccion |
|
||||||
| ID | Nombre | Estado | Epica |
|
| 12 | payments | 1 | 2 | 2 | Produccion |
|
||||||
|----|--------|--------|-------|
|
| 13 | products | 1 | 1 | 1 | Produccion |
|
||||||
| MCH-M07 | Onboarding | Produccion | MCH-006 |
|
| 14 | referrals | 3 | 1 | 1 | Produccion |
|
||||||
| MCH-M08 | Templates | Produccion | MCH-007 |
|
| 15 | sales | 2 | 1 | 1 | Produccion |
|
||||||
| MCH-M09 | Fiados | Produccion | MCH-008 |
|
| 16 | subscriptions | 4 | 1 | 1 | Produccion |
|
||||||
| MCH-M10 | Predictions | Produccion | MCH-009 |
|
| 17 | widgets | 0 | 1 | 1 | Produccion |
|
||||||
| MCH-M11 | MCP Server | Produccion | MCH-010 |
|
|
||||||
| MCH-M12 | WhatsApp | Produccion | MCH-011 |
|
|
||||||
| MCH-M13 | LLM Chat | Produccion | MCH-012/013 |
|
|
||||||
| MCH-M13a | Analytics | Produccion | MCH-016 |
|
|
||||||
|
|
||||||
### 2.3 Modulos Negocio (Fase 4-5)
|
|
||||||
|
|
||||||
| ID | Nombre | Estado | Epica |
|
|
||||||
|----|--------|--------|-------|
|
|
||||||
| MCH-M14 | Customers | Produccion | MCH-014 |
|
|
||||||
| MCH-M15 | Orders | Produccion | MCH-015 |
|
|
||||||
| MCH-M16 | Deliveries | Produccion | MCH-016 |
|
|
||||||
| MCH-M17 | Notifications | Produccion | MCH-017 |
|
|
||||||
| MCH-M18 | Subscriptions | Produccion | MCH-018/019/020 |
|
|
||||||
| MCH-M19 | Offline | Produccion | MCH-022 |
|
|
||||||
| MCH-M20 | Referrals | Produccion | MCH-023 |
|
|
||||||
| MCH-M21 | CoDi/SPEI | Produccion | MCH-024 |
|
|
||||||
| MCH-M22 | Widgets | Produccion | MCH-025 |
|
|
||||||
| MCH-M23 | i18n | Produccion | MCH-026 |
|
|
||||||
| MCH-M24 | SAT/Facturacion | Produccion | MCH-027 |
|
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 3. DETALLE POR MODULO
|
## 3. DETALLE POR MODULO
|
||||||
|
|
||||||
### MCH-M01: Auth
|
### 3.1 auth
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
modulo:
|
modulo:
|
||||||
id: "MCH-M01"
|
nombre: "auth"
|
||||||
nombre: "Authentication"
|
ruta: "backend/src/modules/auth"
|
||||||
estado: "produccion"
|
estado: "produccion"
|
||||||
version: "1.0.0"
|
descripcion: "Autenticacion JWT multi-tenant"
|
||||||
|
|
||||||
documentacion:
|
|
||||||
especificacion: "docs/01-epicas/MCH-002-autenticacion.md"
|
|
||||||
requerimientos: ["RF-AUTH-001", "RF-AUTH-002"]
|
|
||||||
|
|
||||||
objetos:
|
objetos:
|
||||||
tablas: ["users", "sessions", "refresh_tokens"]
|
entities: [Tenant, User]
|
||||||
entities: ["User", "Session", "RefreshToken"]
|
services: [AuthService]
|
||||||
services: ["AuthService", "JwtService", "SessionService"]
|
controllers: [AuthController]
|
||||||
controllers: ["AuthController"]
|
guards: [JwtAuthGuard]
|
||||||
|
strategies: [JwtStrategy]
|
||||||
|
|
||||||
dependencias:
|
endpoints:
|
||||||
modulos: []
|
- POST /v1/auth/register
|
||||||
externos: ["@nestjs/jwt", "@nestjs/passport"]
|
- POST /v1/auth/login
|
||||||
|
- POST /v1/auth/refresh
|
||||||
|
- POST /v1/auth/change-pin
|
||||||
```
|
```
|
||||||
|
|
||||||
### MCH-M05: Sales (POS)
|
### 3.2 billing
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
modulo:
|
modulo:
|
||||||
id: "MCH-M05"
|
nombre: "billing"
|
||||||
nombre: "Punto de Venta"
|
ruta: "backend/src/modules/billing"
|
||||||
estado: "produccion"
|
estado: "produccion"
|
||||||
version: "1.0.0"
|
descripcion: "Facturacion CFDI 4.0"
|
||||||
|
|
||||||
documentacion:
|
|
||||||
especificacion: "docs/01-epicas/MCH-004-punto-venta.md"
|
|
||||||
requerimientos: ["RF-POS-001", "RF-POS-002", "RF-POS-003"]
|
|
||||||
|
|
||||||
objetos:
|
objetos:
|
||||||
tablas: ["sales", "sale_items", "payments", "cash_registers"]
|
entities: []
|
||||||
entities: ["Sale", "SaleItem", "Payment", "CashRegister"]
|
services: [BillingService]
|
||||||
services: ["SalesService", "PaymentsService", "CashRegisterService"]
|
controllers: [BillingController]
|
||||||
controllers: ["SalesController", "PaymentsController"]
|
|
||||||
|
|
||||||
dependencias:
|
|
||||||
modulos: ["MCH-M04", "MCH-M14"]
|
|
||||||
externos: ["stripe"]
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### MCH-M09: Fiados
|
### 3.3 categories
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
modulo:
|
modulo:
|
||||||
id: "MCH-M09"
|
nombre: "categories"
|
||||||
nombre: "Sistema Fiados"
|
ruta: "backend/src/modules/categories"
|
||||||
estado: "produccion"
|
estado: "produccion"
|
||||||
version: "1.0.0"
|
descripcion: "Categorias de productos"
|
||||||
|
|
||||||
documentacion:
|
|
||||||
especificacion: "docs/01-epicas/MCH-008-sistema-fiados.md"
|
|
||||||
|
|
||||||
objetos:
|
objetos:
|
||||||
tablas: ["fiados", "fiado_payments", "credit_limits"]
|
entities: [Category]
|
||||||
entities: ["Fiado", "FiadoPayment", "CreditLimit"]
|
services: [CategoriesService]
|
||||||
services: ["FiadosService", "CreditService"]
|
controllers: [CategoriesController]
|
||||||
controllers: ["FiadosController"]
|
|
||||||
|
|
||||||
dependencias:
|
endpoints:
|
||||||
modulos: ["MCH-M14", "MCH-M05"]
|
- GET /v1/categories
|
||||||
externos: []
|
- GET /v1/categories/:id
|
||||||
|
- POST /v1/categories
|
||||||
|
- PUT /v1/categories/:id
|
||||||
|
- DELETE /v1/categories/:id
|
||||||
```
|
```
|
||||||
|
|
||||||
### MCH-M10: Predictions
|
### 3.4 codi-spei
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
modulo:
|
modulo:
|
||||||
id: "MCH-M10"
|
nombre: "codi-spei"
|
||||||
nombre: "Predictions"
|
ruta: "backend/src/modules/codi-spei"
|
||||||
estado: "produccion"
|
estado: "produccion"
|
||||||
version: "1.0.0"
|
descripcion: "Pagos CoDi y transferencias SPEI"
|
||||||
|
|
||||||
documentacion:
|
|
||||||
especificacion: "docs/01-epicas/MCH-009-prediccion-inventario.md"
|
|
||||||
|
|
||||||
objetos:
|
objetos:
|
||||||
tablas: ["inventory_predictions", "reorder_suggestions"]
|
entities: [CodiTransaction, SpeiTransaction, VirtualAccount]
|
||||||
entities: ["InventoryPrediction", "ReorderSuggestion"]
|
services: [CodiSpeiService]
|
||||||
services: ["PredictionsService", "ReorderService", "AlertsService"]
|
controllers: [CodiSpeiController]
|
||||||
controllers: ["PredictionsController"]
|
|
||||||
|
|
||||||
dependencias:
|
|
||||||
modulos: ["MCH-M04", "MCH-M05"]
|
|
||||||
externos: []
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### MCH-M11: MCP Server
|
### 3.5 customers
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
modulo:
|
modulo:
|
||||||
id: "MCH-M11"
|
nombre: "customers"
|
||||||
nombre: "MCP Server"
|
ruta: "backend/src/modules/customers"
|
||||||
estado: "produccion"
|
estado: "produccion"
|
||||||
version: "1.0.0"
|
descripcion: "Clientes y sistema de fiados"
|
||||||
|
|
||||||
documentacion:
|
|
||||||
especificacion: "docs/01-epicas/MCH-010-mcp-server.md"
|
|
||||||
requerimientos: ["RF-MCP-001", "RF-MCP-002"]
|
|
||||||
|
|
||||||
objetos:
|
objetos:
|
||||||
tablas: ["conversations", "messages", "tool_calls"]
|
entities: [Customer, Fiado, FiadoPayment]
|
||||||
entities: ["Conversation", "Message", "ToolCall"]
|
services: [CustomersService]
|
||||||
services: ["MCPService", "ToolsService", "ConversationsService"]
|
controllers: [CustomersController]
|
||||||
controllers: ["MCPController"]
|
|
||||||
|
|
||||||
dependencias:
|
endpoints:
|
||||||
modulos: ["MCH-M04", "MCH-M05", "MCH-M09", "MCH-M14"]
|
- GET /v1/customers
|
||||||
externos: ["openrouter", "@anthropic-ai/sdk"]
|
- GET /v1/customers/:id
|
||||||
|
- POST /v1/customers
|
||||||
|
- PUT /v1/customers/:id
|
||||||
|
- DELETE /v1/customers/:id
|
||||||
|
- GET /v1/customers/:id/fiados
|
||||||
|
- POST /v1/customers/:id/fiados
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3.6 integrations
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
modulo:
|
||||||
|
nombre: "integrations"
|
||||||
|
ruta: "backend/src/modules/integrations"
|
||||||
|
estado: "produccion"
|
||||||
|
descripcion: "Integraciones externas por tenant"
|
||||||
|
|
||||||
|
objetos:
|
||||||
|
entities: [TenantIntegrationCredential, TenantWhatsappNumber]
|
||||||
|
services: [TenantIntegrationsService]
|
||||||
|
controllers: [IntegrationsController, InternalIntegrationsController]
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3.7 inventory
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
modulo:
|
||||||
|
nombre: "inventory"
|
||||||
|
ruta: "backend/src/modules/inventory"
|
||||||
|
estado: "produccion"
|
||||||
|
descripcion: "Control de stock y alertas"
|
||||||
|
|
||||||
|
objetos:
|
||||||
|
entities: [InventoryMovement, StockAlert]
|
||||||
|
services: [InventoryService]
|
||||||
|
controllers: [InventoryController]
|
||||||
|
|
||||||
|
endpoints:
|
||||||
|
- GET /v1/inventory/movements
|
||||||
|
- POST /v1/inventory/adjust
|
||||||
|
- GET /v1/inventory/alerts
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3.8 invoices
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
modulo:
|
||||||
|
nombre: "invoices"
|
||||||
|
ruta: "backend/src/modules/invoices"
|
||||||
|
estado: "produccion"
|
||||||
|
descripcion: "Facturas CFDI"
|
||||||
|
|
||||||
|
objetos:
|
||||||
|
entities: [Invoice, InvoiceItem, TaxConfig]
|
||||||
|
services: [InvoicesService]
|
||||||
|
controllers: [InvoicesController]
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3.9 marketplace
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
modulo:
|
||||||
|
nombre: "marketplace"
|
||||||
|
ruta: "backend/src/modules/marketplace"
|
||||||
|
estado: "produccion"
|
||||||
|
descripcion: "Marketplace B2B de proveedores"
|
||||||
|
|
||||||
|
objetos:
|
||||||
|
entities: [Supplier, SupplierProduct, SupplierOrder, SupplierOrderItem, SupplierReview, SupplierFavorites]
|
||||||
|
services: [MarketplaceService]
|
||||||
|
controllers: [MarketplaceController]
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3.10 messaging
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
modulo:
|
||||||
|
nombre: "messaging"
|
||||||
|
ruta: "backend/src/modules/messaging"
|
||||||
|
estado: "produccion"
|
||||||
|
descripcion: "Conversaciones y notificaciones"
|
||||||
|
|
||||||
|
objetos:
|
||||||
|
entities: [Conversation, Message, Notification]
|
||||||
|
services: [MessagingService]
|
||||||
|
controllers: [MessagingController]
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3.11 orders
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
modulo:
|
||||||
|
nombre: "orders"
|
||||||
|
ruta: "backend/src/modules/orders"
|
||||||
|
estado: "produccion"
|
||||||
|
descripcion: "Pedidos de clientes"
|
||||||
|
|
||||||
|
objetos:
|
||||||
|
entities: [Order, OrderItem]
|
||||||
|
services: [OrdersService]
|
||||||
|
controllers: [OrdersController]
|
||||||
|
|
||||||
|
endpoints:
|
||||||
|
- GET /v1/orders
|
||||||
|
- GET /v1/orders/:id
|
||||||
|
- POST /v1/orders
|
||||||
|
- PATCH /v1/orders/:id/status
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3.12 payments
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
modulo:
|
||||||
|
nombre: "payments"
|
||||||
|
ruta: "backend/src/modules/payments"
|
||||||
|
estado: "produccion"
|
||||||
|
descripcion: "Metodos de pago y Stripe"
|
||||||
|
|
||||||
|
objetos:
|
||||||
|
entities: [PaymentMethod]
|
||||||
|
services: [PaymentsService, StripeService]
|
||||||
|
controllers: [PaymentsController, WebhooksController]
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3.13 products
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
modulo:
|
||||||
|
nombre: "products"
|
||||||
|
ruta: "backend/src/modules/products"
|
||||||
|
estado: "produccion"
|
||||||
|
descripcion: "Catalogo de productos"
|
||||||
|
|
||||||
|
objetos:
|
||||||
|
entities: [Product]
|
||||||
|
services: [ProductsService]
|
||||||
|
controllers: [ProductsController]
|
||||||
|
|
||||||
|
endpoints:
|
||||||
|
- GET /v1/products
|
||||||
|
- GET /v1/products/:id
|
||||||
|
- GET /v1/products/barcode/:barcode
|
||||||
|
- POST /v1/products
|
||||||
|
- PUT /v1/products/:id
|
||||||
|
- DELETE /v1/products/:id
|
||||||
|
- PATCH /v1/products/:id/adjust-stock
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3.14 referrals
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
modulo:
|
||||||
|
nombre: "referrals"
|
||||||
|
ruta: "backend/src/modules/referrals"
|
||||||
|
estado: "produccion"
|
||||||
|
descripcion: "Sistema de referidos"
|
||||||
|
|
||||||
|
objetos:
|
||||||
|
entities: [Referral, ReferralCode, ReferralReward]
|
||||||
|
services: [ReferralsService]
|
||||||
|
controllers: [ReferralsController]
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3.15 sales
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
modulo:
|
||||||
|
nombre: "sales"
|
||||||
|
ruta: "backend/src/modules/sales"
|
||||||
|
estado: "produccion"
|
||||||
|
descripcion: "Punto de venta POS"
|
||||||
|
|
||||||
|
objetos:
|
||||||
|
entities: [Sale, SaleItem]
|
||||||
|
services: [SalesService]
|
||||||
|
controllers: [SalesController]
|
||||||
|
|
||||||
|
endpoints:
|
||||||
|
- GET /v1/sales
|
||||||
|
- GET /v1/sales/:id
|
||||||
|
- POST /v1/sales
|
||||||
|
- GET /v1/sales/daily-summary
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3.16 subscriptions
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
modulo:
|
||||||
|
nombre: "subscriptions"
|
||||||
|
ruta: "backend/src/modules/subscriptions"
|
||||||
|
estado: "produccion"
|
||||||
|
descripcion: "Planes y tokens IA"
|
||||||
|
|
||||||
|
objetos:
|
||||||
|
entities: [Plan, Subscription, TokenBalance, TokenUsage]
|
||||||
|
services: [SubscriptionsService]
|
||||||
|
controllers: [SubscriptionsController]
|
||||||
|
```
|
||||||
|
|
||||||
|
### 3.17 widgets
|
||||||
|
|
||||||
|
```yaml
|
||||||
|
modulo:
|
||||||
|
nombre: "widgets"
|
||||||
|
ruta: "backend/src/modules/widgets"
|
||||||
|
estado: "produccion"
|
||||||
|
descripcion: "Widgets y atajos"
|
||||||
|
|
||||||
|
objetos:
|
||||||
|
entities: []
|
||||||
|
services: [WidgetsService]
|
||||||
|
controllers: [WidgetsController]
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
@ -193,33 +363,54 @@ modulo:
|
|||||||
## 4. MATRIZ DE DEPENDENCIAS
|
## 4. MATRIZ DE DEPENDENCIAS
|
||||||
|
|
||||||
```
|
```
|
||||||
┌────────────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┐
|
Leyenda: X = depende de
|
||||||
│ │ Auth │ User │Store │ Prod │ Sale │ Cust │ Pred │ MCP │
|
|
||||||
├────────────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┼──────┤
|
|
||||||
│ Auth │ - │ -> │ │ │ │ │ │ │
|
|
||||||
│ Users │ <- │ - │ -> │ │ │ │ │ │
|
|
||||||
│ Stores │ │ <- │ - │ -> │ -> │ -> │ │ │
|
|
||||||
│ Products │ │ │ <- │ - │ │ │ -> │ -> │
|
|
||||||
│ Sales │ │ │ <- │ <- │ - │ <- │ -> │ -> │
|
|
||||||
│ Customers │ │ │ <- │ │ -> │ - │ │ -> │
|
|
||||||
│ Fiados │ │ │ │ │ <- │ <- │ │ -> │
|
|
||||||
│ Orders │ │ │ <- │ <- │ │ <- │ │ │
|
|
||||||
│ Predictions│ │ │ │ <- │ <- │ │ - │ │
|
|
||||||
│ MCP │ │ │ │ <- │ <- │ <- │ │ - │
|
|
||||||
└────────────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┘
|
|
||||||
|
|
||||||
Leyenda: -> depende de, <- es dependido por
|
auth cat cust inv prod sales subs mark msg
|
||||||
|
auth -
|
||||||
|
categories -
|
||||||
|
customers -
|
||||||
|
inventory - X
|
||||||
|
products -
|
||||||
|
sales X X X X -
|
||||||
|
subscriptions X -
|
||||||
|
marketplace X -
|
||||||
|
messaging X -
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 5. REFERENCIAS
|
## 5. UBICACION EN CODIGO
|
||||||
|
|
||||||
- Database: @MCH_DEF_DB
|
```
|
||||||
- Entities: @MCH_DEF_ENTITIES
|
backend/src/modules/
|
||||||
- Services: @MCH_DEF_SERVICES
|
├── auth/
|
||||||
- Navegacion rapida: @MCH_QUICK_MODULES
|
├── billing/
|
||||||
|
├── categories/
|
||||||
|
├── codi-spei/
|
||||||
|
├── customers/
|
||||||
|
├── integrations/
|
||||||
|
├── inventory/
|
||||||
|
├── invoices/
|
||||||
|
├── marketplace/
|
||||||
|
├── messaging/
|
||||||
|
├── orders/
|
||||||
|
├── payments/
|
||||||
|
├── products/
|
||||||
|
├── referrals/
|
||||||
|
├── sales/
|
||||||
|
├── subscriptions/
|
||||||
|
└── widgets/
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
*Definicion canonica v1.0.0 - MiChangarrito*
|
## 6. REFERENCIAS
|
||||||
|
|
||||||
|
- Entities: @MCH_DEF_ENTITIES
|
||||||
|
- Services: @MCH_DEF_SERVICES
|
||||||
|
- Database: @MCH_DEF_DB
|
||||||
|
- Backend Inventory: orchestration/inventarios/BACKEND_INVENTORY.yml
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
*Definicion canonica v2.0.0 - MiChangarrito - VALIDADO*
|
||||||
|
|||||||
@ -4,13 +4,15 @@ type: Definition
|
|||||||
title: "Services Catalog"
|
title: "Services Catalog"
|
||||||
simco_version: "4.0.1"
|
simco_version: "4.0.1"
|
||||||
updated_at: 2026-01-17
|
updated_at: 2026-01-17
|
||||||
|
validated: true
|
||||||
---
|
---
|
||||||
|
|
||||||
# Services Catalog - MiChangarrito
|
# Services Catalog - MiChangarrito
|
||||||
|
|
||||||
**Alias:** @MCH_DEF_SERVICES
|
**Alias:** @MCH_DEF_SERVICES
|
||||||
**Version:** 1.0.0
|
**Version:** 2.0.0
|
||||||
**Ultima actualizacion:** 2026-01-17
|
**Ultima actualizacion:** 2026-01-17
|
||||||
|
**Estado:** VALIDADO vs Codigo
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -18,117 +20,115 @@ updated_at: 2026-01-17
|
|||||||
|
|
||||||
| Metrica | Valor |
|
| Metrica | Valor |
|
||||||
|---------|-------|
|
|---------|-------|
|
||||||
| **Total Services** | 30+ |
|
| **Total Services** | 18 |
|
||||||
| **Por Modulo** | Ver seccion 2 |
|
| **Por Modulo** | Ver seccion 2 |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 2. SERVICES POR MODULO
|
## 2. SERVICES POR MODULO
|
||||||
|
|
||||||
### 2.1 Modulo: Auth
|
### 2.1 Auth
|
||||||
|
|
||||||
| Service | Archivo | Dependencias | Descripcion |
|
| Service | Archivo | Descripcion |
|
||||||
|---------|---------|--------------|-------------|
|
|---------|---------|-------------|
|
||||||
| AuthService | `auth.service.ts` | JwtService, UsersService | Autenticacion de usuarios |
|
| AuthService | `auth.service.ts` | Autenticacion JWT, registro, login |
|
||||||
| JwtService | `jwt.service.ts` | ConfigService | Generacion/validacion JWT |
|
|
||||||
| SessionService | `session.service.ts` | Repository | Gestion de sesiones |
|
|
||||||
|
|
||||||
### 2.2 Modulo: Users
|
### 2.2 Billing
|
||||||
|
|
||||||
| Service | Archivo | Dependencias | Descripcion |
|
| Service | Archivo | Descripcion |
|
||||||
|---------|---------|--------------|-------------|
|
|---------|---------|-------------|
|
||||||
| UsersService | `users.service.ts` | Repository | CRUD de usuarios |
|
| BillingService | `billing.service.ts` | Facturacion CFDI 4.0 |
|
||||||
|
|
||||||
### 2.3 Modulo: Stores
|
### 2.3 Categories
|
||||||
|
|
||||||
| Service | Archivo | Dependencias | Descripcion |
|
| Service | Archivo | Descripcion |
|
||||||
|---------|---------|--------------|-------------|
|
|---------|---------|-------------|
|
||||||
| StoresService | `stores.service.ts` | Repository | CRUD de tiendas |
|
| CategoriesService | `categories.service.ts` | CRUD de categorias |
|
||||||
| StoreSettingsService | `store-settings.service.ts` | Repository | Configuracion de tiendas |
|
|
||||||
|
|
||||||
### 2.4 Modulo: Products
|
### 2.4 CoDi-SPEI
|
||||||
|
|
||||||
| Service | Archivo | Dependencias | Descripcion |
|
| Service | Archivo | Descripcion |
|
||||||
|---------|---------|--------------|-------------|
|
|---------|---------|-------------|
|
||||||
| ProductsService | `products.service.ts` | Repository | CRUD de productos |
|
| CodiSpeiService | `codi-spei.service.ts` | Transacciones CoDi y SPEI |
|
||||||
| CategoriesService | `categories.service.ts` | Repository | CRUD de categorias |
|
|
||||||
| InventoryService | `inventory.service.ts` | Repository | Control de stock |
|
|
||||||
|
|
||||||
### 2.5 Modulo: Sales (POS)
|
### 2.5 Customers
|
||||||
|
|
||||||
| Service | Archivo | Dependencias | Descripcion |
|
| Service | Archivo | Descripcion |
|
||||||
|---------|---------|--------------|-------------|
|
|---------|---------|-------------|
|
||||||
| SalesService | `sales.service.ts` | Repository, ProductsService | Procesamiento de ventas |
|
| CustomersService | `customers.service.ts` | CRUD de clientes y fiados |
|
||||||
| PaymentsService | `payments.service.ts` | StripeService | Procesamiento de pagos |
|
|
||||||
| CashRegisterService | `cash-register.service.ts` | Repository | Control de caja |
|
|
||||||
|
|
||||||
### 2.6 Modulo: Customers
|
### 2.6 Integrations
|
||||||
|
|
||||||
| Service | Archivo | Dependencias | Descripcion |
|
| Service | Archivo | Descripcion |
|
||||||
|---------|---------|--------------|-------------|
|
|---------|---------|-------------|
|
||||||
| CustomersService | `customers.service.ts` | Repository | CRUD de clientes |
|
| TenantIntegrationsService | `tenant-integrations.service.ts` | Credenciales por tenant |
|
||||||
|
|
||||||
### 2.7 Modulo: Fiados
|
### 2.7 Inventory
|
||||||
|
|
||||||
| Service | Archivo | Dependencias | Descripcion |
|
| Service | Archivo | Descripcion |
|
||||||
|---------|---------|--------------|-------------|
|
|---------|---------|-------------|
|
||||||
| FiadosService | `fiados.service.ts` | Repository, CustomersService | Gestion de creditos |
|
| InventoryService | `inventory.service.ts` | Control de stock y movimientos |
|
||||||
| CreditService | `credit.service.ts` | Repository | Limites de credito |
|
|
||||||
|
|
||||||
### 2.8 Modulo: Orders
|
### 2.8 Invoices
|
||||||
|
|
||||||
| Service | Archivo | Dependencias | Descripcion |
|
| Service | Archivo | Descripcion |
|
||||||
|---------|---------|--------------|-------------|
|
|---------|---------|-------------|
|
||||||
| OrdersService | `orders.service.ts` | Repository, ProductsService | Gestion de pedidos |
|
| InvoicesService | `invoices.service.ts` | Gestion de facturas |
|
||||||
| DeliveriesService | `deliveries.service.ts` | Repository | Entregas a domicilio |
|
|
||||||
|
|
||||||
### 2.9 Modulo: Subscriptions
|
### 2.9 Marketplace
|
||||||
|
|
||||||
| Service | Archivo | Dependencias | Descripcion |
|
| Service | Archivo | Descripcion |
|
||||||
|---------|---------|--------------|-------------|
|
|---------|---------|-------------|
|
||||||
| SubscriptionsService | `subscriptions.service.ts` | Repository, StripeService | Gestion de suscripciones |
|
| MarketplaceService | `marketplace.service.ts` | Proveedores B2B y ordenes |
|
||||||
| PlansService | `plans.service.ts` | Repository | CRUD de planes |
|
|
||||||
| TokensService | `tokens.service.ts` | Repository | Gestion de tokens IA |
|
|
||||||
|
|
||||||
### 2.10 Modulo: Integraciones
|
### 2.10 Messaging
|
||||||
|
|
||||||
| Service | Archivo | Dependencias | Descripcion |
|
| Service | Archivo | Descripcion |
|
||||||
|---------|---------|--------------|-------------|
|
|---------|---------|-------------|
|
||||||
| WhatsAppService | `whatsapp.service.ts` | HttpService, ConfigService | Integracion Meta API |
|
| MessagingService | `messaging.service.ts` | Conversaciones y notificaciones |
|
||||||
| LLMService | `llm.service.ts` | HttpService, ConfigService | Integracion OpenRouter |
|
|
||||||
| StripeService | `stripe.service.ts` | Stripe SDK | Integracion Stripe |
|
|
||||||
|
|
||||||
### 2.11 Modulo: MCP Server
|
### 2.11 Orders
|
||||||
|
|
||||||
| Service | Archivo | Dependencias | Descripcion |
|
| Service | Archivo | Descripcion |
|
||||||
|---------|---------|--------------|-------------|
|
|---------|---------|-------------|
|
||||||
| MCPService | `mcp.service.ts` | LLMService, ToolsRegistry | Gateway LLM agnostico |
|
| OrdersService | `orders.service.ts` | Gestion de pedidos |
|
||||||
| ToolsService | `tools.service.ts` | ProductsService, SalesService | Ejecutor de tools MCP |
|
|
||||||
| ConversationsService | `conversations.service.ts` | Repository | Gestion de conversaciones IA |
|
|
||||||
|
|
||||||
### 2.12 Modulo: Predictions
|
### 2.12 Payments
|
||||||
|
|
||||||
| Service | Archivo | Dependencias | Descripcion |
|
| Service | Archivo | Descripcion |
|
||||||
|---------|---------|--------------|-------------|
|
|---------|---------|-------------|
|
||||||
| PredictionsService | `predictions.service.ts` | Repository, SalesService | Prediccion de demanda |
|
| PaymentsService | `payments.service.ts` | Metodos de pago |
|
||||||
| ReorderService | `reorder.service.ts` | Repository, InventoryService | Sugerencias de reorden |
|
| StripeService | `stripe.service.ts` | Integracion Stripe |
|
||||||
| AlertsService | `alerts.service.ts` | Repository, NotificationsService | Alertas de stock bajo |
|
|
||||||
|
|
||||||
### 2.13 Modulo: Onboarding
|
### 2.13 Products
|
||||||
|
|
||||||
| Service | Archivo | Dependencias | Descripcion |
|
| Service | Archivo | Descripcion |
|
||||||
|---------|---------|--------------|-------------|
|
|---------|---------|-------------|
|
||||||
| OnboardingService | `onboarding.service.ts` | Repository, WhatsAppService | Flujo de onboarding |
|
| ProductsService | `products.service.ts` | CRUD de productos |
|
||||||
| OCRService | `ocr.service.ts` | GoogleVisionClient | Procesamiento de imagenes |
|
|
||||||
| TranscriptionService | `transcription.service.ts` | WhisperClient | Transcripcion de audio |
|
|
||||||
|
|
||||||
### 2.14 Modulo: Notifications
|
### 2.14 Referrals
|
||||||
|
|
||||||
| Service | Archivo | Dependencias | Descripcion |
|
| Service | Archivo | Descripcion |
|
||||||
|---------|---------|--------------|-------------|
|
|---------|---------|-------------|
|
||||||
| NotificationsService | `notifications.service.ts` | Repository, FCMService | Gestion de notificaciones |
|
| ReferralsService | `referrals.service.ts` | Sistema de referidos |
|
||||||
| FCMService | `fcm.service.ts` | Firebase Admin | Push notifications |
|
|
||||||
| EmailService | `email.service.ts` | SendGridClient | Envio de emails |
|
### 2.15 Sales
|
||||||
|
|
||||||
|
| Service | Archivo | Descripcion |
|
||||||
|
|---------|---------|-------------|
|
||||||
|
| SalesService | `sales.service.ts` | Punto de venta |
|
||||||
|
|
||||||
|
### 2.16 Subscriptions
|
||||||
|
|
||||||
|
| Service | Archivo | Descripcion |
|
||||||
|
|---------|---------|-------------|
|
||||||
|
| SubscriptionsService | `subscriptions.service.ts` | Planes y tokens IA |
|
||||||
|
|
||||||
|
### 2.17 Widgets
|
||||||
|
|
||||||
|
| Service | Archivo | Descripcion |
|
||||||
|
|---------|---------|-------------|
|
||||||
|
| WidgetsService | `widgets.service.ts` | Widgets y atajos |
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
@ -137,66 +137,69 @@ updated_at: 2026-01-17
|
|||||||
```yaml
|
```yaml
|
||||||
dependencias:
|
dependencias:
|
||||||
AuthService:
|
AuthService:
|
||||||
inyecta:
|
inyecta: [JwtService, ConfigService]
|
||||||
- JwtService
|
inyectado_en: [AuthController, JwtAuthGuard]
|
||||||
- UsersService
|
|
||||||
- SessionService
|
|
||||||
inyectado_en:
|
|
||||||
- AuthController
|
|
||||||
- JwtAuthGuard
|
|
||||||
|
|
||||||
SalesService:
|
SalesService:
|
||||||
inyecta:
|
inyecta: [ProductsService, InventoryService, CustomersService]
|
||||||
- ProductsService
|
inyectado_en: [SalesController]
|
||||||
- InventoryService
|
|
||||||
- PaymentsService
|
|
||||||
inyectado_en:
|
|
||||||
- SalesController
|
|
||||||
- OrdersService
|
|
||||||
|
|
||||||
FiadosService:
|
CustomersService:
|
||||||
inyecta:
|
inyecta: [Repository]
|
||||||
- CustomersService
|
inyectado_en: [CustomersController, SalesService]
|
||||||
- CreditService
|
|
||||||
inyectado_en:
|
|
||||||
- FiadosController
|
|
||||||
- SalesService
|
|
||||||
|
|
||||||
WhatsAppService:
|
InventoryService:
|
||||||
inyecta:
|
inyecta: [ProductsService]
|
||||||
- HttpService
|
inyectado_en: [InventoryController, SalesService]
|
||||||
- ConfigService
|
|
||||||
- LLMService
|
|
||||||
inyectado_en:
|
|
||||||
- WhatsAppController
|
|
||||||
- OrdersService
|
|
||||||
- NotificationsService
|
|
||||||
|
|
||||||
MCPService:
|
SubscriptionsService:
|
||||||
inyecta:
|
inyecta: [StripeService, Repository]
|
||||||
- LLMService
|
inyectado_en: [SubscriptionsController]
|
||||||
- ToolsService
|
|
||||||
inyectado_en:
|
|
||||||
- WhatsAppService
|
|
||||||
- ChatController
|
|
||||||
|
|
||||||
PredictionsService:
|
MarketplaceService:
|
||||||
inyecta:
|
inyecta: [Repository]
|
||||||
- SalesService
|
inyectado_en: [MarketplaceController]
|
||||||
- InventoryService
|
|
||||||
inyectado_en:
|
MessagingService:
|
||||||
- MCPService
|
inyecta: [Repository, NotificationGateway]
|
||||||
- ReportsController
|
inyectado_en: [MessagingController]
|
||||||
```
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 4. REFERENCIAS
|
## 4. UBICACION EN CODIGO
|
||||||
|
|
||||||
- Entities: @MCH_DEF_ENTITIES
|
```
|
||||||
- Controllers: Ver documentacion API en `/api/docs`
|
backend/src/modules/
|
||||||
- Ubicacion: `apps/backend/src/modules/*/services/`
|
├── auth/auth.service.ts
|
||||||
|
├── billing/billing.service.ts
|
||||||
|
├── categories/categories.service.ts
|
||||||
|
├── codi-spei/codi-spei.service.ts
|
||||||
|
├── customers/customers.service.ts
|
||||||
|
├── integrations/tenant-integrations.service.ts
|
||||||
|
├── inventory/inventory.service.ts
|
||||||
|
├── invoices/invoices.service.ts
|
||||||
|
├── marketplace/marketplace.service.ts
|
||||||
|
├── messaging/messaging.service.ts
|
||||||
|
├── orders/orders.service.ts
|
||||||
|
├── payments/
|
||||||
|
│ ├── payments.service.ts
|
||||||
|
│ └── stripe.service.ts
|
||||||
|
├── products/products.service.ts
|
||||||
|
├── referrals/referrals.service.ts
|
||||||
|
├── sales/sales.service.ts
|
||||||
|
├── subscriptions/subscriptions.service.ts
|
||||||
|
└── widgets/widgets.service.ts
|
||||||
|
```
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
*Definicion canonica v1.0.0 - MiChangarrito*
|
## 5. REFERENCIAS
|
||||||
|
|
||||||
|
- Entities: @MCH_DEF_ENTITIES
|
||||||
|
- Modules: @MCH_DEF_MODULES
|
||||||
|
- Backend Inventory: orchestration/inventarios/BACKEND_INVENTORY.yml
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
*Definicion canonica v2.0.0 - MiChangarrito - VALIDADO*
|
||||||
|
|||||||
@ -1,13 +1,14 @@
|
|||||||
# Indice de Definiciones del Proyecto
|
# Indice de Definiciones del Proyecto
|
||||||
# Proyecto: michangarrito
|
# Proyecto: michangarrito
|
||||||
# Fecha: 2026-01-16
|
# Fecha: 2026-01-17
|
||||||
|
# Estado: VALIDADO vs Codigo
|
||||||
|
|
||||||
version: "1.1.0"
|
version: "2.0.0"
|
||||||
simco_version: "4.0.1"
|
simco_version: "4.0.1"
|
||||||
proyecto: "michangarrito"
|
proyecto: "michangarrito"
|
||||||
fecha_creacion: "2026-01-16"
|
fecha_creacion: "2026-01-16"
|
||||||
fecha_actualizacion: "2026-01-17"
|
fecha_actualizacion: "2026-01-17"
|
||||||
descripcion: "Definiciones canonicas del proyecto MiChangarrito"
|
descripcion: "Definiciones canonicas del proyecto MiChangarrito - VALIDADAS"
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# REFERENCIAS A WORKSPACE (Definiciones Globales)
|
# REFERENCIAS A WORKSPACE (Definiciones Globales)
|
||||||
@ -24,41 +25,36 @@ referencias_workspace:
|
|||||||
devops: "@WS_DEF_VAL_DEVOPS"
|
devops: "@WS_DEF_VAL_DEVOPS"
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# DEFINICIONES LOCALES DEL PROYECTO
|
# DEFINICIONES LOCALES DEL PROYECTO (VALIDADAS)
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
definiciones_locales:
|
definiciones_locales:
|
||||||
database:
|
database:
|
||||||
archivo: "DATABASE-SCHEMA.md"
|
archivo: "DATABASE-SCHEMA.md"
|
||||||
alias: "@MCH_DEF_DB"
|
alias: "@MCH_DEF_DB"
|
||||||
descripcion: "Schema canonico de base de datos MiChangarrito"
|
descripcion: "Schema de base de datos (TypeORM entities)"
|
||||||
tablas_principales:
|
validado: true
|
||||||
- users
|
tablas: 38 # Corresponde 1:1 con entities
|
||||||
- stores
|
|
||||||
- products
|
|
||||||
- sales
|
|
||||||
- orders
|
|
||||||
- customers
|
|
||||||
- fiados
|
|
||||||
- subscriptions
|
|
||||||
- tokens
|
|
||||||
|
|
||||||
entities:
|
entities:
|
||||||
archivo: "ENTITIES-CATALOG.md"
|
archivo: "ENTITIES-CATALOG.md"
|
||||||
alias: "@MCH_DEF_ENTITIES"
|
alias: "@MCH_DEF_ENTITIES"
|
||||||
descripcion: "Catalogo de entidades del proyecto"
|
descripcion: "Catalogo de entidades del proyecto"
|
||||||
total_entities: 35
|
validado: true
|
||||||
|
total_entities: 38 # VALIDADO vs codigo
|
||||||
|
|
||||||
services:
|
services:
|
||||||
archivo: "SERVICES-CATALOG.md"
|
archivo: "SERVICES-CATALOG.md"
|
||||||
alias: "@MCH_DEF_SERVICES"
|
alias: "@MCH_DEF_SERVICES"
|
||||||
descripcion: "Catalogo de servicios del proyecto"
|
descripcion: "Catalogo de servicios del proyecto"
|
||||||
total_services: 30
|
validado: true
|
||||||
|
total_services: 18 # VALIDADO vs codigo
|
||||||
|
|
||||||
modules:
|
modules:
|
||||||
archivo: "MODULES-CATALOG.md"
|
archivo: "MODULES-CATALOG.md"
|
||||||
alias: "@MCH_DEF_MODULES"
|
alias: "@MCH_DEF_MODULES"
|
||||||
descripcion: "Catalogo de modulos del proyecto"
|
descripcion: "Catalogo de modulos del proyecto"
|
||||||
total_modules: 24
|
validado: true
|
||||||
|
total_modules: 17 # VALIDADO vs codigo
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# HERENCIA (Proyecto Independiente)
|
# HERENCIA (Proyecto Independiente)
|
||||||
@ -69,9 +65,24 @@ herencia:
|
|||||||
definiciones_heredadas: []
|
definiciones_heredadas: []
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
# ESTADISTICAS
|
# ESTADISTICAS VALIDADAS
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
estadisticas:
|
estadisticas:
|
||||||
total_definiciones: 4
|
total_definiciones: 4
|
||||||
total_referencias_ws: 6
|
total_referencias_ws: 6
|
||||||
ultima_actualizacion: "2026-01-17"
|
ultima_actualizacion: "2026-01-17"
|
||||||
|
validacion:
|
||||||
|
fecha: "2026-01-17"
|
||||||
|
metodo: "Comparacion directa con codigo fuente"
|
||||||
|
resultado: "COHERENTE"
|
||||||
|
|
||||||
|
# ============================================================================
|
||||||
|
# METRICAS DEL CODIGO (VALIDADAS)
|
||||||
|
# ============================================================================
|
||||||
|
metricas_codigo:
|
||||||
|
backend:
|
||||||
|
modulos: 17
|
||||||
|
entities: 38
|
||||||
|
services: 18
|
||||||
|
controllers: 19
|
||||||
|
tablas_bd: 38 # 1:1 con entities
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
# MASTER INVENTORY - MiChangarrito
|
# MASTER INVENTORY - MiChangarrito
|
||||||
# Version: 4.0.0
|
# Version: 4.0.0
|
||||||
# Ultima actualizacion: 2026-01-10
|
# Ultima actualizacion: 2026-01-17
|
||||||
# Sistema: SIMCO v4.0.1 + CAPVED + SCRUM
|
# Sistema: SIMCO v4.0.1 + CAPVED + SCRUM
|
||||||
# Actualizado: Integracion capacidades SaaS de template-saas
|
# Actualizado: Integracion capacidades SaaS de template-saas
|
||||||
|
|
||||||
@ -11,7 +11,7 @@ metadata:
|
|||||||
estado: "MVP_LISTO"
|
estado: "MVP_LISTO"
|
||||||
tipo: "standalone"
|
tipo: "standalone"
|
||||||
categoria: "saas"
|
categoria: "saas"
|
||||||
actualizado: "2026-01-10"
|
actualizado: "2026-01-17"
|
||||||
actualizado_por: "Agente Orquestador"
|
actualizado_por: "Agente Orquestador"
|
||||||
|
|
||||||
# ============================================================================
|
# ============================================================================
|
||||||
@ -26,19 +26,20 @@ resumen:
|
|||||||
listo_produccion: true
|
listo_produccion: true
|
||||||
|
|
||||||
database:
|
database:
|
||||||
schemas: 11
|
schemas: 1 # public (TypeORM)
|
||||||
tablas: 47 # Sincronizado con DATABASE_INVENTORY.yml
|
tablas: 38 # VALIDADO - 1:1 con entities
|
||||||
funciones: 15
|
funciones: 0
|
||||||
triggers: 22
|
triggers: 0
|
||||||
extensiones: 4
|
extensiones: 1 # uuid-ossp
|
||||||
enums: 4
|
enums: 0
|
||||||
ddl_files: 17
|
ddl_files: 0 # TypeORM genera tablas
|
||||||
|
|
||||||
backend:
|
backend:
|
||||||
modulos: 17
|
modulos: 17 # VALIDADO
|
||||||
controllers: 20 # Sincronizado con BACKEND_INVENTORY.yml
|
controllers: 19 # VALIDADO
|
||||||
endpoints: 195
|
endpoints: 195
|
||||||
entities: 37 # Sincronizado con BACKEND_INVENTORY.yml
|
entities: 38 # VALIDADO
|
||||||
|
services: 18 # VALIDADO
|
||||||
|
|
||||||
frontend:
|
frontend:
|
||||||
paginas: 12
|
paginas: 12
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user