# Quick Environment Reference

## 🔒 SECURITY FIRST

**All `.env*` files (except `.env*.example`) contain real credentials and are NEVER committed to git!**

## 🚀 First-Time Setup

```bash
# 1. Copy template with real credentials
cp backend/.env.prod.example backend/.env.prod

# 2. Edit with YOUR credentials
vim backend/.env.prod

# 3. Fill in the placeholders:
#    - ORACLE_PASSWORD
#    - JWT_SECRET_KEY
#    - AUTH_SESSION_SECRET
#    - TELEGRAM_BOT_TOKEN
#    - SMTP_PASSWORD

# 4. Start production
./start-prod.sh
```

## 📋 Daily Usage

```bash
# Production (uses .env.prod automatically)
./start-prod.sh

# Test Environment (uses .env.test automatically)
./start-test.sh

# Quick Restart (uses existing .env)
./start-backend.sh restart
```

## ✏️ Changing Configuration

```bash
# 1. Edit the source file (NOT .env!)
vim backend/.env.prod    # Production
vim backend/.env.test   # Test

# 2. Restart to apply changes
./start-prod.sh
```

## 📁 Which File to Edit?

| You Want To... | Edit This File |
|----------------|----------------|
| Change dev database password | `backend/.env.prod` |
| Update test server settings | `backend/.env.test` |
| Add new environment variable | Templates: `.env*.example` + your `.env.prod`/`.env.test` |
| Create production config | Copy `.env.prod.example` to `.env.prod` and fill secrets |

## 🔑 Generating Secrets

```bash
# For JWT_SECRET_KEY and AUTH_SESSION_SECRET
python3 -c "import secrets; print(secrets.token_urlsafe(32))"
```

**Generate DIFFERENT secrets for each environment (dev, test, prod)!**

## ⚠️ Important

- **Never edit** `backend/.env` directly (it's auto-generated!)
- **Always edit** `backend/.env.prod` or `.env.test`
- **Never commit** `.env`, `.env.prod`, `.env.test`, `.env.prod`
- **Only commit** `.env*.example` (templates with placeholders)
- Restart after changes for them to take effect

## 🛡️ Git Behavior

| File | Git Status | Contains |
|------|-----------|----------|
| `.env.prod.example` | ✅ Committed | Template (placeholders) |
| `.env.test.example` | ✅ Committed | Template (placeholders) |
| `.env.prod.example` | ✅ Committed | Template (placeholders) |
| `.env.example` | ✅ Committed | Generic template |
| `.env.prod` | ❌ Ignored | **Real dev credentials** |
| `.env.test` | ❌ Ignored | **Real test credentials** |
| `.env.prod` | ❌ Ignored | **Real prod credentials** |
| `.env` | ❌ Ignored | Auto-generated (current) |

## ✅ Quick Check

```bash
# See what git will commit
git status backend/.env*

# Should show ONLY .env*.example files
# If .env.prod or .env.test appear, they're NOT properly ignored!
```

## 📖 More Info

See `backend/ENV-SETUP.md` for complete documentation.
