FastAPI application entry point. CORS, static file serving, middleware, startup events, route registration. Serves frontend + API from same server.
PythonFastAPICore
🔐Authentication
backend/auth/auth.py
JWT access tokens (15min) + refresh tokens (7 days). bcrypt password hashing. OAuth2 flow. Plan-based route guards (free/standard/advanced).
PythonJWTSecurity
👤Auth Routes
backend/routers/auth_routes.py
Register, login, logout, refresh token, email verification, password reset. Token revocation via DB. Brute force protection.
PythonREST
📁File Security
backend/services/file_security.py
MIME type verification, malicious file detection, private storage outside web root, signed URLs with expiry, auto-delete after 1hr (free) / 24hr (standard) / 30 days (advanced).
PythonSecurity
⚡Rate Limiter
backend/middleware/rate_limit.py
Redis-based rate limiting per user + per IP. Per-minute and per-day limits. Plan-aware (free: 20 req/min, standard: 60, advanced: 200). Action-specific limits for images/videos.
PythonRedis
🎯Generation Routes
backend/routers/generation.py
Submit jobs, poll status, cancel, get history. WebSocket for real-time updates. Credit deduction. RunPod serverless dispatch. Queue position + ETA.
PythonWebSocket
🔄Job Manager
backend/services/job_manager.py
Redis priority queue. Job creation, status tracking, queue positions, ETA calculation. Background worker loop. User notifications. Auto-cleanup expired jobs.
PythonRedis
🖥RunPod Worker
runpod_worker/handler.py
GPU serverless handler. Image generation (FLUX), Text→Video (CogVideoX), Image→Video (SVD), Anime (AnimateDiff), Transcription (Whisper). Model lazy loading + caching.
PythonRunPodGPU
🌐RunPod Service
backend/services/runpod_service.py
Submit jobs to RunPod serverless API, poll for results, handle timeouts, cancel jobs. HMAC signature validation for security.
PythonHTTP
🛡Colab Watchdog
backend/services/colab_watchdog.py
Monitors Google Colab worker health every 30 seconds. Marks offline if unreachable. Auto-failover to free API providers. Redis status updates.
PythonMonitor
🗄Database Models
backend/models/
PostgreSQL via SQLAlchemy. Tables: users, files, jobs, refresh_tokens, ai_logs, subscriptions, credits. All with created_at, updated_at, soft delete.
PostgreSQLSQLAlchemy
🔒Privacy Routes
backend/routers/privacy.py
GDPR Article 17 — delete all user data. GDPR Article 20 — export all user data as JSON. Wipes files from disk + all DB records.
PythonGDPR
⚙Config & Env
backend/config.py + .env
All secrets in .env (JWT, refresh, file, worker secrets). API keys for Groq, Cloudflare, Kling, RunPod. Database URLs. Never committed to git.
ConfigSecurity
🐳Dockerfile
runpod_worker/Dockerfile
RunPod GPU worker container. PyTorch 2.1 + CUDA 11.8 base. FFmpeg, all AI model dependencies. Builds to DockerHub for RunPod serverless deployment.
DockerGPU
🌍Nginx Config
/etc/nginx/sites-available/aisuitex
Serves frontend files, proxies /api/ to FastAPI, serves /outputs/ and /uploads/ directories. 100MB upload limit, 300s timeout for AI generation.
NginxServer
🔧Systemd Service
/etc/systemd/system/aisuitex.service
Auto-starts FastAPI on VPS boot. Gunicorn with 2 Uvicorn workers. 300s timeout. Restarts automatically on crash. Runs as www-data user.
LinuxSystemD