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

# Environment Variables Reference

> Comprehensive list of all required and optional environment variables for LearnWay Backend.

# Environment Variables Reference

Configuration is loaded from `config/env/.env` using `@nestjs/config` and validated against a Joi schema on application boot.

***

## Core Server & Database

| Variable          | Type     | Required | Description                            | Example                 |
| ----------------- | -------- | -------- | -------------------------------------- | ----------------------- |
| `NODE_ENV`        | `string` | No       | Environment mode: `dev` or `prod`      | `dev`                   |
| `PORT`            | `number` | No       | HTTP listening port (defaults to 3000) | `3000`                  |
| `DB_HOST`         | `string` | **Yes**  | PostgreSQL host address                | `localhost`             |
| `DB_PORT`         | `number` | **Yes**  | PostgreSQL port                        | `5432`                  |
| `DB_USERNAME`     | `string` | **Yes**  | PostgreSQL user                        | `postgres`              |
| `DB_PASSWORD`     | `string` | **Yes**  | PostgreSQL password                    | `secret`                |
| `DB_NAME`         | `string` | **Yes**  | PostgreSQL database name               | `learnway`              |
| `FRONTEND_ORIGIN` | `string` | No       | Allowed CORS origin                    | `http://localhost:5173` |

***

## Redis & Caching

| Variable         | Type     | Required | Description                          | Example                  |
| ---------------- | -------- | -------- | ------------------------------------ | ------------------------ |
| `REDIS_URL`      | `string` | **Yes**  | Redis connection URI for Bull queues | `redis://localhost:6379` |
| `REDIS_HOST`     | `string` | No       | Redis host for CacheManager          | `localhost`              |
| `REDIS_PORT`     | `number` | No       | Redis port                           | `6379`                   |
| `REDIS_PASSWORD` | `string` | No       | Redis auth password                  | `redispassword`          |

***

## Media (ImageKit)

| Variable                | Type     | Required | Description                                               |
| ----------------------- | -------- | -------- | --------------------------------------------------------- |
| `IMAGEKIT_PUBLIC_KEY`   | `string` | **Yes**  | ImageKit client-side public key                           |
| `IMAGEKIT_PRIVATE_KEY`  | `string` | **Yes**  | ImageKit server-side private key                          |
| `IMAGEKIT_URL_ENDPOINT` | `string` | **Yes**  | ImageKit endpoint URL (e.g. `https://ik.imagekit.io/xxx`) |

***

## Blockchain & Web3

| Variable                            | Type     | Required | Description                                       |
| ----------------------------------- | -------- | -------- | ------------------------------------------------- |
| `BLOCKCHAIN_RPC_URL`                | `string` | **Yes**  | EVM RPC endpoint (Lisk L2)                        |
| `CHAIN_ID`                          | `number` | **Yes**  | Chain ID (e.g. `1135` for Lisk)                   |
| `PRIVATE_KEY`                       | `string` | **Yes**  | 64-character hex private key of deployment wallet |
| `LEARNWAY_MANAGER_CONTRACT_ADDRESS` | `string` | **Yes**  | Deployed LearnwayManager contract                 |
| `BADGES_NFT_CONTRACT_ADDRESS`       | `string` | **Yes**  | Deployed Badges ERC-1155 contract                 |
| `GEM_CONTRACT_ADDRESS`              | `string` | **Yes**  | Deployed Gems ERC-20 contract                     |
| `XP_CONTRACT_ADDRESS`               | `string` | **Yes**  | Deployed XP ERC-20 contract                       |
| `USDT_CONTRACT_ADDRESS`             | `string` | No       | USDT ERC-20 token address                         |

***

## Payments (Fonbnk)

| Variable                | Type     | Required | Description                            |
| ----------------------- | -------- | -------- | -------------------------------------- |
| `FONBNK_API_BASE_URL`   | `string` | No       | Base API URL (defaults to sandbox)     |
| `FONBNK_CLIENT_ID`      | `string` | **Yes**  | Fonbnk API client ID                   |
| `FONBNK_CLIENT_SECRET`  | `string` | **Yes**  | Fonbnk base64-encoded secret           |
| `FONBNK_WEBHOOK_SECRET` | `string` | **Yes**  | Secret for verifying incoming webhooks |

***

## External Integrations

| Variable                 | Description                                             |
| ------------------------ | ------------------------------------------------------- |
| `GOOGLE_GEMINI_API_KEY`  | API Key for Google Gemini (AI Tutor & Skill Assessment) |
| `RESEND_API_KEY`         | API Key for Resend transactional email service          |
| `CMC_API_KEY`            | CoinMarketCap API key for real-time crypto price feeds  |
| `FIREBASE_PROJECT_ID`    | Firebase project ID for FCM Push Notifications          |
| `REVCAT_IOS_API_KEY`     | RevenueCat public key for iOS                           |
| `REVCAT_ANDROID_API_KEY` | RevenueCat public key for Android                       |
