Architecture Overview - usmantahirr/infobip-notification-service GitHub Wiki
The Infobip Notification Service is built with a clean, modular architecture using TypeScript and Express.js. Here's a detailed overview of the current implementation:
graph TD
Client[Client Applications] -->|HTTP/HTTPS| API[Express API]
API -->|Validate| Validator[Zod Schema]
API -->|Rate Limit| RateLimiter[Express Rate Limit]
API -->|Log| Logger[Winston Logger]
Validator -->|Valid Request| Service[Notification Service]
RateLimiter -->|Within Limits| Service
Logger -->|Log Request| Service
Service -->|Email| EmailService[Email Service]
Service -->|SMS| SMSService[SMS Service]
EmailService -->|Send| Infobip[Infobip API]
SMSService -->|Send| Infobip
style Client fill:#f9f,stroke:#333,stroke-width:2px
style API fill:#bbf,stroke:#333,stroke-width:2px
style Service fill:#bfb,stroke:#333,stroke-width:2px
style Infobip fill:#fbb,stroke:#333,stroke-width:2px
src/
├── app.ts # Application entry point
├── config/ # Configuration files
│ ├── config.ts # App configuration
│ ├── logger.ts # Winston logger setup
│ └── openapi.ts # OpenAPI documentation
├── controllers/ # Request handlers
├── middleware/ # Express middleware
│ ├── errorHandler.ts
│ ├── rateLimiter.ts
│ ├── requestLogger.ts
│ └── security.ts
├── routes/ # API routes
├── schemas/ # Zod validation schemas
├── services/ # Business logic
│ ├── notificationService.ts
│ ├── emailService.ts
│ └── smsService.ts
└── errors/ # Custom error classes
-
API Layer
- Express.js with TypeScript
- RESTful API endpoints
- OpenAPI/Swagger documentation
- Request validation using Zod
- Rate limiting
- Security middleware (Helmet, CORS)
-
Service Layer
- Notification service for handling different types of notifications
- Email service for sending emails via Infobip
- SMS service for sending SMS via Infobip
- Error handling and logging
-
Security
- API key authentication
- Rate limiting
- Input validation
- Security headers (Helmet)
- CORS configuration
-
Monitoring & Logging
- Winston logger
- Request logging
- Error logging
graph TD
Client[Client] -->|Request| API[API]
API -->|Queue| Redis[Redis Queue]
Redis -->|Process| Worker[Notification Worker]
Worker -->|Send| Infobip[Infobip API]
style Redis fill:#ff9,stroke:#333,stroke-width:2px
style Worker fill:#9ff,stroke:#333,stroke-width:2px
graph TD
Service[Notification Service] -->|Save| DB[(PostgreSQL)]
DB -->|Query| Service
Service -->|Cache| Redis[(Redis Cache)]
style DB fill:#9f9,stroke:#333,stroke-width:2px
style Redis fill:#ff9,stroke:#333,stroke-width:2px
graph TD
App[Application] -->|Metrics| Prometheus[Prometheus]
App -->|Traces| Jaeger[Jaeger]
App -->|Logs| ELK[ELK Stack]
Prometheus -->|Visualize| Grafana[Grafana]
Jaeger -->|Visualize| Grafana
ELK -->|Visualize| Kibana[Kibana]
style Prometheus fill:#f9f,stroke:#333,stroke-width:2px
style Jaeger fill:#bbf,stroke:#333,stroke-width:2px
style ELK fill:#bfb,stroke:#333,stroke-width:2px
-
High Priority
- Message queue integration for reliable delivery
- Database integration for notification tracking
- Enhanced error handling and retries
-
Medium Priority
- Caching layer for rate limiting
- Health check endpoints
- Metrics collection
-
Low Priority
- Advanced monitoring
- A/B testing capabilities
- Analytics dashboard
- Runtime: Node.js with TypeScript
- Framework: Express.js
- Validation: Zod
- Documentation: OpenAPI/Swagger
- Logging: Winston
- Security: Helmet, CORS
- API: Infobip
- Message Queue: Redis/Bull
- Database: PostgreSQL
- Caching: Redis
- Monitoring: Prometheus/Grafana
- Tracing: OpenTelemetry
- Testing: Jest
- API key authentication
- Rate limiting
- Input validation
- Security headers
- CORS configuration
- JWT authentication
- Request signing
- IP whitelisting
- Audit logging
- Encryption at rest
- Stateless design
- Basic rate limiting
- Error handling
- Horizontal scaling with load balancer
- Distributed rate limiting
- Database sharding
- Caching strategy
- Queue-based processing
Last updated: March 2025