SafiGuard Node.js/Express backend — REST API for policies, oracle data, and governance. Aggregates weather data from Open-Meteo, NASA POWER, and CHIRPS. Handles Stellar transactions, policy monitoring, and SMS/email notifications via Africa's Talking. PostgreSQL + Redis.
# SafiGuard Backend API
**Parametric micro-insurance on Stellar/Soroban for underserved markets.**
SafiGuard provides automated crop and weather insurance for smallholder farmers across Africa. This backend service handles oracle data feeds, weather API aggregation, policy management, and SMS notifications.
---
## Architecture
```
+---------------------+
| Soroban Contracts |
| (Insurance + Oracle)|
+----------+----------+
|
+-------------------+ +-------------------+ | +-------------------+
| Open-Meteo API +--->| | | | Africa's Talking |
+-------------------+ | SafiGuard +---+ | SMS Gateway |
| CHIRPS Satellite+--->| Backend API +------>+-------------------+
+-------------------+ | |
| NASA POWER API +--->| (Express/TS) +------>+-------------------+
+-------------------+ | | | Frontend App |
+--------+----------+ +-------------------+
|
+-------------+-------------+
| |
+-----+------+ +-------+------+
| PostgreSQL | | Redis |
| Database | | Cache |
+-------------+ +--------------+
```
## Tech Stack
| Component | Technology |
|-----------|-----------|
| Runtime | Node.js 20+ |
| Language | TypeScript 5.7 |
| Framework | Express.js 4 |
| Blockchain | Stellar / Soroban |
| Database | PostgreSQL 16 |
| Cache | Redis 7 |
| SMS | Africa's Talking |
| Weather Data | Open-Meteo, CHIRPS, NASA POWER |
| Task Scheduling | node-cron |
| Validation | Joi |
| Logging | Winston |
## Prerequisites
- **Node.js** >= 20.0.0
- **PostgreSQL** >= 16
- **Redis** >= 7
- **Docker** and **Docker Compose** (optional, for containerized setup)
## Setup
### Local Development
1. **Clone the repository:**
```bash
git clone
github.com
cd safiguard-backend
```
2. **Install dependencies:**
```bash
npm install
```
3. **Configure envi …