# COHERENCE-BASELINE-2026-01-28.md
## Reporte Baseline de Coherencia - Trading Platform

**Fecha:** 2026-01-28
**Proyecto:** trading-platform
**Sistema:** SIMCO v4.0.0
**Fase:** F0.3.3

---

## RESUMEN EJECUTIVO

Este documento establece el **punto de partida (baseline)** para medir mejoras de coherencia.

### Métricas Globales

| Métrica | Actual | Target (F4) | Gap | Prioridad |
|---------|--------|-------------|-----|-----------|
| **Coherencia DDL-Backend** | 31% | 95% | -64pp | P0 CRÍTICO |
| **Coherencia Backend-Frontend** | 72% | 85% | -13pp | P1 ALTO |
| **Documentación Épicas** | 45% | 70% | -25pp | P1 ALTO |
| **Cobertura Tests Frontend** | 5% | 85% | -80pp | P0 CRÍTICO |
| **COHERENCIA GLOBAL** | **39.6%** | **90%** | **-50.4pp** | **CRÍTICO** |

**Fórmula Global:** (31 + 72 + 45 + 5) / 4 = 39.6%

---

## I. INVENTARIO POR CAPA

### 1.1 DDL Layer

| Métrica | Valor |
|---------|-------|
| Schemas | 10 |
| Tablas totales | 93 |
| Tablas con cobertura backend | 37 (39.8%) |
| Tablas orphan | 56 (60.2%) |
| SQL files | 125 |
| Triggers/Functions | 20+ |

### 1.2 Backend Layer

| Métrica | Valor |
|---------|-------|
| TypeScript files | 182 |
| Services | 42 |
| Controllers | 31 |
| Módulos | 17 |
| Endpoints totales | 282 |
| Endpoints documentados Swagger | 2 (0.7%) |

### 1.3 Frontend Layer

| Métrica | Valor |
|---------|-------|
| React components | 30 |
| Routes | 47 |
| API Services | 15 |
| Zustand Stores | 8 |
| Test files | 6 |
| Test cases | ~108 |

### 1.4 Documentación

| Métrica | Valor |
|---------|-------|
| Markdown files | 359 |
| Epic docs | 22 |
| Épicas documentadas | 10 |
| Coverage promedio épicas | 45% |

---

## II. DESGLOSE POR SCHEMA

| Schema | Tablas | Backend | Frontend | Coherencia |
|--------|--------|---------|----------|------------|
| audit | 7 | 1 | 0 | 14% |
| auth | 13 | 6 | 6 | 46% |
| education | 16 | 10 | 8 | 63% |
| financial | 10 | 4 | 3 | 40% |
| investment | 9 | 5 | 3 | 56% |
| llm | 5 | 1 | 1 | 20% |
| market_data | 4 | 1 | 1 | 25% |
| ml | 11 | 6 | 4 | 55% |
| portfolio | 5 | 3 | 3 | 60% |
| trading | 10 | 5 | 5 | 50% |

---

## III. DESGLOSE POR ÉPICA

| Epic | Implementación | Documentación | DDL-BE | BE-FE |
|------|----------------|---------------|--------|-------|
| OQI-001 | 85% | 70% | 46% | 100% |
| OQI-002 | 55% | 50% | 63% | 98% |
| OQI-003 | 60% | 55% | 50% | 95% |
| OQI-004 | 55% | 45% | 56% | 50% |
| OQI-005 | 65% | 60% | 40% | 95% |
| OQI-006 | 75% | 65% | 55% | 60% |
| OQI-007 | 45% | 35% | 20% | 50% |
| OQI-008 | 45% | 40% | 60% | 100% |
| OQI-009 | ? | 30% | ? | ? |
| OQI-010 | 15% | 25% | ? | ? |

---

## IV. GAPS CRÍTICOS IDENTIFICADOS

### Gap 1: AUDIT Module (0% frontend)
- 7 tablas DDL
- 1 servicio backend
- 0 servicios frontend
- **Impacto:** Compliance

### Gap 2: Zustand Stores (8/17)
- 9 stores faltantes
- **Impacto:** State management

### Gap 3: Swagger Docs (0.7%)
- 280 endpoints sin documentación
- **Impacto:** Developer experience

### Gap 4: Test Coverage (5%)
- 147 tests faltantes
- **Impacto:** Quality assurance

### Gap 5: LLM Disconnected
- Tipos existen, BD no usada
- **Impacto:** Data persistence

---

## V. ROADMAP DE MEJORA

| Fase | Objetivo | Métrica Target |
|------|----------|----------------|
| F1 | Cerrar DDL-Backend | 75% (+44pp) |
| F2 | Cerrar Backend-Frontend | 85% (+13pp) |
| F3 | Completar Documentación | 70% (+25pp) |
| F4 | Validación y Cierre | 90% global |

### Timeline Estimado

```
Semana 1-2: F1 (DDL-Backend)
Semana 3-4: F2 (Backend-Frontend)
Semana 5-6: F3 (Documentación)
Semana 7:   F4 (Validación)
```

---

## VI. MÉTRICAS DE ÉXITO (F4)

### Criterios de Aprobación

- [ ] DDL-Backend >= 95%
- [ ] Backend-Frontend >= 85%
- [ ] Documentación >= 70%
- [ ] Tests >= 85%
- [ ] Global >= 90%
- [ ] Zero breaking changes
- [ ] Build sin errores
- [ ] Lint sin warnings críticos

---

## VII. FÓRMULAS DE CÁLCULO

### Coherencia DDL-Backend
```
= (Servicios_Implementados / Total_Tablas) × 100
= (37 / 120) × 100 = 31%
```

### Coherencia Backend-Frontend
```
= (Endpoints_Con_Consumidor / Total_Endpoints) × 100
= (147 / 208) × 100 = 72%
```

### Documentación Épicas
```
= Promedio_Coverage_Todas_Épicas
= 45%
```

### Test Coverage
```
= (Test_Cases_Existentes / Test_Cases_Requeridos) × 100
= (108 / 2000+) × 100 ≈ 5%
```

### Coherencia Global
```
= (DDL-BE + BE-FE + Doc + Tests) / 4
= (31 + 72 + 45 + 5) / 4 = 39.6%
```

---

## VIII. PRÓXIMOS PASOS

1. **Completar F0** - Marcar como completada
2. **Iniciar F1** - Cerrar gaps DDL-Backend
3. **Paralelo F3.3/F3.4** - Documentación OQI-009, OQI-010

---

**Estado:** BASELINE ESTABLECIDO
**Siguiente checkpoint:** F1 completada
**Responsable:** Claude Code (Opus 4.5)

---

*Generado: 2026-01-28 | Sistema SIMCO v4.0.0*
