Files
wiki/tasks/flightradar24/frontend/README.md
2026-04-25 13:50:01 +03:00

63 lines
2.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# API Service
Minimal Flask HTTP API that reads from the `fr24` PostgreSQL schema and exposes data for the noisemap UI.
## Endpoints
| Method | Path | Description |
|---|---|---|
| GET | `/health` | API + DB liveness check |
| GET | `/dashboard/status` | Ingest pipeline stats (captures, packets, processing cursor, aircraft, flights) |
| GET | `/viewer/config` | Static system config for the map viewer |
| GET | `/captures` | List capture sessions (`?limit=50`) |
| GET | `/aircraft` | List aircraft (`?limit=100`) |
| GET | `/flights` | List flights (`?limit=100&status=active`) |
| GET | `/api/schedule/data` | Расписание рейсов с обогащением. Параметры: `flight_date`, `date_from`, `date_to`, `airport`, `direction`, `limit`, `offset` |
| GET | `/api/flight-actual` | Данные из `fr24_ext.flight_actual` (FR24 summary/full) |
| GET | `/api/data-sources/coverage` | Покрытие источниками по дням |
| GET | `/api/data-sources/quality` | Качество данных |
| GET | `/api/data-sources/top-airlines` | Топ авиакомпаний |
| GET | `/api/data-sources/top-routes` | Топ маршрутов |
| GET | `/api/data-sources/airport-load` | Загрузка аэропортов |
| GET | `/monitoring` | Мониторинг системы (контейнеры, DB, диск) |
### Поле `aircraft_type` в `/api/schedule/data`
Тип ВС возвращается через `COALESCE(mf.aircraft_type, s.aircraft_type)`:
- Приоритет: `fr24_mart.flights` (если есть трек за этот день)
- Fallback: `fr24_ext.schedule` (из Яндекс.Расписаний)
Это гарантирует заполненность колонки даже для дней без RTL-SDR данных.
## Dependencies
- `flask` — HTTP server
- `psycopg2-binary` — PostgreSQL driver
## Environment variables
| Variable | Default | Description |
|---|---|---|
| `POSTGRES_HOST` | required | DB host |
| `POSTGRES_PORT` | `5432` | DB port |
| `POSTGRES_DB` | required | DB name |
| `POSTGRES_USER` | required | DB user |
| `POSTGRES_PASSWORD` | required | DB password |
| `API_PORT` | `8080` | Port to listen on |
## Run locally
```bash
pip install -r requirements.txt
export POSTGRES_HOST=localhost POSTGRES_DB=fr24 POSTGRES_USER=fr24 POSTGRES_PASSWORD=change-me
python main.py
# → http://localhost:8080/health
```
## Build & run via Docker
```bash
docker build -t fr24-api .
docker run -p 8080:8080 --env-file ../../compose/.env fr24-api
```