Push Notification Micro NodeJS API Server
A Push Notification Service is a way for businesses to send messages and updates to their customers' mobile devices, such as iOS or Android. It works similarly to the notifications that you may receive on Twitter, Facebook, or Instagram. It is a great way to keep your customers informed and engaged with your business.
I recently developed a Push Notification Micro NodeJS API Server. This server was built to separate the push notification functionality from their very busy PHP server, while also freeing up the server resources needed to perform expensive calculations. By utilizing NodeJS and its fast response time, the server was able to handle high traffic input and output with ease.
The NodeJS Microserver was also integrated with Google's Firebase Cloud Messaging API Service, also known as FCM. In addition to delivering messages, the server also kept track of user's pending notifications, the ones who received the notifications, and who read the notifications. It also had calculation functionality which enabled the company to have a report of the latest notifications statistics (per user, per group, or per community).
The beauty of this microservice was that it allowed the company to break off its functionality from the main server into separate services, allowing them to easily scale as their software requirements grew. It also allowed them to better organize their software and made it easier to maintain.
High Level Overview of the POS functionality and features.
Authentication & Security
- Server to Server Token Authentication
- User to Server Token Authenticaion
- Token Protected API routes
- URL and Data sanitization
- Store each push notification.
- Process each push notification.
- Create users that don't exist yet.
- Keep a Registry of the transactions.
- Bundles messages for FCM.
- Send push notifications.
- Audit tracking functionality.
Device to Server
- Update the notification status.
- User Device can query notifications.
- User device can unsubscribe from certain notifications for groups or categories.
- Mark all posts for certain groups or categories as read.
- Get all notifications from server.
The architecture of the "Push Notification Micro NodeJS API Server" is designed to be efficient and scalable, allowing for the smooth operation of your push notification services.
- Database Architecture. Designing of the database structure and normalizing the data.
- Server Architecture. Designing the functionality and features the server would offer.
The business logic is laid out in detailed flow charts, which is then converted into application logic, providing a clear understanding of how the system works and how it fits into your overall business strategy.
The database architecture is designed with a focus on data normalization, ensuring that the data is stored in a logical and organized manner, making it easy to retrieve and update. The database structure is designed to handle large amounts of data, allowing for the smooth operation of your push notification services even as your business grows.
The server architecture is designed to offer a wide range of functionality and features, including the ability to send push notifications, track user's pending, received, and read notifications, provide reports of the latest notification statistics, per user, per group, or per community. The server is also designed to handle large amounts of data, provide a seamless user experience and integrate with Google's Firebase Cloud Messaging API Service (FCM).
Overall, the architecture of the "Push Notification Micro NodeJS API Server" is designed to provide a robust and reliable solution for businesses looking to implement push notification services and keep their customers informed and engaged.
Push Notifications Instruction set send to the API Micro Server.
When the Micro API Server receives an push notification payload from the php server.
PHP Server will send a payload object containing the
message, users and groups to which the push
notification needs to be send to.
The Micro API server would accept this payload and
save it to a collection called notifications.
Every notification is saved in a document.
The Micro API server would then create the user
accounts, if they don't exist for authentication and
The Micro API server would also create a register
entry for each user to monitor the state of each
Then it will start to post the push notification
messages in bulk to the Google FCM API. While
posting to the registry to keep track of the status
of each push notification.
Registry Entries for Audit Tracking
To be able to keep track of the notification activity.
Pending status: Push notification still needs to be
Send status: Push Notifications was send, MFC
responsed with a success that the messages is placed
in their Que system.
Received status: The user device has received the
Read status: Users have read their push
The server was also developed to serve as a bi-directional service between the Push Notification Server and the user's devices.
User devices would ping the status back to the server, if a notification was received or openend. From this it can also be monitored if a push notification was actualy received, and if not, send it again.
Users can also unregister from certain categories or groups. These will be categories or groups from where they do not wish to receive push notification anymore.
Some other API features included the ability to get all unread post for a group or category or mark all posts for a group or category as read.