> For clean Markdown of any page, append .md to the page URL.
> For a complete documentation index, see https://docs.adid.dev/llms.txt.
> For full documentation content, see https://docs.adid.dev/llms-full.txt.

# Configuration

All IDA services are configured via environment variables.

## API Service

| Variable                       | Required | Default | Description                               |
| ------------------------------ | -------- | ------- | ----------------------------------------- |
| `DATABASE_URL`                 | Yes      | -       | PostgreSQL connection string              |
| `REDIS_URL`                    | Yes      | -       | Redis connection string                   |
| `ADI_RPC_URL`                  | Yes      | -       | ADI blockchain RPC endpoint               |
| `ADI_CHAIN_ID`                 | No       | 1337    | ADI chain ID                              |
| `NATS_URL`                     | Yes      | -       | NATS server URL                           |
| `IPFS_API_URL`                 | Yes      | -       | IPFS API URL                              |
| `API_PORT`                     | No       | 8080    | API server port                           |
| `LOG_LEVEL`                    | No       | info    | Log level (debug, info, warn, error)      |
| `DID_REGISTRY_ADDRESS`         | Yes      | -       | DID Registry contract address             |
| `SCHEMA_REGISTRY_ADDRESS`      | Yes      | -       | Schema Registry contract address          |
| `REVOCATION_REGISTRY_ADDRESS`  | Yes      | -       | Revocation Registry contract address      |
| `AGENT_TRUST_REGISTRY_ADDRESS` | Yes      | -       | Agent Trust Registry contract address     |
| `SIGNING_KEY`                  | Yes      | -       | Platform signing key (for audit receipts) |
| `CORS_ORIGINS`                 | No       | `*`     | Allowed CORS origins                      |
| `RATE_LIMIT_ENABLED`           | No       | true    | Enable rate limiting                      |
| `RATE_LIMIT_REQUESTS`          | No       | 1000    | Requests per minute per API key           |

## Resolver Service

| Variable        | Required | Default | Description                        |
| --------------- | -------- | ------- | ---------------------------------- |
| `ADI_RPC_URL`   | Yes      | -       | ADI blockchain RPC endpoint        |
| `REDIS_URL`     | Yes      | -       | Redis for DID resolution cache     |
| `IPFS_API_URL`  | Yes      | -       | IPFS for DID Document retrieval    |
| `RESOLVER_PORT` | No       | 8081    | Resolver server port               |
| `CACHE_TTL`     | No       | 300     | DID resolution cache TTL (seconds) |

## Portal

| Variable                  | Required | Default | Description            |
| ------------------------- | -------- | ------- | ---------------------- |
| `VITE_API_URL`            | Yes      | -       | IDA API base URL       |
| `VITE_RESOLVER_URL`       | No       | -       | DID resolver URL       |
| `VITE_CHAIN_EXPLORER_URL` | No       | -       | ADI block explorer URL |

## ADI Blockchain Node

| Variable    | Required | Default | Description                             |
| ----------- | -------- | ------- | --------------------------------------- |
| `NETWORK`   | Yes      | devnet  | Network name (devnet, testnet, mainnet) |
| `NODE_ID`   | Yes      | -       | Unique node identifier                  |
| `VALIDATOR` | No       | false   | Enable validator mode                   |
| `BOOTNODE`  | No       | -       | Bootnode address for peer discovery     |
| `DATA_DIR`  | No       | /data   | Blockchain data directory               |

## Example .env File

```env
# Database
DATABASE_URL=postgres://ida:ida_secret@localhost:5432/ida?sslmode=disable
REDIS_URL=redis://localhost:6379

# Blockchain
ADI_RPC_URL=http://localhost:30303
ADI_CHAIN_ID=1337

# Smart Contracts
DID_REGISTRY_ADDRESS=0x5FbDB2315678afecb367f032d93F642f64180aa3
SCHEMA_REGISTRY_ADDRESS=0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
REVOCATION_REGISTRY_ADDRESS=0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
AGENT_TRUST_REGISTRY_ADDRESS=0xCf7Ed3AccA5a467e9e704C703E8D87F634fB0Fc9

# Services
NATS_URL=nats://localhost:4222
IPFS_API_URL=http://localhost:5001

# API
API_PORT=8080
RESOLVER_PORT=8081
LOG_LEVEL=debug
CORS_ORIGINS=http://localhost:5173,http://localhost:3000

# Security
SIGNING_KEY=your-platform-signing-key
RATE_LIMIT_ENABLED=true
RATE_LIMIT_REQUESTS=1000
```

## Configuration Precedence

1. Environment variables (highest priority)
2. `.env` file in project root
3. Default values (lowest priority)

## Secrets Management

For production deployments, use a secrets manager:

| Platform   | Method                                         |
| ---------- | ---------------------------------------------- |
| Kubernetes | Kubernetes Secrets + external-secrets-operator |
| AWS        | AWS Secrets Manager                            |
| GCP        | Google Secret Manager                          |
| Azure      | Azure Key Vault                                |
| HashiCorp  | Vault                                          |

Never commit secrets to version control. Use `.env.example` as a template.