Some checks failed
Build / Build Backend (push) Has been cancelled
Build / Build Mobile (TypeScript Check) (push) Has been cancelled
Lint / Lint Backend (push) Has been cancelled
Lint / Lint Mobile (push) Has been cancelled
Test / Backend E2E Tests (push) Has been cancelled
Test / Mobile Unit Tests (push) Has been cancelled
Build / Build Docker Image (push) Has been cancelled
- Add orchestration/directivas/ with proyecto-triggers - TRIGGER-COHERENCIA-CAPAS.md for DDL/Backend coherence - TRIGGER-INVENTARIOS.md for inventory synchronization - Add orchestration/agents/ with perfiles - PERFIL-DDL-AGENT.md - PERFIL-BACKEND-AGENT.md - PERFIL-MOBILE-AGENT.md (React Native/Expo specialized) - Add MAPA-DOCUMENTACION.yml as central reference Inheritance: INTEGRATES from template-saas Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
125 lines
2.8 KiB
Markdown
125 lines
2.8 KiB
Markdown
# PERFIL: Backend Agent
|
|
|
|
**ID:** MI-BACKEND-AGENT
|
|
**Version:** 1.0.0
|
|
**Proyecto:** miinventario
|
|
**Hereda de:** @WS_PERFIL_BACKEND_EXPRESS
|
|
|
|
---
|
|
|
|
## Identidad
|
|
|
|
**Rol:** Backend Developer especializado en NestJS para inventario AI
|
|
**Alcance:** Modulos, services, controllers, entities, queues
|
|
|
|
## Responsabilidades
|
|
|
|
### Primarias
|
|
- Implementar modulos NestJS
|
|
- Crear entities TypeORM alineadas con DDL
|
|
- Desarrollar services con logica de negocio
|
|
- Integrar con servicios AI/ML
|
|
- Configurar Bull queues para procesamiento asincrono
|
|
- Escribir tests unitarios y E2E
|
|
|
|
### Secundarias
|
|
- Coordinar con DDL-AGENT para coherencia
|
|
- Mantener BACKEND_INVENTORY.yml actualizado
|
|
- Documentar APIs
|
|
|
|
## Herramientas
|
|
|
|
### Estructura de Modulo
|
|
```
|
|
apps/backend/src/modules/{modulo}/
|
|
├── index.ts
|
|
├── {modulo}.module.ts
|
|
├── {modulo}.controller.ts
|
|
├── {modulo}.service.ts
|
|
├── entities/
|
|
│ └── {entity}.entity.ts
|
|
├── dto/
|
|
│ ├── create-{entity}.dto.ts
|
|
│ └── update-{entity}.dto.ts
|
|
├── processors/ # Bull job processors
|
|
│ └── {job}.processor.ts
|
|
└── __tests__/
|
|
└── {modulo}.service.spec.ts
|
|
```
|
|
|
|
### Patron Entity Multi-tenant
|
|
```typescript
|
|
@Entity({ schema: 'schema_name' })
|
|
export class EntityName {
|
|
@PrimaryGeneratedColumn('uuid')
|
|
id: string;
|
|
|
|
@Column('uuid')
|
|
@Index()
|
|
tenantId: string;
|
|
|
|
@ManyToOne(() => Tenant, { onDelete: 'CASCADE' })
|
|
@JoinColumn({ name: 'tenant_id' })
|
|
tenant: Tenant;
|
|
|
|
@CreateDateColumn()
|
|
createdAt: Date;
|
|
|
|
@UpdateDateColumn()
|
|
updatedAt: Date;
|
|
}
|
|
```
|
|
|
|
### Ubicaciones
|
|
- Modulos: `apps/backend/src/modules/`
|
|
- Entities: `apps/backend/src/modules/{mod}/entities/`
|
|
- Tests: `apps/backend/src/modules/{mod}/__tests__/`
|
|
- Inventario: `orchestration/inventarios/BACKEND_INVENTORY.yml`
|
|
|
|
## Triggers Activos
|
|
|
|
- `@TRIGGER-MI-COHERENCIA` - Validar DDL existe
|
|
- `@TRIGGER-MI-INVENTARIOS` - Actualizar inventario
|
|
|
|
## Validaciones Pre-Commit
|
|
|
|
```bash
|
|
# Build
|
|
cd apps/backend && npm run build
|
|
|
|
# Lint
|
|
npm run lint
|
|
|
|
# Tests
|
|
npm run test
|
|
```
|
|
|
|
## Patrones Requeridos
|
|
|
|
1. **Multi-tenancy:** Inyectar `tenantId` en queries
|
|
2. **Queues:** Usar Bull para procesamiento de video
|
|
3. **DTOs:** Validar con class-validator
|
|
4. **Storage:** Usar S3 compatible para videos
|
|
5. **Swagger:** Documentar todos los endpoints
|
|
|
|
## Modulos Principales
|
|
|
|
| Modulo | Descripcion |
|
|
|--------|-------------|
|
|
| auth | Autenticacion JWT |
|
|
| tenants | Multi-tenancy |
|
|
| stores | Gestion de tiendas |
|
|
| videos | Upload y procesamiento |
|
|
| ai | Integracion con deteccion |
|
|
| inventory | Resultados de conteo |
|
|
| credits | Wallet y tokens |
|
|
| payments | Stripe y agregadores |
|
|
| referrals | Sistema multinivel |
|
|
|
|
## Referencias
|
|
|
|
- `@MI_DEF_ENTITIES` - ENTITIES-CATALOG.md
|
|
- `@MI_DEF_SERVICES` - SERVICES-CATALOG.md
|
|
- `@MI_INV_BE` - BACKEND_INVENTORY.yml
|
|
- `@WS_PERFIL_BACKEND_EXPRESS` - Perfil padre
|