From 3a19de64eee2024b63f3ff894de9754e5ca3d28d Mon Sep 17 00:00:00 2001 From: Nico Montanari Date: Tue, 17 Mar 2026 13:12:48 +0100 Subject: [PATCH 1/2] 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. --- README.md | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 README.md diff --git a/README.md b/README.md new file mode 100644 index 0000000..71bbfe9 --- /dev/null +++ b/README.md @@ -0,0 +1,75 @@ +# Mida-Sync (Meteo Info Daily Alert Sync) + +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. + +## ๐ŸŒŸ Implemented Products and Services + +The system interfaces with various official and unofficial sources to provide a complete meteorological overview: + +1. **[Allerta Meteo Regione Emilia-Romagna](https://allertameteo.regione.emilia-romagna.it/)** + - **Feature:** Daily monitoring of the meteorological alert status. + - **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. + - **Notification:** Sends a Telegram message formatted with the alert colors and a direct link to the official PDF bulletin. + +2. **[Estofex (European Storm Forecast Experiment)](https://www.estofex.org/)** + - **Feature:** Integration of European severe storm bulletins. + - **Details:** Analyzes the Estofex XML feed to check for level 1, 2, or 3 forecasts for the following day. + - **Notification:** In case of critical alerts in the local territory, it sends the European convective forecast map to the Telegram channel. + +3. **[Pretemp (Previsione Temporali)](https://pretemp.altervista.org/)** + - **Feature:** Integration of Italian thunderstorm forecast bulletins. + - **Details:** Dynamically retrieves forecast maps for the following day via the Pretemp archive. + - **Notification:** If conditions require it (presence of ongoing alerts), it sends the thunderstorm forecast image to the Telegram channel. + +## ๐Ÿ•’ Scheduled Tasks (Crons) + +The application relies on scheduled tasks (crons) to automate the weather monitoring flow: + +- **Meteo Alerts Check** + - 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. +- **Pretemp Report Check** + - Verifies and sends the Pretemp map for the following day, provided there is an ongoing alert and the map hasn't been sent yet. +- **Estofex Report Check** + - Verifies and sends the Estofex map for the following day, following the same conditional logic based on ongoing alerts. + +## โš™๏ธ Configuration and Installation + +### Prerequisites +- Node.js (v22+) +- PostgreSQL +- Docker (optional, for deployment) +- A valid Telegram Bot token and a destination Chat ID. + +### Environment Variables (`.env`) +The project uses a `.env` file for configuration. Required keys include: +- PostgreSQL Database credentials (Host, User, Password, DB Name) +- `TELEGRAM_TOKEN`: Telegram Bot token. +- `CHAT_ID`: ID of the Telegram chat or channel where alerts will be sent. + +### Development Setup + +```bash +# Install dependencies +npm install + +# Start development server (on port 3000) +npm run start +``` + +### Build and Deployment + +```bash +# TypeScript compilation +npm run dist + +# Start via Docker Compose +npm run deploy +``` + +## ๐Ÿงช Testing + +The project uses `mocha` and `chai` for testing. Tests can be run with: + +```bash +npm run test +``` From 2f6c4ab6b9c036c216caa5fd0d01e872fd3de5d8 Mon Sep 17 00:00:00 2001 From: Nico Montanari Date: Tue, 17 Mar 2026 13:14:50 +0100 Subject: [PATCH 2/2] Update README.md for clarity and consistency * Remove emojis from section headers for a cleaner presentation. * Adjust section titles for improved readability and uniformity. * Enhance the description of configuration requirements and testing instructions. --- README.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 71bbfe9..0d5577d 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ 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. -## ๐ŸŒŸ Implemented Products and Services +## Implemented Products and Services The system interfaces with various official and unofficial sources to provide a complete meteorological overview: @@ -21,7 +21,7 @@ The system interfaces with various official and unofficial sources to provide a - **Details:** Dynamically retrieves forecast maps for the following day via the Pretemp archive. - **Notification:** If conditions require it (presence of ongoing alerts), it sends the thunderstorm forecast image to the Telegram channel. -## ๐Ÿ•’ Scheduled Tasks (Crons) +## Scheduled Tasks (Crons) The application relies on scheduled tasks (crons) to automate the weather monitoring flow: @@ -32,16 +32,19 @@ The application relies on scheduled tasks (crons) to automate the weather monito - **Estofex Report Check** - Verifies and sends the Estofex map for the following day, following the same conditional logic based on ongoing alerts. -## โš™๏ธ Configuration and Installation +## Configuration and Installation ### Prerequisites + - Node.js (v22+) - PostgreSQL - Docker (optional, for deployment) - A valid Telegram Bot token and a destination Chat ID. ### Environment Variables (`.env`) + The project uses a `.env` file for configuration. Required keys include: + - PostgreSQL Database credentials (Host, User, Password, DB Name) - `TELEGRAM_TOKEN`: Telegram Bot token. - `CHAT_ID`: ID of the Telegram chat or channel where alerts will be sent. @@ -66,7 +69,7 @@ npm run dist npm run deploy ``` -## ๐Ÿงช Testing +## Testing The project uses `mocha` and `chai` for testing. Tests can be run with: