How andreaswt/ai-video-sentiment-saas works
Project type and purpose
• This is a full-stack SaaS application (“ai-video-sentiment-saas”) built with the T3 Stack (Next.js, React, Tailwind, Auth.js, Prisma).
• It provides video sentiment and emotion inference via AWS SageMaker endpoints, persists user data and API-key/quota information in a relational database (Prisma), and stores uploaded videos in AWS S3.
File structure
• Top-level config files: next.config.js, Prisma schema (prisma/schema.prisma), Tailwind and PostCSS configs, Auth.js (src/env.js), TypeScript config.
• Frontend/UI: src/app (Next.js pages, layouts, login/signup), src/components (client-side React components).
• API layer: src/app/api – serverless routes for auth ([...nextauth]/route.ts), presigned upload URLs (upload-url/route.ts), sentiment-inference (sentiment-inference/route.ts).
• Business logic modules: src/actions (high-level operations like auth.ts), src/lib (quota enforcement, helper functions), src/schemas (data validation).
• Server utilities: src/server/auth (Auth.js configuration), src/server/db.ts (Prisma client).
• Static assets: public/, styles/, thumbnail.png.
README for additional insights
• The system stages are:
a. User authentication & session management (Auth.js + NextAuth).
b. Video upload: frontend obtains a presigned URL, uploads to S3.
c. Inference invocation: API route calls SageMaker endpoint, returns sentiment/emotion results.
d. Quota tracking: each inference decrements the user’s monthly quota in the database.
e. Data persistence: user profiles, API keys, usage logs stored via Prisma/DB.
Main components and their interactions
a. Frontend (Next.js + React + Tailwind)
• Login/Signup pages
• Video uploader and Inference UI components
• Calls API endpoints under /api
b. Authentication layer
• NextAuth routes ([...nextauth])
• Auth.js config in src/server/auth/config.ts
• Session state passed to frontend components
c. API Layer (Next.js Serverless Functions)
• /api/upload-url → generates S3 presigned PUT URLs (uses AWS SDK)
• /api/sentiment-inference → invokes AWS SageMaker endpoint, returns results
• /api/auth/[...nextauth] → standard NextAuth endpoint
d. Business Logic & Services
• src/actions/auth.ts → high-level sign-in/out logic
• src/lib/quota.ts → tracks and enforces user quotas per month
• src/schemas/auth.ts → request/response validation
e. Data Storage
• Relational Database (e.g. PostgreSQL) accessed via Prisma (prisma/schema.prisma & src/server/db.ts)
• AWS S3 bucket for video storage
f. External AI Inference Service
• AWS SageMaker Endpoint for multimodal model inference
Architectural patterns and design principles
• Layered serverless architecture:
• Presentation layer (Next.js pages/components)
• API layer (Next.js serverless functions under /api)
• Service/business layer (actions, lib, schemas)
• Data layer (Prisma ORM + PostgreSQL, S3)
• Separation of concerns: UI vs. data vs. AI inference vs. auth vs. quota enforcement
• Scalability via AWS services (serverless functions, S3, SageMaker)
Elements
• Notes around quota enforcement (src/lib/quota.ts) and API key management