A fault-tolerant, secure, and high-performance backend system written in Rust to monitor drone activity, detect no-fly zone (NFZ) violations, and expose secure endpoints for real-time data access.
- ✅ Polls live drone data every 10 seconds from a remote API
- 🚫 Detects NFZ violations within a 1000-unit circular boundary centered at (0, 0)
- 🔒 Fetches and stores drone owner information only if a violation occurs
- 💾 Persists violations in PostgreSQL
- 🔐 Secured access to personal violation data using
X-Secretheader - 🧩 Built with SOLID principles, modular design patterns
- 🐳 Fully containerized with Docker and Docker Compose
+---------------------+
| External Drone API |
+---------------------+
|
v
+---------------+ +------------------+
| Poller (task) |-------------->| PostgreSQL DB |
+---------------+ +------------------+
| ^
| |
+---------v----------+ +----------+---------+
| Axum RESTful API |<-------->| /nfz, /drones, / |
+--------------------+ +--------------------+
| Tech | Role |
|---|---|
| Rust (2021) | Core programming language |
| Axum | Fast, modular web server |
| SQLx | Async-safe PostgreSQL ORM |
| Reqwest | HTTP client for polling APIs |
| Tokio | Async runtime |
| Serde | JSON parsing |
| dotenvy | Environment management |
| tracing | Structured, async logging |
| Docker + Compose | Container orchestration and networking |
fdf_fi/
├── src/
│ ├── config.rs # AppConfig, AppState, .env parsing
│ ├── db.rs # PostgreSQL connection pool
│ ├── main.rs # Application entrypoint
│ ├── models/ # Violation, Drone, Owner structs
│ ├── routes/ # REST endpoints: /nfz, /health, /drones
│ ├── tasks/ # Poller logic
├── migrations/ # SQLx migrations
├── .env.example # Example environment variables
├── Dockerfile # Multi-stage build for Rust
├── docker-compose.yml # Orchestration with PostgreSQL
└── README.md
curl http://localhost:8000/health{ "success": "ok" }curl http://localhost:8000/dronesReturns raw array of drones from upstream.
curl -H "X-Secret: your-secret-here" http://localhost:8000/nfzReturns:
[
{
"id": "...",
"owner_id": 123,
"x": 45.0,
"y": 30.0,
"z": 80.0,
"timestamp": "...",
"owner_first_name": "John",
"owner_last_name": "Doe",
"owner_ssn": "123-45-6789",
"owner_phone": "+123456789"
},
...
]Copy from .env.example:
DATABASE_URL=postgres://root:password@postgres:5432/air_guardian
NFZ_API_SECRET=your-secret-here
DRONES_API_BASE_URL=https://drones-api
DRONES_ENDPOINT=/drones
USERS_ENDPOINT=/users
POLL_INTERVAL_SECS=10
POSTGRES_USER=root
POSTGRES_PASSWORD=password
POSTGRES_DB=air_guardiandocker-compose up --buildThis will:
- Run the backend at
http://localhost:8000 - Start PostgreSQL at
localhost:5432
curl http://localhost:8000/health
curl http://localhost:8000/drones
curl -H "X-Secret: your-secret-here" http://localhost:8000/nfz- investigate more error handling, Api responses and logging
🛡️ MIT License — secure and production-ready.