Skip to content

Notification Service is a Node.js REST API for sending notifications via Email, SMS, and In-App channels. Built with Express and MongoDB, it integrates with Twilio and SMTP (Gmail) for reliable messaging. Easily fetch, filter, and mark notifications through a clean, modular API β€” ready for integration into any app.

License

Notifications You must be signed in to change notification settings

DEVanshDEVS/notification-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“¬ Notification Service
A Node.js REST API to send notifications via Email, SMS, and In-App channels.

Built with Express, MongoDB, Twilio, and SMTP (Gmail).

πŸš€ Features
βœ… Send notifications via:

Email

SMS

In-App

πŸ“₯ Fetch notifications for a user (with optional filtering by type)

βœ… Mark In-App notifications as read

πŸ”Œ RESTful API with clean, modular code

πŸ—„οΈ Persistent storage using MongoDB

## πŸ–ΌοΈ Screenshots

> ⚠️ **If the images below do not display properly, please check the `screenshots` folder in this repository to view sample screenshots directly.**

πŸ“Œ **Email Notification Sample**

![Email Notification Sample](https://github.com/DEVanshDEVS/notification-service/blob/main/screenshots/emailNotiExample.jpg?raw=true)

πŸ“Œ **Sending Email Notification via Postman**

![Email Notification via Postman](https://raw.githubusercontent.com/DEVanshDEVS/notification-service/main/screenshots/emailNotification.png)

πŸ“Œ **Fetching All Notifications via Postman**

![Fetch All Notifications](https://raw.githubusercontent.com/DEVanshDEVS/notification-service/main/screenshots/fetchAllNotification.png)

πŸ“Œ **In-App Notification via Postman**

![In-App Notification via Postman](https://raw.githubusercontent.com/DEVanshDEVS/notification-service/main/screenshots/in-appNotification.png)



πŸ”— Easily integrable with any frontend or backend

πŸ› οΈ Setup & Installation
1. Clone the repository
bash:
    git clone https://github.com/DEVanshDEVS/notification-service.git
    cd notification-service

2. Install dependencies
bash:
    npm install

3. Configure environment variables
Create a .env file in the root directory:
    PORT=3000
    MONGODB_URI=mongodb://localhost:27017/notification_service

# Email (Gmail SMTP example)
SMTP_HOST=smtp.gmail.com
SMTP_PORT=587
SMTP_USER=your_email@gmail.com
SMTP_PASS=your_gmail_app_password

# Twilio
TWILIO_ACCOUNT_SID=your_twilio_sid
TWILIO_AUTH_TOKEN=your_twilio_auth_token
TWILIO_PHONE_NUMBER=your_twilio_number

4. Start the server
bash:
    npm start
The server will run at:
πŸ‘‰ http://localhost:3000

πŸ“š API Endpoints
➀ Send a Notification
POST /notifications

json:
    {
      "userId": "USER_ID_HERE",
      "type": "in-app", // or "email" or "sms"
      "message": "This is a test notification!"
    }
➀ Get All Notifications for a User
GET /notifications/users/:id/notifications

Optional Filter by Type:

ruby:
    /notifications/users/:id/notifications?type=in-app
➀ Mark In-App Notification as Read
PATCH /notifications/:notificationId/read

πŸ‘€ User Management
Ensure user documents exist in MongoDB. Notifications are sent to these users.

Sample User Document
json:
    {
      "name": "Receiver",
      "email": "receiver@example.com",
      "phone": "+1234567890"
    }
πŸ§ͺ Example Requests
βœ… Send In-App Notification
bash:
    curl -X POST http://localhost:3000/notifications \
      -H "Content-Type: application/json" \
      -d '{"userId":"USER_ID_HERE","type":"in-app","message":"Hello from in-app!"}'

πŸ“₯ Get All In-App Notifications
bash:
    curl http://localhost:3000/notifications/users/USER_ID_HERE/notifications?type=in-app

βœ… Mark Notification as Read
bash:
    curl -X PATCH http://localhost:3000/notifications/NOTIFICATION_ID/read


πŸ“ Notes
❌ Never commit your .env file to a public repository.

πŸ“§ Gmail SMTP requires an App Password (not your login password).

πŸ“± Twilio requires an active account and a verified sender number.


πŸ“„ License
This project is licensed under the MIT License.
See the LICENSE file for more details.

πŸ™Œ Contributing
Found a bug? Have a feature request?
Open an issue or submit a pull request!
Happy Notifying! πŸ›ŽοΈ

About

Notification Service is a Node.js REST API for sending notifications via Email, SMS, and In-App channels. Built with Express and MongoDB, it integrates with Twilio and SMTP (Gmail) for reliable messaging. Easily fetch, filter, and mark notifications through a clean, modular API β€” ready for integration into any app.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published