services:
  backend:
    build: ./backend
    ports:
      - "8000:8000"  # Map host 8000 to container 8000 for local access
    environment:
      - DATABASE_URL=sqlite+aiosqlite:///./data/h2h.db
      - JWT_SECRET=${JWT_SECRET:-your-secret-key-change-in-production-min-32-characters}
      - JWT_ALGORITHM=HS256
      - ACCESS_TOKEN_EXPIRE_MINUTES=30
      - REFRESH_TOKEN_EXPIRE_DAYS=7
    volumes:
      - ./backend:/app  # Hot-reload: sync local changes
      - sqlite_data:/app/data
    command: uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload

  frontend:
    build: ./frontend
    ports:
      - "5173:5173"  # Map host 5173 to container 5173 for local access
    environment:
      - VITE_API_URL=http://localhost:8000
      - VITE_WS_URL=ws://localhost:8000
    volumes:
      - ./frontend:/app  # Hot-reload: sync local changes
      - /app/node_modules
    command: npm run dev -- --host --port 5173
    depends_on:
      - backend

volumes:
  sqlite_data:
