Overview
The Notification service handles delivery of transactional notifications, primarily email delivery of ticket PDFs after ticket generation. It consumes Kafka events, composes email messages, sends them via SMTP, and tracks delivery status. Port: 50005 (external), 5005 (internal)Database Schema:
bc_notificationDependencies: PostgreSQL, Kafka, SMTP server (or dev mode simulation)
Responsibilities
- Send email notifications to customers
- Deliver ticket PDFs via email after fulfillment
- Track notification status (pending, sent, failed, retrying)
- Provide idempotent notification handling
- Store email templates and delivery history
- Support SMTP integration with development mode fallback
API Endpoints
The Notification service does not expose public HTTP endpoints. It operates as an event-driven consumer service listening to Kafka topics.Domain Models
EmailNotification
Represents an email notification record.Unique notification identifier
Reference to the ticket being delivered
Reference to the order
Email address of the recipient
Email subject line
Email body content (plain text or HTML)
Notification status:
Pending, Sent, Failed, or RetryingURL or path to the ticket PDF attachment
Reason for delivery failure (if applicable)
When the notification was created
When the notification was successfully sent
When the notification was last updated
~/workspace/source/services/notification/src/Domain/Entities/EmailNotification.cs
Configuration
Database Connection
appsettings.json
Kafka Configuration
Email (SMTP) Configuration
UseDevMode: truesimulates email sending without actual SMTP connection- Logs email content to console/logs instead of sending
- Useful for local development and testing
- Set
UseDevMode: false - Configure real SMTP credentials (Gmail, SendGrid, AWS SES, etc.)
Notification Flow
- Consume ticket-issued event: Kafka consumer receives event from Fulfillment service
- Check idempotency: Verify notification doesn’t already exist for this OrderId
- Build email content: Compose subject and body with event/ticket details
- Send email: Deliver via SMTP (or simulate in dev mode)
- Create notification record: Store in database with appropriate status
- Update status: Mark as
SentorFailedbased on delivery result - Log result: Record success or failure for monitoring/debugging
Use Cases
SendTicketNotification
The primary use case for sending ticket delivery emails.The ticket ID
The order ID
Customer email address
Name of the event
Seat information
Ticket price
Currency code
URL to download the ticket PDF
QR code data for the ticket
~/workspace/source/services/notification/src/Application/UseCases/SendTicketNotification/SendTicketNotificationHandler.cs
Email Template
The default email template includes:- Greeting
- Event details (name, seat, price)
- Ticket issuance timestamp
- Instructions for using the ticket
- QR code mention
- PDF attachment reference
- Support contact information
Kafka Integration
Consumed Events:- ticket-issued: Triggers email notification flow
- Payload:
{ TicketId, OrderId, CustomerEmail, EventName, SeatNumber, Price, Currency, TicketPdfUrl, QrCodeData, TicketIssuedAt }
- Payload:
Idempotency
To prevent duplicate email sends:- Check for existing notification by
OrderId - If found, return success without re-sending
- If not found, proceed with email send and record creation
Retry Strategy
For failed notifications:- Status set to
FailedwithFailureReason - Background worker can retry failed notifications
- Status transitions:
Pending→Retrying→SentorFailed - Exponential backoff recommended for retries
Architecture Notes
- Uses MediatR for CQRS-style command/query handling
- Infrastructure services registered via
AddInfrastructure()extension method - Event-driven architecture (no HTTP controllers)
- Listens to Kafka for
ticket-issuedevents - SMTP service abstracted via
IEmailServiceport - Development mode simulation for local testing without SMTP server
