This project implements a backend system for alerts and notifications using FastAPI.
The system supports:
- Admins: Configure alerts, set visibility (organization, team, or user), and ensure recurring reminders every 2 hours.
- End Users: Receive alerts relevant to them, snooze alerts for the day, and manage their read/unread status.
It demonstrates state management (read/unread/snoozed), delivery strategies, reminders, and analytics.
- Create, update, and list alerts (
/admin/alerts) - Define alert visibility:
- Organization → visible to all users
- Team → visible only to users of a team
- User → visible only to selected users
- Recurring reminders every 2 hours until user snoozes the alert
- View delivery logs (
/admin/deliveries)
- Fetch alerts relevant to the user (
/users/{user_id}/alerts) - Mark alerts as read or unread
- Snooze alerts until the end of the day
/analyticsendpoint shows:- Delivered vs Read alerts
- Snoozed counts per alert
- Alerts breakdown by severity
- Backend Framework: FastAPI
- Language: Python 3.9+
- Data Store: In-memory (Python dicts) for demo purposes
- Run Server: Uvicorn
- Install dependencies
pip install fastapi uvicorn pydantic
- Run the server
python alertNotification.py
- Interactive API Docs
(http://127.0.0.1:8000/docs)
- Create Alert
POST /admin/alerts
- List Alerts
GET /admin/alerts
- Trigger Reminders
POST /system/trigger_reminders
- List Alerts for a User
GET /users/{user_id}/alerts
- Snooze Alert
POST /users/{user_id}/alerts/{alert_id}/snooze
- Mark Read
POST /users/{user_id}/alerts/{alert_id}/read
- Mark Unread
POST /users/{user_id}/alerts/{alert_id}/unread
- View Metrics
GET /analytics
When the server starts, it automatically seeds demo data:
-
Teams:
- Engineering
- Marketing
-
Users:
- Alice
- Bob
- Carol
-
Sample Alerts:
- System Maintenance (Org-wide)
- Engineering Standup Postponed (Team-specific)
- Security Incident (User-specific for Alice)