t2m / WORKING_SETUP.md
thanhkt's picture
implement core api
50a7bf0

βœ… Working FastAPI + Docker + ngrok Setup

🎯 Current Status: WORKING!

Your development environment is successfully set up with:

  • βœ… Redis running in Docker
  • βœ… ngrok exposing your local server publicly
  • βœ… FastAPI server running locally
  • βœ… Public HTTPS URL: https://d4e9601ecb72.ngrok-free.app

πŸš€ Quick Start Commands

1. Start Services (Redis + ngrok)

./start-services.sh

2. Start FastAPI Server

# Simple working version
python simple_app.py

# Or the full version (once config is fixed)
python -m uvicorn src.app.main:app --reload --host 0.0.0.0 --port 8000

3. Get Your Public URL

curl -s http://localhost:4040/api/tunnels | jq -r '.tunnels[0].public_url'

🌐 Your URLs

πŸ”§ Configure Clerk Webhook

Now you can set up your Clerk webhook:

  1. Go to Clerk Dashboard
  2. Navigate to Webhooks β†’ Add Endpoint
  3. Enter your webhook URL:
    https://d4e9601ecb72.ngrok-free.app/api/v1/auth/webhooks/clerk
    
  4. Select events: user.created, user.updated, user.deleted, session.created, session.ended
  5. Copy the Signing Secret and add to your .env:
    CLERK_WEBHOOK_SECRET=whsec_your_webhook_signing_secret_here
    

πŸ“ Available Endpoints (Simple App)

  • GET / - Welcome message
  • GET /health - Health check
  • GET /config - Configuration info

Test them:

curl https://d4e9601ecb72.ngrok-free.app/
curl https://d4e9601ecb72.ngrok-free.app/health
curl https://d4e9601ecb72.ngrok-free.app/config

πŸ› οΈ Service Management

Check Services

# Check Redis
redis-cli ping

# Check ngrok tunnels
curl -s http://localhost:4040/api/tunnels

# Check Docker containers
docker ps

Stop Services

# Stop all related containers
docker stop $(docker ps -q --filter 'ancestor=redis:7-alpine' --filter 'ancestor=ngrok/ngrok:latest')

Restart Services

./start-services.sh

πŸ” Troubleshooting

If ngrok URL changes:

The ngrok URL will change each time you restart ngrok (unless you have a paid plan). Get the new URL with:

curl -s http://localhost:4040/api/tunnels | jq -r '.tunnels[0].public_url'

If Redis connection fails:

# Check if Redis is running
docker ps | grep redis

# Restart Redis if needed
docker restart $(docker ps -q --filter 'ancestor=redis:7-alpine')

If FastAPI config fails:

Use the simple app for now:

python simple_app.py

πŸŽ‰ Next Steps

  1. Test your webhook: Use the public URL to set up Clerk webhooks
  2. Fix the main FastAPI app: The config parsing issue needs to be resolved
  3. Add authentication: Implement Clerk authentication middleware
  4. Add your business logic: Build your video generation endpoints

πŸ“‹ Working Files

  • start-services.sh - Starts Redis and ngrok
  • simple_app.py - Working FastAPI application
  • simple_config.py - Working configuration
  • .env - Environment variables (configured)

Your development environment is ready for webhook testing! πŸš€