Added two new apis

Co-authored-by: Copilot <copilot@github.com>
This commit is contained in:
2026-05-04 17:37:08 -06:00
parent 2be72ae7be
commit b3788beedd
30 changed files with 2736 additions and 2 deletions

60
METRICS_SETUP.md Normal file
View File

@@ -0,0 +1,60 @@
# Metrics API Setup
## Configuración Base de Datos
PostgreSQL se ejecuta automáticamente en el contenedor Docker.
**Conexión:**
- Host: localhost
- Puerto: 5432
- Base de datos: voxpopuli_metrics
- Usuario: voxpopuli
- Contraseña: voxpopuli_pass
**Tabla creada automáticamente:**
```
metrics:
- id (PK)
- event_type (STRING, INDEXED)
- entity_id (STRING)
- entity_type (STRING)
- timestamp (DATETIME, INDEXED)
- metadata (JSON)
- user_id (INT, NULLABLE)
```
## Arquitectura
```
API Metrics (Puerto 8004)
├── FastAPI Router
│ ├── POST /metrics/record - Registrar métrica
│ ├── GET /metrics/report - Reporte analítica
│ ├── GET /metrics/daily-stats - Estadísticas diarias
│ ├── GET /metrics/summary - Resumen eventos
│ └── GET /metrics/health - Health check
├── Metrics Service (Lógica)
│ └── Metrics Repository (Postgres)
└── Metrics Consumer (RabbitMQ)
├── Escucha: users_queue
├── Escucha: reports_queue
├── Escucha: notifications_queue
└── Escucha: moderations_queue
```
## Inicio
```bash
# Levantar DB (docker)
docker-compose up -d
# Instalar dependencias
pip install -r requirements.txt
# Ejecutar todas las APIs
python -m src.main
```
La API de métricas se ejecutará automáticamente en puerto 8004.