AI-powered incident monitoring pipeline built with n8n, Gemini AI, and PostgreSQL to automate API failure analysis and engineer notifications.
DevStream is an AI-powered incident monitoring pipeline built using n8n, Gemini AI, and Neon PostgreSQL.
The project automates API failure handling by receiving failure events, validating requests, calculating incident severity, generating AI-assisted root cause analysis, storing incident data in PostgreSQL, and notifying engineers about high-severity incidents.
It demonstrates workflow automation, AI integration, database persistence, and event-driven incident management in a backend engineering scenario.
API Failure Event
│
▼
Webhook
│
▼
Payload Validation
│
▼
Severity Calculation
│
▼
PostgreSQL Failure Log
│
▼
Gemini AI Analysis
│
▼
Store AI Analysis
│
▼
HIGH Severity?
│
▼
Engineer Notification
- AI-assisted root cause analysis using Gemini AI
- Automated incident severity calculation
- PostgreSQL persistence for API failures and AI analysis
- Conditional email notifications for HIGH-severity incidents
- Workflow automation using n8n
- Structured storage of AI-generated analysis and recommendations
- Extensible architecture for future Spring Boot integration
| Category | Technology |
|---|---|
| Workflow Automation | n8n |
| AI Model | Gemini AI |
| Database | Neon PostgreSQL |
| Database Engine | PostgreSQL |
| Notification | Gmail |
| API Testing | Postman |
| Version Control | GitHub |
| Future Event Source | Spring Boot Microservice |
flowchart TD
A["API Failure Event"]
B["Receive Failure Event"]
C["Validate Payload"]
D["Calculate Severity"]
E["Log API Failure"]
F["Analyze Failure (Gemini AI)"]
G["Parse AI Response"]
H["Store AI Analysis"]
I["Update AI Status"]
J{"HIGH Severity?"}
K["Notify Engineer (Email)"]
L["End"]
M["Neon PostgreSQL
(api_failure_logs, ai_analysis)"]
A --> B
B --> C
C --> D
D --> E
E -.->|"Save Failure Log"| M
E --> F
F --> G
G --> H
H -.->|"Save AI Analysis"| M
H --> I
I -.->|"Update Processing Status"| M
I --> J
J -->|Yes| K
J -->|No| L
Current Event Source: Postman for API failure simulation
Workflow Trigger: n8n HTTP Webhook
Planned Event Source: Spring Boot Microservice (Phase 2)
The following screenshot shows the complete implementation of the AI-powered incident monitoring pipeline in n8n.
The workflow validates incoming API failures, performs AI-assisted incident analysis, persists the results in Neon PostgreSQL, and notifies engineers for HIGH-severity incidents.
- API failure event is sent using Postman.
- n8n validates the payload and calculates severity.
- Failure details are stored in Neon PostgreSQL.
- Gemini AI analyzes the incident and generates:
- Root cause
- Java fix recommendation
- Unit test suggestion
- Best practice
- Confidence score
- AI analysis is stored in PostgreSQL.
- HIGH severity incidents trigger an automated email notification to the designated engineer.
The project uses Neon PostgreSQL to store both raw API failure events and AI-generated incident analysis.
The following diagram presents a simplified view of the primary database fields and relationships.
The database consists of two primary tables:
| Table | Purpose |
|---|---|
api_failure_logs |
Stores API failure details received by the workflow |
ai_analysis |
Stores AI-generated analysis linked to each API failure |
erDiagram
api_failure_logs ||--o| ai_analysis : has
api_failure_logs {
int failure_id PK
string service_name
string endpoint
int status_code
string severity
string ai_status
}
ai_analysis {
int analysis_id PK
int failure_id FK
string root_cause
string java_fix
string recommended_action
float confidence_score
}
Each API failure is stored first in api_failure_logs.
After AI processing, the generated root cause analysis, Java fix recommendations, confidence score, and other outputs are stored in ai_analysis using the corresponding failure_id.
The workflow receives API failure events through an HTTP Webhook.
Example request:
{
"serviceName": "Order Service",
"endpoint": "/api/orders",
"httpMethod": "POST",
"statusCode": 500,
"responseTimeMs": 2400,
"errorMessage": "NullPointerException while creating order",
"stackTrace": "java.lang.NullPointerException..."
}- n8n Cloud or self-hosted n8n
- Google Gemini API Key
- Neon PostgreSQL
- Gmail Account
- Postman
- Clone the repository.
- Create the PostgreSQL tables using the SQL scripts.
- Import the n8n workflow JSON.
- Configure the Gemini API credentials.
- Configure PostgreSQL credentials.
- Configure Gmail credentials.
- Activate the workflow.
- Send the sample payload using Postman.
- Verify the AI analysis and database entries.
This repository intentionally excludes all secrets and sensitive credentials.
The exported n8n workflow contains only references to credentials—not the actual values.
After importing the workflow, configure your own credentials in n8n for:
- Google Gemini API
- Neon PostgreSQL
- Gmail OAuth
Never commit:
- API keys
- Database passwords
- Connection strings
- OAuth tokens
.envfiles- Exported credentials
- Replace Postman with Spring Boot Microservice
- Automatic failure reporting
- Exception handling integration
- Slack notifications
- Jira integration
- Monitoring dashboard
- Incident analytics
- Retry recommendations
- Historical incident search
- Docker deployment
DevStream/
│
├── README.md
├── workflow/
│ └── DevStream_AI_Incident_Monitoring.json
├── database/
│ ├── create_tables.sql
│ └── sample_data.sql
├── images/
│ └── workflow.png
└── LICENSE
Current Phase
Phase 1 – AI-powered incident monitoring workflow using Postman for event simulation.
Next Phase
Integrate a Spring Boot microservice to automatically report API failures to the n8n workflow.
workflow/– n8n workflow exportdatabase/– PostgreSQL schema and sample dataimages/– Architecture and workflow screenshotsREADME.md– Project documentation
This project is licensed under the MIT License. See the LICENSE file for details.
