# Haumdaucher Website 🦢🍻

D'Offizielle Website der Haumdaucher aus Regensburg.

## 🚀 Quick Start (Local)

```bash
npm install
npm run dev
```
Visit [http://localhost:5173/](http://localhost:5173/) to see the site.

## 🛠 Documentation

For detailed information on the project structure, how to modify themes, update content, or deploy to Kubernetes, please see the **[Development Guide](DEVELOPMENT.md)**.

## 🎡 Deployment

Use the provided deployment script to push to your Kubernetes cluster:
```bash
./deploy.sh
```
Check [k8s-manifests.yaml](k8s-manifests.yaml) for resource definitions.

## 🚀 Bootstrap & Authentication (Infrastructure)

We use Terraform to manage Firebase Authentication and Firestore. To set this up for a new environment:

### 1. Manual Prerequisites (One-time)
1.  **Create a Project**: Go to [Google Cloud Console](https://console.cloud.google.com/) and create a new project.
2.  **Enable Billing**: Link a Billing Account to this project (Required for Terraform to enable Identity Platform).
    3.  **Local Auth**:
        ```bash
        gcloud auth login
        gcloud auth application-default login
        ```
    4.  **Configure OAuth (Crucial Step)**:
        *   Go to [APIs & Services > OAuth consent screen](https://console.cloud.google.com/apis/credentials/consent).
        *   Select **External** -> Create.
        *   Fill in: App Name ("Haumdaucher"), Support Email, and Developer Contact Email. Click **Save and Continue** (You can skip scopes/test users for now).
        *   Go to [Credentials](https://console.cloud.google.com/apis/credentials).
        *   Click **+ Create Credentials** > **OAuth client ID**.
        *   Type: **Web application**.
        *   Name: "Haumdaucher Web".
        *   **Authorized JavaScript origins**:
            *   `http://localhost:5173`
            *   `https://haumdaucher.de`
            *   `https://haumdaucher.web.app` (Default Firebase Hosting URL)
        *   **Authorized redirect URIs**:
            *   `https://haumdaucher.firebaseapp.com/__/auth/handler`
        *   Click **Create**.
    5.  **Configure Secrets**:
        Run the helper script and paste the **Client ID** and **Client Secret** you just created:
        ```bash
        ./scripts/manage_secrets.py
        ```
    6.  **Verify**: Log in to the application. You should see the member banner.

## 🛠 Local Development Requirements

This project uses **Firebase** for authentication. To run the app locally, you need the environment variables (API keys) that are normally injected during deployment.

### 1. Generate Local Environment Config
We typically manage infrastructure via Terraform. Use the included helper script to fetch the configuration from your active Terraform state and create a local `.env` file:

```bash
npm run setup:env
```

*Prerequisites: You must have `terraform` and `jq` installed, and `terraform apply` must have been run at least once.*

### 2. Start Dev Server
```bash
npm run dev
```

### 2. Infrastructure Deployment
Navigate to the `terraform` directory and apply the configuration:

```bash
cd terraform
terraform init
terraform apply -var="project_id=YOUR_PROJECT_ID" -var='allowed_users=["your_email@gmail.com"]'
```

This will:
- Enable Firebase, Firestore, and Identity APIs.
- Create the Firestore Database.
- Create the **Allowlist** in Firestore (`config/allowlist`).

### 3. Adding Friends
To approve new users, simply update the `allowed_users` list in your `terraform.tfvars` (or CLI argument) and re-run `terraform apply`.

