> ## Documentation Index
> Fetch the complete documentation index at: https://docs.wethehivers.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Environnements

> URLs et configuration par environnement (dev, staging, production)

# Environnements

THE HIVE expose trois environnements distincts avec des bases de données et des stockages séparés.

## Bases URL

| Env         | API                                          | Candidat                  | Recruteur                           | Admin                           |
| ----------- | -------------------------------------------- | ------------------------- | ----------------------------------- | ------------------------------- |
| **Prod**    | `https://api.wethehivers.com/v1/api`         | `wethehivers.com`         | `recruteur.wethehivers.com`         | `admin.wethehivers.com`         |
| **Staging** | `https://api-staging.wethehivers.com/v1/api` | `staging.wethehivers.com` | `recruteur-staging.wethehivers.com` | `admin-staging.wethehivers.com` |
| **Dev**     | `http://localhost:3091/v1/api`               | `localhost:3000`          | `localhost:3001`                    | `localhost:3002`                |

## Topologie

```mermaid theme={null}
flowchart TB
    subgraph Prod[Production — Hostinger + Cloudflare]
        CF[Cloudflare DNS + SSL + R2]
        CF --> VPS1[VPS1 16 Go\n Nginx + Backend + Redis]
        CF -.failover.-> VPS2[VPS2 8 Go\n Nginx + Backend + Redis + Uptime Kuma]
        VPS1 --> VPS3[VPS3 4 Go\n PostgreSQL]
        VPS2 --> VPS3
        VPS1 --> R2[(Cloudflare R2\n fichiers)]
        VPS2 --> R2
    end

    subgraph Staging[Staging]
        SV[VPS staging\n Backend + Nginx + PostgreSQL + MinIO]
    end

    subgraph Dev[Dev local]
        LBE[localhost:3091\n Spring Boot]
        LBE --> LPG[(PostgreSQL\n localhost:5432)]
        LBE --> LMINIO[(MinIO\n localhost:9000)]
        LBE --> LMH[MailHog\n localhost:8025]
    end
```

## Caractéristiques par environnement

| Attribut                 | Dev           | Staging          | Prod                        |
| ------------------------ | ------------- | ---------------- | --------------------------- |
| SSL                      | Non           | Let's Encrypt    | Cloudflare + LE             |
| Rate limiting            | Désactivé     | 2× prod          | Actif                       |
| Emails réels             | Non (MailHog) | Non (test inbox) | Oui                         |
| Logs niveau              | DEBUG         | INFO             | WARN                        |
| Springdoc `/v3/api-docs` | Activé        | Activé           | **Désactivé**               |
| Blacklist JWT            | In-memory     | Redis            | Redis (partagée VPS1/VPS2)  |
| Stockage fichiers        | MinIO         | MinIO            | Cloudflare R2               |
| Flyway auto-migrate      | Oui           | Oui              | VPS1 uniquement             |
| Backups DB               | Non           | Quotidien        | Horaire + quotidien chiffré |

## Statut en temps réel

| Env     | Status page                                    |
| ------- | ---------------------------------------------- |
| Prod    | `https://status.wethehivers.com` (Uptime Kuma) |
| Staging | Interne                                        |

## Secrets par environnement

```mermaid theme={null}
flowchart LR
    GL[GitLab CI/CD] -->|vars masqués| DEP[Deploy]
    DEP --> ENV[.env sur VPS chmod 600]
    ENV --> APP[Spring Boot\n @Value]

    subgraph Secrets
        JWT[JWT_SECRET]
        DBP[DB_PASSWORD]
        R2K[R2_ACCESS_KEY]
        R2S[R2_SECRET_KEY]
        SMTP[MAIL_PASSWORD]
    end

    GL -.-> Secrets
```

<Warning>
  Ne jamais committer de secret dans le repo. Les variables d'environnement sont toutes masquées dans GitLab CI/CD et chiffrées au repos.
</Warning>

## Rotation des tokens

| Token                | Rotation                       |
| -------------------- | ------------------------------ |
| JWT\_SECRET          | Trimestrielle + après incident |
| R2 access/secret key | Semestrielle                   |
| SMTP password        | Semestrielle                   |
| DB password          | Annuelle (hors incident)       |

## Connectivité

```bash theme={null}
# Health check — tous env
curl https://api.wethehivers.com/v1/api/actuator/health
curl https://api-staging.wethehivers.com/v1/api/actuator/health
curl http://localhost:3091/v1/api/actuator/health
```

<Info>
  En production Cloudflare est configuré en **orange-cloud proxy**. Les vraies IPs clients sont transmises via le header `CF-Connecting-IP`.
</Info>
