feat: backend ingest API, Docker Compose, Ubuntu install guide

- FastAPI: POST /api/v1/events, GET /health, JSON Schema validation

- PostgreSQL models, Alembic migration, bootstrap API key

- deploy/docker-compose.yml, .env.example

- docs/install-ubuntu-24.04.md, updated work-plan (agents first)
This commit is contained in:
PTah
2026-05-26 20:21:31 +10:00
parent bf1c1c9fe9
commit 69a232d08a
34 changed files with 1139 additions and 134 deletions
+33 -8
View File
@@ -1,11 +1,36 @@
# Backend (FastAPI)
# Backend — Security Alert Center
**Статус:** не реализован. См. [docs/work-plan.md](../docs/work-plan.md) фаза 1.
FastAPI + PostgreSQL + Alembic.
Планируется:
## Локальная разработка (без Docker)
- `app/main.py` — точка входа
- `app/api/v1/events.py` — ingest
- `app/models/` — SQLAlchemy
- `app/services/` — правила, уведомления
- `alembic/` — миграции
```bash
cd backend
python3.12 -m venv .venv
source .venv/bin/activate # Windows: .venv\Scripts\activate
pip install -r requirements.txt
export DATABASE_URL=postgresql+psycopg2://sac:sac@localhost:5432/sac
export SAC_BOOTSTRAP_API_KEY=sac_dev_test_key_change_me
alembic upgrade head
uvicorn app.main:app --reload --port 8000
```
## Docker (из корня репозитория)
```bash
cd deploy
cp .env.example .env
# отредактировать .env
docker compose up -d
docker compose run --rm migrate
curl http://127.0.0.1:8000/health
```
## API
| Метод | Путь | Auth |
|-------|------|------|
| GET | `/health` | нет |
| POST | `/api/v1/events` | Bearer API key |
См. [docs/agent-integration.md](../docs/agent-integration.md) и [docs/event-schema-v1.json](../docs/event-schema-v1.json).