# Judicial Monitor

Internal Portuguese judicial process monitoring. FastAPI + React + Postgres in Docker.

## Bootstrap (CT/LXC, as root)

```bash
cd /opt/judicial
cp .env.example .env
$EDITOR .env                              # set POSTGRES_PASSWORD, SECRET_KEY, ADMIN_EMAIL
docker compose up -d --build
docker compose exec backend python -m app.cli create-admin --email "$(grep ADMIN_EMAIL .env | cut -d= -f2)"
curl -s -o /dev/null -w "%{http_code}\n" http://localhost/api/health   # expect 200
```

## Operate

- **View logs**: `docker compose logs -f backend`
- **Run scrape manually**: `docker compose exec backend python -m app.cli run-scrape distribuicao|cire|ptdata`
- **Open a DB shell**: `docker compose exec postgres psql -U judicial -d judicial`
- **Backup**: `./infra/backup.sh` (dumps to `./backups/`, 30d retention)
- **Update**: `git pull && docker compose up -d --build`

## Scheduled jobs (Europe/Lisbon)

| Job | Cron |
|---|---|
| Distribuição daily | 03:00 |
| CIRE daily | 03:30 |
| ptdata refresh | 04:15 |
| Vacuum logs | Sundays 02:00 |
