# Infra — Familienarchiv

## Overview

Infrastructure-as-code and deployment configurations for the Familienarchiv platform. Currently focused on Gitea CI/CD workflows.

## Folder Structure

```
infra/
└── gitea/
    └── workflows/
        └── ci.yml    # Gitea Actions CI pipeline
```

## CI/CD Pipeline (`gitea/workflows/ci.yml`)

The CI pipeline runs on every push and pull request. It consists of three parallel jobs:

### 1. Unit & Component Tests (`unit-tests`)
- **Container**: `mcr.microsoft.com/playwright:v1.58.2-noble`
- **Steps**:
  1. Checkout code
  2. Cache and install `node_modules`
  3. Compile Paraglide i18n
  4. Run lint (Prettier + ESLint)
  5. Run Vitest unit + browser component tests
  6. Upload screenshots on failure

### 2. OCR Service Tests (`ocr-tests`)
- **Runner**: `ubuntu-latest`
- **Steps**:
  1. Setup Python 3.11
  2. Install test dependencies (`pyspellchecker`, `pytest`, `pytest-asyncio`)
  3. Run pure-logic tests (no ML stack required):
     - `test_spell_check.py`
     - `test_confidence.py`
     - `test_sender_registry.py`

### 3. Backend Unit Tests (`backend-unit-tests`)
- **Runner**: `ubuntu-latest`
- **Env**: `DOCKER_API_VERSION=1.43` (for Testcontainers compatibility)
- **Steps**:
  1. Setup Java 21 (Temurin)
  2. Cache Maven repository
  3. Run `./mvnw clean test`

## How to Run CI Locally

### Frontend Tests (same as CI)
```bash
cd frontend
npm ci
npx @inlang/paraglide-js compile --project ./project.inlang --outdir ./src/lib/paraglide
npm run lint
npm test
```

### OCR Tests (same as CI)
```bash
cd ocr-service
pip install "pyspellchecker==0.9.0" pytest pytest-asyncio
python -m pytest test_spell_check.py test_confidence.py test_sender_registry.py -v
```

### Backend Tests (same as CI)
```bash
cd backend
chmod +x mvnw
./mvnw clean test
```

## Future Infrastructure

Potential additions to this folder:
- Terraform / OpenTofu configs for cloud deployment
- Ansible playbooks for bare-metal setup
- Kubernetes manifests (Helm charts)
- Monitoring stack configs (Prometheus, Grafana)
- Reverse proxy configs (Nginx, Traefik)

## Notes

- The pipeline uses Gitea Actions (syntax-compatible with GitHub Actions).
- Docker API version pinning ensures compatibility with older Docker daemon versions.
- No deployment stage is defined yet — the CI stops at test verification.
