Skip to content

Commit 3a19de6

Browse files
committed
Refactor alert handling and enhance logging
* Improve alert report model and update related routes for better report management. * Add tests for Estofex report validation and enhance error handling in image retrieval. * Remove TelegramUser model and associated logic. * Implement structured error logging and enhance error handling across services. * Update Fastify server options for improved type safety.
1 parent 0c9e2c7 commit 3a19de6

1 file changed

Lines changed: 75 additions & 0 deletions

File tree

README.md

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# Mida-Sync (Meteo Info Daily Alert Sync)
2+
3+
Mida-Sync is a backend service designed to monitor, aggregate, and notify meteorological alerts and reports. The system analyzes alerts issued by the Emilia-Romagna Region, integrating them with convective forecasts at national and European levels, to send timely and detailed notifications via Telegram.
4+
5+
## 🌟 Implemented Products and Services
6+
7+
The system interfaces with various official and unofficial sources to provide a complete meteorological overview:
8+
9+
1. **[Allerta Meteo Regione Emilia-Romagna](https://allertameteo.regione.emilia-romagna.it/)**
10+
- **Feature:** Daily monitoring of the meteorological alert status.
11+
- **Details:** Extracts data via the open APIs of the civil protection, focusing particularly on the "D1" alert zone. It detects critical alerts (yellow, orange, red) for hydraulic risk, hydrogeological risk, thunderstorms, wind, extreme temperatures, and snow/ice.
12+
- **Notification:** Sends a Telegram message formatted with the alert colors and a direct link to the official PDF bulletin.
13+
14+
2. **[Estofex (European Storm Forecast Experiment)](https://www.estofex.org/)**
15+
- **Feature:** Integration of European severe storm bulletins.
16+
- **Details:** Analyzes the Estofex XML feed to check for level 1, 2, or 3 forecasts for the following day.
17+
- **Notification:** In case of critical alerts in the local territory, it sends the European convective forecast map to the Telegram channel.
18+
19+
3. **[Pretemp (Previsione Temporali)](https://pretemp.altervista.org/)**
20+
- **Feature:** Integration of Italian thunderstorm forecast bulletins.
21+
- **Details:** Dynamically retrieves forecast maps for the following day via the Pretemp archive.
22+
- **Notification:** If conditions require it (presence of ongoing alerts), it sends the thunderstorm forecast image to the Telegram channel.
23+
24+
## 🕒 Scheduled Tasks (Crons)
25+
26+
The application relies on scheduled tasks (crons) to automate the weather monitoring flow:
27+
28+
- **Meteo Alerts Check**
29+
- Periodically checks the status of the Emilia-Romagna weather alerts for the following day. If it detects a critical alert that has not been notified yet, it sends it on Telegram and saves it in the database.
30+
- **Pretemp Report Check**
31+
- Verifies and sends the Pretemp map for the following day, provided there is an ongoing alert and the map hasn't been sent yet.
32+
- **Estofex Report Check**
33+
- Verifies and sends the Estofex map for the following day, following the same conditional logic based on ongoing alerts.
34+
35+
## ⚙️ Configuration and Installation
36+
37+
### Prerequisites
38+
- Node.js (v22+)
39+
- PostgreSQL
40+
- Docker (optional, for deployment)
41+
- A valid Telegram Bot token and a destination Chat ID.
42+
43+
### Environment Variables (`.env`)
44+
The project uses a `.env` file for configuration. Required keys include:
45+
- PostgreSQL Database credentials (Host, User, Password, DB Name)
46+
- `TELEGRAM_TOKEN`: Telegram Bot token.
47+
- `CHAT_ID`: ID of the Telegram chat or channel where alerts will be sent.
48+
49+
### Development Setup
50+
51+
```bash
52+
# Install dependencies
53+
npm install
54+
55+
# Start development server (on port 3000)
56+
npm run start
57+
```
58+
59+
### Build and Deployment
60+
61+
```bash
62+
# TypeScript compilation
63+
npm run dist
64+
65+
# Start via Docker Compose
66+
npm run deploy
67+
```
68+
69+
## 🧪 Testing
70+
71+
The project uses `mocha` and `chai` for testing. Tests can be run with:
72+
73+
```bash
74+
npm run test
75+
```

0 commit comments

Comments
 (0)