# Configuration

This guide explains how to configure OrchardGo for development.

## Environment Variables (.env)

The `.env` file contains environment-specific configuration. Copy from the template:

```bash
cp .env.shadow .env
```

### Key Environment Variables

| Variable | Description | Example |
|----------|-------------|---------|
| `AUTH0_DOMAIN` | Auth0 authentication domain | `your-tenant.auth0.com` |
| `AUTH0_CLIENT_ID` | Auth0 client ID | `abc123...` |
| `API_URL` | Backend API URL | `https://api.example.com` |
| `GRAPHQL_URL` | GraphQL endpoint | `https://api.example.com/graphql` |
| `SENTRY_DSN` | Sentry error tracking DSN | `https://...@sentry.io/...` |
| `DATADOG_CLIENT_TOKEN` | DataDog monitoring token | `pub...` |
| `SEGMENT_WRITE_KEY` | Segment analytics key | `xyz789...` |

### Environment-Specific Templates

Different `.env.shadow` files may exist for different environments:
- `.env.shadow` - Default/development
- `.env.test.shadow` - Testing environment
- `.env.qa.shadow` - QA environment

Choose the appropriate template for your needs.

## NPM Configuration (.npmrc)

The `.npmrc` file configures access to private npm packages.

```bash
cp ./setup/.npmrc.shadow .npmrc
```

### Required Tokens

1. **GitHub Token** - For `@theorchard` packages
   - Create at: GitHub Settings → Developer settings → Personal access tokens
   - Scope required: `read:packages`
   - Add to `.npmrc`: `//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}`

2. **Other Private Registries** (if applicable)
   - Consult with your team for additional registry tokens

### Security Note

**Never commit `.npmrc` or `.env` files!** They contain sensitive tokens and are in `.gitignore`.

## Brand Configuration

OrchardGo supports multiple brands (Orchard, Awal). Brand assets are in:

```
brands/
├── orchard/
│   ├── icons/
│   └── images/
└── awal/
    ├── icons/
    └── images/
```

To add a new brand, see [Branding Guide](../guides/branding.md).

## Platform Configuration

### iOS Configuration

Key files:
- `ios/orchardgo.xcworkspace` - Xcode workspace
- `ios/Podfile` - CocoaPods dependencies
- `ios/Podfile.lock` - Locked pod versions
- `ios/orchardgo/Info.plist` - App metadata

#### Bundle Identifier

Configured per brand and environment in:
- Development: `com.theorchard.orchardgo.dev`
- QA: `com.theorchard.orchardgo.qa`
- Production: `com.theorchard.orchardgo`

### Android Configuration

Key files:
- `android/app/build.gradle` - App configuration
- `android/gradle.properties` - Build properties
- `android/app/google-services.json` - Firebase configuration (generated)

#### Application ID

Configured per brand and environment:
- Development: `com.theorchard.orchardgo.dev`
- QA: `com.theorchard.orchardgo.qa`
- Production: `com.theorchard.orchardgo`

For generating `google-services.json`, see [Google Services Configuration](../guides/google-services.md).

## CodePush Configuration

CodePush enables over-the-air JavaScript updates.

### Setup

```bash
# Copy CodePush configuration
cp .code-push.config.qa.shadow .code-push.config

# Login to CodePush
LOCALAPPDATA=. yarn code-push-standalone whoami
```

### Environment Keys

CodePush deployment keys are configured per platform and environment:
- iOS Production: `OrchardGoIOS/Production`
- iOS QA: `OrchardGoIOS/QA`
- Android Production: `OrchardGoAndroid/Production`
- Android QA: `OrchardGoAndroid/QA`

See [CodePush Guide](../deployment/codepush.md) for detailed usage.

## Firebase Configuration

### iOS

Firebase configuration is managed through:
- `GoogleService-Info.plist` files per brand/environment
- Located in `ios/firebase/[brand]/[env]/`

### Android

Firebase configuration is generated dynamically:
```bash
# Apply Google Services JSON for Android
yarn apply:google-services
```

See [Push Notifications Guide](../guides/push-notifications.md) for setup details.

## DataDog Configuration

DataDog provides monitoring and analytics. Configuration includes:
- Client token (in `.env`)
- Application ID (in `.env`)
- Environment name (auto-detected)

DataDog dashboards:
- [Production CodePush](https://app.datadoghq.com/dashboard/bk2-s6f-vtz/prod-code-push-server-release-radar)
- [QA CodePush](https://app.datadoghq.com/dashboard/74n-raq-nip)

## Sentry Configuration

Sentry tracks errors and performance. Configuration:
- DSN in `.env`
- Release version auto-detected from `package.json`
- Source maps uploaded during deployment

## Next Steps

- [Running the App](../development/running-the-app.md)
- [Deployment](../deployment/)
- [Debugging](../development/debugging.md)
