Notification service for CoreChain HRM system using Firebase Cloud Messaging (FCM) and Kafka.
This is a Golang-based notification service that:
- Consumes Kafka messages from the NestJS backend
- Sends push notifications via Firebase Cloud Messaging (FCM)
- Stores notification history in PostgreSQL
- Supports multiple notification types (tasks, messages, calls)
Current Flow: Task created on server (NestJS) → Kafka → Notification service (Golang) → FCM → Mobile app
Built with Clean Architecture principles:
cmd/server/- Application entry pointinternal/domain/- Business entities and interfacesinternal/application/- Business logic (services & DTOs)internal/infrastructure/- External integrations (Kafka, FCM, PostgreSQL)internal/delivery/- Message handlerspkg/- Public/shared code
- Go 1.21+
- Docker & Docker Compose
- PostgreSQL 15
- Kafka (or use Docker Compose setup)
-
Clone and setup
cd CoreChain-Notification cp .env.example .env # Edit .env with your configuration
-
Install dependencies
make deps
-
Start with Docker Compose (includes PostgreSQL, Kafka, and service)
make docker-up
-
Or run locally
# Make sure PostgreSQL and Kafka are running make run
Configure via environment variables (see .env.example):
# Database
DB_HOST=localhost
DB_PORT=5432
DB_USER=notification_user
DB_PASSWORD=notification_pass
DB_NAME=notification_db
# Kafka
KAFKA_BROKERS=localhost:9092
KAFKA_GROUP_ID=notification-service-group
KAFKA_TOPIC_TASK_CREATED=task.created
# FCM
FCM_CREDENTIALS_PATH=./google-services.json
FCM_PROJECT_ID=corechain-e1321make help # Show all available commands
make deps # Download dependencies
make build # Build the application
make run # Run locally
make test # Run tests
make docker-up # Start with Docker Compose
make docker-down # Stop Docker services
make docker-logs # View logsCoreChain-Notification/
├── cmd/server/ # Main application
├── internal/
│ ├── config/ # Configuration management
│ ├── domain/ # Domain models & interfaces
│ ├── application/ # Services & DTOs
│ ├── infrastructure/ # Kafka, FCM, PostgreSQL
│ ├── delivery/ # Message handlers
│ └── utils/ # Logger, errors, validators
├── deployments/
│ └── docker/ # Dockerfile & docker-compose
└── configs/ # Config files
- Task Created - Notifies when a new task is assigned
- Task Updated - Notifies when a task is modified
- New Message - Notifies on incoming messages
- Incoming Call - Notifies on incoming calls
- Add constant in
pkg/constants/notification_types.go - Create DTO in
internal/application/dto/ - Add template in
internal/infrastructure/fcm/templates.go - Create handler in
internal/delivery/kafka/ - Register handler in
cmd/server/main.go
# Run all tests
make test
# Run with coverage
make test-coveragemake docker-build- postgres - PostgreSQL database (port 5432)
- kafka - Apache Kafka (port 9092)
- zookeeper - Kafka dependency (port 2181)
- notification-service - This service (port 8080)
Stores all notification records with delivery status tracking.
Tracks device tokens for each user.
See deployments/docker/migrations/001_init.sql for full schema.
The NestJS backend should publish messages to Kafka in this format:
{
"event_type": "task.created",
"timestamp": "2025-12-26T07:29:50Z",
"data": {
"_id": "task-id",
"title": "Task title",
"assignedTo": "user-id",
...
},
"metadata": {
"assignedToUser": {
"_id": "user-id",
"fcmToken": "device-token",
"name": "User Name"
}
}
}MIT License