← Volver al índice
Auditoría Técnica — dkv-notifications
Tipo: Documentación Técnica — Análisis Forense
Estado: ✅ Completo
Relacionado con: Arquitectura del Sistema · Implementation Plan
1. ¿Qué es dkv-notifications?
dkv-notifications es un microservicio Erlang/OTP que gestiona el envío de notificaciones push (APNs, FCM, Web Push) y emails para la plataforma dkv-pet-cloud. Actúa como intermediario entre la aplicación Spring Boot principal y el servicio Gorush (Go).
2. Arquitectura descubierta
graph LR
subgraph "dkv-pet-cloud (Spring Boot)"
API["REST API<br/>port 8080"]
EMAIL_CFG["Email config<br/>POST /api/v1/emails/"]
end
subgraph "dkv-notifications (Erlang OTP)"
NTF["HTTP Listener<br/>port 9111"]
APPS["apps.yml"]
EMAILS["emails.yml"]
GORUSH_CFG["gorush.yml"]
DB["PostgreSQL 11.6<br/>DB: dkv_notifications<br/>port 5433"]
end
subgraph "Gorush 1.16.0 (Go)"
GR["HTTP API<br/>port 8088<br/>path: /send"]
end
subgraph "Proveedores"
APNs["Apple APNs"]
FCM["Google FCM"]
WEB["Web Push (VAPID)"]
end
API -->|"POST /api/v1<br/>app_id: nk"| NTF
EMAIL_CFG -->|"POST /api/v1/emails/"| NTF
NTF -->|"POST 8088/send"| GR
NTF --> DB
APPS -.-> NTF
EMAILS -.-> NTF
GORUSH_CFG -.-> NTF
GR --> APNs & FCM & WEB
Tres contenedores
| Contenedor |
Imagen |
Puerto |
Red |
pet-notifications |
ghcr.io/jaraxasoftware/dkv-notifications:${TAG} |
9111 |
backend, monitoring |
pet-notifications-postgres |
postgres:11.6 |
5433 → 5432 |
backend, monitoring |
pet-notifications-gorush |
ghcr.io/jaraxasoftware/gorush:1.16.0 |
8088 |
backend, monitoring |
3. Stack Erlang/OTP — Detalle
sys.config (configuración OTP)
[{dkv_notifications, [
{start_services, true},
{apps_config_file, "/opt/code/etc/settings/apps.yml"},
{emails_config_file, "/opt/code/etc/settings/emails.yml"},
{gorush_config_file, "/opt/code/etc/settings/gorush.yml"},
{listen, #{
url => "http://0.0.0.0:9111",
debug => []
}},
{db, #{
targets => [#{url => "postgresql://petuser:12345678@pet-notifications-postgres:5432"}],
database => dkv_notifications,
flavour => postgresql,
debug => true
}},
{use_aws, false}
]},
{nkpacket, [{ext_ip, {127,0,0,1}}]},
{nkserver_ot, [
{activate, false},
{opentrace_url, "http://notifications-jaeger:9411/api/v1/spans"}
]}].
Librerías legacy heredadas de Netcomp
| Librería |
Propósito |
Origen |
| nkpacket |
Transport abstraction (HTTP/WS/TCP/SCTP/UDP) |
Netcomp core |
| nkserver_ot |
OpenTelemetry/OpenTracing integration |
Netcomp observability |
| lager |
Logging framework Erlang |
Estándar OTP (pero legacy vs logger) |
Riesgo legacy: Estas librerías son compartidas con Netcomp. Netcomp está en proceso de migración a dkv-pet-cloud (go-live julio 2026). Modificar dkv-notifications podría causar regresiones en la migración.
4. Base de datos
Init script
CREATE DATABASE dkv_notifications;
CREATE USER petuser WITH ENCRYPTED PASSWORD '12345678';
GRANT ALL PRIVILEGES ON DATABASE dkv_notifications TO petuser;
\connect dkv_notifications;
CREATE EXTENSION pgcrypto;
- PostgreSQL: 11.6 (legacy — ya tiene EOL)
- Extensión: pgcrypto (para encriptación de tokens/device IDs)
- Volumen Docker:
db-data-notifications
- Puerto: 5433 (mapeado desde 5432 interno para no colisionar con el postgres principal)
5. Integración con dkv-pet-cloud
Punto de integración: Push
# pet/src/main/resources/application.yaml
collab:
external_push:
url: "http://dkv-notifications:8090/api/v1"
app_id: "nk"
app_secret: "c1919145-7532-45eb-8582-95847fcb00e2"
Punto de integración: Email
dkv-emails:
enabled: true
url: "http://localhost/notifications/api/v1/emails/"
from: "no-reply@dkvseguros.com"
brand: "DKV"
product: "PET"
Gorush config dentro de dkv-notifications
# docker/dkv-notifications/local/gorush.yml
spec:
DKV:
qcp:
transport:
keyword: http
host: dkv-notifications-gorush
port: 8088
path: /send
6. Análisis de calidad OTP
| Criterio |
Estado |
Valoración |
| Supervision tree |
Presente (start_services: true) |
✅ Correcto |
| Clustering |
Posible (nkpacket soporta clustering) |
✅ Viable |
| Hot code reload |
Estándar OTP |
✅ Disponible |
| Librerías actuales |
nkpacket, nkserver_ot → legacy de Netcomp |
⚠️ Sin mantenimiento activo |
| PostgreSQL 11.6 |
EOL desde noviembre 2023 |
🔴 Obsoleto |
| Erlang version |
No especificada en config |
⚠️ Riesgo desconocido |
7. Estrategia de coexistencia — Recomendación
FASE 1: Coexistencia API-compatible (ahora → julio 2026)
graph TB
subgraph "Pet Flows (Quarkus)"
PF_API["REST API<br/>/api/v1 compatible"]
end
subgraph "dkv-notifications (Erlang)"
NTF["Puerto 9111<br/>NO se toca"]
GR["Gorush 1.16.0"]
end
PF_API -->|"Mismo contrato"| NTF
NTF --> GR
style PF_API fill:#7C3AED,color:#fff
style NTF fill:#D97706,color:#fff
style GR fill:#059669,color:#fff
- Pet Flows delega a dkv-notifications para push reales
- Implementamos endpoints con el mismo contrato REST (
/api/v1)
- No tocamos nada del stack Erlang ni de su DB
- Cero riesgo para el go-live de julio
FASE 2: Absorción gradual (post-julio 2026)
graph TB
subgraph "Pet Flows (Quarkus + Dapr)"
PF_API2["REST API"]
DAPR["Dapr Binding<br/>output: gorush"]
end
subgraph "Reutilizado"
GR2["Gorush<br/>(mismo container)"]
DB2["dkv_notifications DB<br/>(migrada a PF)"]
end
PF_API2 --> DAPR
DAPR --> GR2
PF_API2 --> DB2
style PF_API2 fill:#7C3AED,color:#fff
style DAPR fill:#D97706,color:#fff
style GR2 fill:#059669,color:#fff
style DB2 fill:#2563EB,color:#fff
- Pet Flows habla directo con Gorush via Dapr Binding (output)
- Se conserva la base de datos
dkv_notifications (migración de datos históricos)
- Se elimina el contenedor Erlang
- De 3 containers → 2 containers
Valoración DevOps
| Aspecto |
Fase 1 |
Fase 2 |
| Riesgo operacional |
✅ Mínimo (no toca nada) |
⚠️ Medio (requiere migración rutas) |
| Gorush |
Reutilizado vía dkv-notifications |
Reutilizado directo vía Dapr |
| Persistencia |
Cada app su DB |
Pet Flows absorbe dkv_notifications |
| Containers |
PF + NTF + Gorush (3) |
PF + Gorush (2) |
| Rollback |
Instantáneo |
Posible pero requiere restaurar NTF |
| Certificados |
Los gestiona NTF/Gorush |
Los gestiona PF/Gorush (misma config) |
Documentos Relacionados