# {{ project_name }} - Provisioning Configuration

**Generated by typedialog-prov-gen**

This directory contains the complete provisioning configuration for {{ project_name }}, using TypeDialog forms with Nickel configuration validation.

## Quick Start

1. **Run the configuration wizard:**
   ```bash
   ./scripts/configure.sh
   ```

2. **Generated files will be in `generated/`:**
   - `config.ncl` - Nickel source configuration
   - `config.json` - JSON export
   - `config.yaml` - YAML export

3. **Validate configuration:**
   ```bash
   nickel typecheck generated/config.ncl
   ```

## Directory Structure

```
provisioning/
├── config.ncl                  # Main Nickel configuration entry point
├── config-form.toml            # TypeDialog master form
├── constraints.toml            # Validation constraints
├── defaults/                   # Default values for all features
├── docs/                       # Documentation guides
├── fragments/                  # Form field fragments
├── generated/                  # Generated configurations (git-ignored)
├── locales/                    # i18n translations (en-US, es-ES)
├── schemas/                    # Nickel type schemas
├── scripts/                    # Configuration and deployment scripts
├── templates/                  # Infrastructure templates (Terraform, Ansible, etc.)
├── validators/                 # Validation predicates
└── values/                     # User-editable runtime values
```

## Features

{% for feature in features %}
### {{ feature.name }}

{{ feature.description | default(value="No description available") }}

**Fields:** {{ feature.fields | length }} configuration fields

{% endfor %}

## Configuration Workflow

1. **Interactive Form** → Run `./scripts/configure.sh` to collect user input
2. **JSON Generation** → TypeDialog outputs user values as JSON
3. **Nickel Conversion** → JSON is embedded into Nickel configuration
4. **Schema Validation** → Nickel type contracts enforce correctness
5. **Export** → Final configuration exported to JSON/YAML/TOML

## Infrastructure as Code

{% if iac_templates.terraform_enabled %}
### Terraform/OpenTofu

Templates in `templates/tofu/`:
- `common/` - Shared Terraform modules
- `hetzner/` - Hetzner Cloud provider
- `lxd/` - LXD container provider

**Usage:**
```bash
cd templates/tofu/hetzner
terraform init
terraform plan -var-file="../../../generated/config.tfvars"
```
{% endif %}

{% if iac_templates.ansible_enabled %}
### Ansible

Playbooks in `templates/ansible/`:
- `deploy.yml` - Main deployment playbook
- `inventory.yml` - Dynamic inventory

**Usage:**
```bash
ansible-playbook templates/ansible/deploy.yml -i templates/ansible/inventory.yml
```
{% endif %}

{% if iac_templates.docker_compose_enabled %}
### Docker Compose

Compose files in `templates/docker-compose/`:
- `service.yml` - Main service definition
- `monitoring.yml` - Monitoring stack (Prometheus, Grafana)

**Usage:**
```bash
docker-compose -f templates/docker-compose/service.yml up -d
```
{% endif %}

## Scripts

- `configure.sh` / `configure.nu` - Main configuration wizard (Bash/Nushell)
- `nickel-to-json.sh` / `.nu` - Export Nickel → JSON
- `nickel-to-yaml.sh` / `.nu` - Export Nickel → YAML
- `json-to-nickel.sh` / `.nu` - Import JSON → Nickel

## Nickel Roundtrip Workflow

See [NICKEL_ROUNDTRIP.md](docs/NICKEL_ROUNDTRIP.md) for detailed workflow documentation.

**Summary:**
1. Edit values in `values/config.ncl`
2. Run `nickel typecheck values/config.ncl`
3. Export with `nickel export values/config.ncl > generated/config.json`
4. Apply to infrastructure

## Localization

Supported locales:
{% for locale in locales %}
- {{ locale.language_code }}{% if locale.is_default %} (default){% endif %}
{% endfor %}

Translation files in `locales/{lang}/forms.ftl` (Fluent format).

## Documentation

- [README.md](README.md) - This file
- [docs/QUICKSTART.md](docs/QUICKSTART.md) - Getting started guide
- [docs/NICKEL_ROUNDTRIP.md](docs/NICKEL_ROUNDTRIP.md) - Nickel roundtrip workflow

## License

{{ license | default(value="MIT") }}
