Skip to content

Conversation

@afrinxnahar
Copy link
Collaborator

Overview

This pull request consolidates a series of commits that strengthen the ScriptAI application's backend architecture, introduce scalable asynchronous processing for AI training tasks, and add a secure, user-friendly OTP-based password reset flow. The changes follow a minimal, clean approach with strict type safety via Zod schemas and TypeScript. We've prioritized DRY principles by centralizing Supabase client creation in shared packages, used NestJS guards for authentication, and leveraged BullMQ for reliable job queuing to handle high-volume AI workloads without blocking the main API.

Changes

OTP-Based Password Reset (full flow)

– Backend: /auth/forgot-password, /verify-otp, /reset-password with 6-digit OTP (10-min expiry, 5-attempt limit)
– Secure updates via Supabase service-role client
– Emails powered by Resend + Zod-validated DTOs
– Frontend: Modern react-hook-form + Zod resolver, animated errors, sonner toasts, auto-redirect

Async AI Training Queue

– BullMQ + Redis (password-protected) for long-running train-ai jobs
– Dedicated NestJS controller & processor with retries, backoff, and rate-limiting (100/min)
– Frontend now calls secure backend endpoint (POST /api/v1/train-ai) with JWT

Security & Consistency

– Centralised Supabase server client (@repo/supabase)
– JWT auth via SupabaseAuthGuard on all protected routes
– Added /test-db health check
– Removed unused code (~537 lines)

Database & Infra

– New tables: user_voices, dubbing_jobs with RLS + indexes
– Redis password + Docker Compose updates
– Added worker script (npm run start:worker)

Testing

  • Backend: Run npm run start:dev (API) and npm run start:worker; test /test-db, /train-ai with valid JWT; verify OTP flow with mock Resend.
  • Frontend: npm run dev; submit forgot-password form; check redirects, toasts, and animations.
  • E2E: Queue a training job; confirm worker processes it; reset password via email simulation.
  • Edge Cases: Invalid OTP (expires/attempts), missing Redis password (fails gracefully), high-load queue (rate limits apply).

Screenshots (Password Reset UX)

Before: Basic form with manual error handling.

After: Animated, validated form with success toast and auto-redirect.

image image

Email temp:
image

Next Steps

  • Test Train AI route with backend
  • Integrate dubbing jobs into the queue.
  • Add queue monitoring (e.g., Prometheus metrics).
  • E2E tests for full auth flow.

@vercel
Copy link
Contributor

vercel bot commented Nov 21, 2025

@afrinxnahar is attempting to deploy a commit to the afrin127329's projects Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant