This microservice is responsible for sending notifications to user devices in response to an event coming from the notification scheduler. This microservice also takes care of user-device registration and deregistration.
- Before receiving reminder-notifications users device(s) must be registered with the service so that it can send the notification to the device(s).
- Clients can register the user device using an FCM token generated from the project's cloud-messaging system. If the FCM token is valid then the device is registered otherwise not.
- Clients can also deregister the device using the provided device ID after successful registration, if the user wishes not to receive notifications on this device or on logout operation.
- These registration details are stored in PostgreSQL database.
- The incoming notification-event from the notification-scheduler contains all the information required to send the notification to the client.
- This service continuously polls the notification-sqs-queue and send the notification to the clients.
- Fork this repository
- "Forking" adds a copy of adisakshya/notification-service repository to your GitHub account as
https://github.com/YourGitHubUserName/notification-service
- "Forking" adds a copy of adisakshya/notification-service repository to your GitHub account as
- Or you can download or clone this repository
- You can clone the repository executing below command in a location of your choice in your system
$ git clone https://github.com/adisakshya/notification-service.git
- Source code for the notification-service can be found at
/src
- All CI/CD resources are located in
.travis
directory requirements.txt
contain the python packages required for the CI/CD process.env.example
is a template env file
- Make sure you have
- Installed Docker (when running using docker)
- Firebase Cloud Messaging (FCM) service-account json file
- PostgreSQL
device-database
running and accessible using host-url, username and password - AWS SES template
- AWS SQS
notification-queue
setup and is accessible using queue URL - AWS SNS
event-topic
setup and is accessible using ARN
- In source directory
src/
run the following command$ yarn install
- install required dependencies$ yarn build
- build source code$ yarn test
- run test (optional)$ docker build -t notification-service .
- build docker image
- With successful execution of above commands you will have a docker-image for the notification-service
- The docker-image can be run using the following command
docker run -p 3000:3000 --env-file ./.env notification-service
- On successful start, the notification-service is ready to consume notification-messages from the notification-queue
- Replace the env-variables at
/src/src/common/api-config.service.ts
- Use the following commands to start the service
$ yarn install
- install required dependencies$ yarn test
- run test (optional)$ yarn start
- start notification-service
- On successful start, the API documentaion (built using Swagger) for the service will be accssible on
http://localhost:3000/docs
Fig 1 - Notification Service Architecture
Clients can interact with the service using HTTP/HTTPs requests (interfaced by API Gateway) for device-registration while mechanism for sending notifications is internal. The notification-service has 2 modules namely:
- Device Module
- Device Controller - Handles incoming requests for device-registration and returns responses to the client
- Device Service - Defines the logic to serve incoming requests
- Notification Module - Polls the notification-queue and send available notifications to target clients
A brief description of the deployment strategy is described in documentation of continuous-improvement project.
There are multiple ways to contribute to this project, read about them here.
All versions of the app are open-sourced, read more about this LICENSE.