How priyansh00soni/nexus works
Nexus is a multi-tenant notification delivery API. Clients register tenants, then submit authenticated, validated and deduplicated notification requests; the service records and enqueues work, returning before channel delivery. Email, in-app and webhook workers process jobs with retries and update delivery state. Templates, notification lookup, tenant rate limits, and health, queue and delivery metrics are additional capabilities. Worker and service internals are partly documented rather than sampled, so those links follow README-described behavior; monitoring integrations reflect documented scraping and dashboards.
Main entry points: monitoring.controller.ts Monitoring controller · notification.service.ts Notification service · prismaClient.ts PostgreSQL · app.ts HTTP application
Components 28
API and tenancy
- HTTP application
src/app.ts - Tenant routes
src/features/tenants/tenant.routes.ts - Tenant service
src/features/tenants/tenant.service.ts - API-key auth
src/middleware/auth.middleware.ts - Idempotency
src/middleware/idempotency.middleware.ts - Tenant rate limit
src/middleware/rateLimit.middleware.ts
Templates and notifications
- Notification routes
src/features/notifications/notification.routes.ts - Notification controller
src/features/notifications/notification.controller.ts - Notification service
src/features/notifications/notification.service.ts - Template routes
src/features/templates/template.routes.ts - Template service
src/features/templates/template.service.ts
Asynchronous delivery
- Email worker
src/workers/email.worker.ts - In-app worker
src/workers/inapp.worker.ts - Webhook worker
src/workers/webhook.worker.ts - Message resolution
src/utils/resolveNotificationMessage.ts
State and queues
- Email queue
src/queues/email.queue.ts - In-app queue
src/queues/inapp.queue.ts - Webhook queue
src/queues/webhook.queue.ts - PostgreSQL
src/config/prismaClient.ts - Redis
src/config/redis.ts
Monitoring
- Monitoring routes
src/monitoring/monitoring.routes.ts - Monitoring controller
src/monitoring/monitoring.controller.ts - Metrics registry
src/monitoring/metrics.ts
Other components
- Business client
- Resend email
- Tenant webhook endpoint
- Prometheus
- Grafana
Connections 46
- Business client → HTTP application: sends API requests
- HTTP application → Tenant routes: dispatches
- HTTP application → Notification routes: dispatches
- HTTP application → Template routes: dispatches
- HTTP application → Monitoring routes: dispatches
- Tenant routes → Tenant service: invokes
- Tenant service → PostgreSQL: creates tenant
- Notification routes → API-key auth: authenticates
- API-key auth → Notification routes: continues request
- Notification routes → Idempotency: checks duplicate
- Idempotency → Redis: claims key
- Idempotency → Tenant rate limit: continues request
- Tenant rate limit → Redis: checks tenant limit
- Tenant rate limit → Notification controller: continues request
- Notification controller → Notification service: invokes
- Notification service → PostgreSQL: records notification
- Notification service → Email queue: enqueues email
- Notification service → In-app queue: enqueues in-app job
- Notification service → Webhook queue: enqueues webhook
- Notification service → Business client: returns acceptance
- Template routes → API-key auth: authenticates
- Template routes → Template service: invokes
- Template service → PostgreSQL: manages templates
- Email queue → Email worker: dispatches jobs
- In-app queue → In-app worker: dispatches jobs
- Webhook queue → Webhook worker: dispatches jobs
- Email worker → Message resolution: resolves content
- Email worker → Resend email: sends email
- Email worker → PostgreSQL: records attempts and status
- In-app worker → Message resolution: resolves content
- In-app worker → PostgreSQL: persists delivery
- Webhook worker → Message resolution: resolves content
- Webhook worker → Tenant webhook endpoint: posts webhook
- Webhook worker → PostgreSQL: records delivery
- Monitoring routes → Monitoring controller: invokes
- Monitoring controller → PostgreSQL: checks health
- Monitoring controller → Redis: checks health
- Monitoring controller → Email queue: reads counts and failures
- Monitoring controller → In-app queue: reads counts and failures
- Monitoring controller → Webhook queue: reads counts and failures
- Monitoring controller → Metrics registry: updates and serves
- Email worker → Metrics registry: records delivery metrics
- In-app worker → Metrics registry: records delivery metrics
- Webhook worker → Metrics registry: records delivery metrics
- Prometheus → Metrics registry: scrapes
- Prometheus → Grafana: feeds dashboards