Files
VoxPopuli/METRICS_SETUP.md
2026-05-04 17:37:08 -06:00

61 lines
1.3 KiB
Markdown

# 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.