========================================
REDIS SETUP FOR TAT NOTIFICATIONS
========================================

-----------------------------------------
OPTION 1: UPSTASH (★ RECOMMENDED ★)
-----------------------------------------

✅ NO INSTALLATION NEEDED
✅ 100% FREE FOR DEVELOPMENT
✅ WORKS ON WINDOWS, MAC, LINUX
✅ PRODUCTION READY

SETUP (2 MINUTES):

1. Go to: https://console.upstash.com/

2. Sign up (GitHub/Google/Email)

3. Click "Create Database"
   - Name: redis-tat-dev
   - Type: Regional
   - Region: Choose closest to you
   - Click "Create"

4. Copy the Redis URL (looks like):
   rediss://default:AbC123...@us1-mighty-12345.upstash.io:6379

5. Add to Re_Backend/.env:
   REDIS_URL=rediss://default:AbC123...@us1-mighty-12345.upstash.io:6379
   TAT_TEST_MODE=true

6. Restart backend:
   cd Re_Backend
   npm run dev

7. ✅ Done! Look for: "[TAT Queue] Connected to Redis"

-----------------------------------------
OPTION 2: DOCKER (IF YOU PREFER LOCAL)
-----------------------------------------

If you have Docker Desktop:

1. Run Redis container:
   docker run -d --name redis-tat -p 6379:6379 redis:latest

2. Add to Re_Backend/.env:
   REDIS_URL=redis://localhost:6379
   TAT_TEST_MODE=true

3. Restart backend

-----------------------------------------
OPTION 3: PRODUCTION (LINUX SERVER)
-----------------------------------------

For Ubuntu/Debian servers:

1. Install Redis:
   sudo apt update
   sudo apt install redis-server -y

2. Enable and start:
   sudo systemctl enable redis-server
   sudo systemctl start redis-server

3. Verify:
   redis-cli ping
   # → PONG

4. Add to .env on server:
   REDIS_URL=redis://localhost:6379
   TAT_TEST_MODE=false

✅ FREE, NO LICENSE, PRODUCTION READY

-----------------------------------------
VERIFY CONNECTION
-----------------------------------------

After setup, check backend logs for:
   ✅ [TAT Queue] Connected to Redis
   ✅ [TAT Worker] Initialized and listening

Or test manually:

For Upstash:
   - Use Upstash Console → CLI tab
   - Type: PING → Should return PONG

For Local/Docker:
   Test-NetConnection localhost -Port 6379
   # Should show: TcpTestSucceeded : True

-----------------------------------------
RESTART BACKEND
-----------------------------------------

After Redis is running:
   cd Re_Backend
   npm run dev

You should see:
   ✅ [TAT Queue] Connected to Redis
   ✅ [TAT Worker] Initialized and listening

-----------------------------------------
TEST TAT NOTIFICATIONS
-----------------------------------------

1. Create a new workflow request
2. Set a short TAT (e.g., 2 hours for testing)
3. Submit the request
4. Check logs for:
   - "TAT jobs scheduled"
   - Notifications at 50%, 75%, 100%

For testing, you can modify working hours in:
   Re_Backend/src/utils/tatTimeUtils.ts

-----------------------------------------
CURRENT STATUS
-----------------------------------------

❌ Redis: NOT RUNNING
❌ TAT Notifications: DISABLED

After installing Redis:
✅ Redis: RUNNING
✅ TAT Notifications: ENABLED

========================================

