|
1 | | -# With-NestJs | API |
| 1 | +# Creator AI — API |
2 | 2 |
|
3 | | -## Getting Started |
| 3 | +NestJS backend for Creator AI. Handles scripts, ideation, subtitles, dubbing, story builder, AI training, billing, and auth. |
4 | 4 |
|
5 | | -First, run the development server: |
| 5 | +## Endpoints |
6 | 6 |
|
7 | | -```bash |
8 | | -pnpm run dev |
9 | | -``` |
| 7 | +All endpoints (except health and Stripe webhook) are prefixed with `/api/v1` and require a Supabase JWT in the `Authorization: Bearer <token>` header, validated by `SupabaseAuthGuard`. |
| 8 | + |
| 9 | +### Auth (`/api/v1/auth`) |
| 10 | + |
| 11 | +| Method | Path | Description | |
| 12 | +|--------|------|-------------| |
| 13 | +| POST | `/forgot-password` | Send OTP to email | |
| 14 | +| POST | `/verify-otp` | Verify 6-digit OTP | |
| 15 | +| POST | `/reset-password` | Reset password with verified OTP | |
| 16 | + |
| 17 | +### Scripts (`/api/v1/script`) |
| 18 | + |
| 19 | +| Method | Path | Description | |
| 20 | +|--------|------|-------------| |
| 21 | +| POST | `/generate` | Queue script generation job (BullMQ), supports file uploads | |
| 22 | +| GET | `/` | List user's scripts | |
| 23 | +| GET | `/:id` | Get single script | |
| 24 | +| GET | `/:id/export` | Export script as PDF | |
| 25 | +| PATCH | `/:id` | Update script title & content | |
| 26 | +| DELETE | `/:id` | Delete script | |
| 27 | +| SSE | `/status/:jobId` | Real-time generation progress stream | |
| 28 | + |
| 29 | +### Ideation (`/api/v1/ideation`) |
| 30 | + |
| 31 | +| Method | Path | Description | |
| 32 | +|--------|------|-------------| |
| 33 | +| POST | `/` | Queue ideation job (BullMQ) | |
| 34 | +| GET | `/` | List ideation jobs (paginated) | |
| 35 | +| GET | `/profile-status` | Check user AI training status | |
| 36 | +| GET | `/:id` | Get single ideation job | |
| 37 | +| GET | `/:id/export/pdf` | Export ideation as PDF | |
| 38 | +| GET | `/:id/export/json` | Export ideation as JSON | |
| 39 | +| DELETE | `/:id` | Delete ideation job | |
| 40 | +| SSE | `/status/:jobId` | Real-time ideation progress stream | |
| 41 | + |
| 42 | +### Story Builder (`/api/v1/story-builder`) |
| 43 | + |
| 44 | +| Method | Path | Description | |
| 45 | +|--------|------|-------------| |
| 46 | +| POST | `/generate` | Queue story builder job (BullMQ) | |
| 47 | +| GET | `/` | List story builder jobs | |
| 48 | +| GET | `/profile-status` | Check user AI training status | |
| 49 | +| GET | `/:id` | Get single story builder job | |
| 50 | +| DELETE | `/:id` | Delete story builder job | |
| 51 | +| SSE | `/status/:jobId` | Real-time generation progress stream | |
| 52 | + |
| 53 | +### Subtitles (`/api/v1/subtitle`) |
| 54 | + |
| 55 | +| Method | Path | Description | |
| 56 | +|--------|------|-------------| |
| 57 | +| POST | `/` | Generate subtitles with Gemini AI | |
| 58 | +| GET | `/` | List user's subtitle jobs | |
| 59 | +| POST | `/upload` | Upload video (max 200 MB) | |
| 60 | +| PATCH | `/` | Update subtitle JSON | |
| 61 | +| GET | `/:id` | Get single subtitle job | |
| 62 | +| PATCH | `/:id` | Update subtitle by ID | |
| 63 | +| DELETE | `/:id` | Delete subtitle job and file | |
| 64 | +| POST | `/burn` | Burn subtitles into video (FFmpeg) | |
| 65 | + |
| 66 | +### Dubbing (`/api/v1/dubbing`) |
10 | 67 |
|
11 | | -By default, your server will run at [http://localhost:3000](http://localhost:3000). You can use your favorite API platform like [Insomnia](https://insomnia.rest/) or [Postman](https://www.postman.com/) to test your APIs |
| 68 | +| Method | Path | Description | |
| 69 | +|--------|------|-------------| |
| 70 | +| POST | `/` | Create dubbing project (Murf.ai) | |
| 71 | +| GET | `/` | List dubbing projects (paginated) | |
| 72 | +| GET | `/status/:projectId` | SSE stream for dubbing progress | |
| 73 | +| GET | `/:id` | Get dubbing project | |
| 74 | +| DELETE | `/:id` | Delete dubbing project | |
12 | 75 |
|
13 | | -You can start editing the demo **APIs** by modifying [linksService](./src/links/links.service.ts) provider. |
| 76 | +### AI Training (`/api/v1/train-ai`) |
14 | 77 |
|
15 | | -### ⚠️ Note about build |
| 78 | +| Method | Path | Description | |
| 79 | +|--------|------|-------------| |
| 80 | +| POST | `/` | Queue training job (BullMQ) | |
| 81 | +| GET | `/status/:jobId` | SSE stream for training progress | |
16 | 82 |
|
17 | | -If you plan to only build this app. Please make sure you've built the packages first. |
| 83 | +### Billing (`/api/v1/billing`) |
18 | 84 |
|
19 | | -## Learn More |
| 85 | +| Method | Path | Description | |
| 86 | +|--------|------|-------------| |
| 87 | +| GET | `/plans` | List available subscription plans | |
| 88 | +| GET | `/info` | Get user's billing info | |
| 89 | +| POST | `/checkout` | Create Stripe Checkout session | |
| 90 | +| POST | `/portal` | Create Stripe Customer Portal session | |
20 | 91 |
|
21 | | -To learn more about NestJs, take a look at the following resources: |
| 92 | +### Stripe Webhook (`/api/v1/stripe`) |
| 93 | + |
| 94 | +| Method | Path | Description | |
| 95 | +|--------|------|-------------| |
| 96 | +| POST | `/webhook` | Handle Stripe webhook events | |
| 97 | + |
| 98 | +Handled events: `checkout.session.completed`, `customer.subscription.updated`, `customer.subscription.deleted`, `invoice.paid` |
| 99 | + |
| 100 | +### Health |
| 101 | + |
| 102 | +| Method | Path | Description | |
| 103 | +|--------|------|-------------| |
| 104 | +| GET | `/` | Health check | |
| 105 | +| GET | `/api/v1/test-db` | Database connection test | |
| 106 | + |
| 107 | +## Job Queues (BullMQ) |
| 108 | + |
| 109 | +| Queue | Purpose | |
| 110 | +|-------|---------| |
| 111 | +| `train-ai` | AI style training from YouTube videos | |
| 112 | +| `script` | Script generation with style personalization | |
| 113 | +| `ideation` | Idea research with web search | |
| 114 | +| `story-builder` | Narrative structure generation | |
| 115 | + |
| 116 | +All queues stream progress to the client via SSE. |
| 117 | + |
| 118 | +## Key Integrations |
| 119 | + |
| 120 | +| Service | Purpose | |
| 121 | +|---------|---------| |
| 122 | +| Supabase | Database, auth, storage | |
| 123 | +| Google Gemini AI | Script generation, ideation, training, transcription | |
| 124 | +| Murf.ai | Audio/video dubbing | |
| 125 | +| Stripe | Subscriptions, checkout, billing portal | |
| 126 | +| BullMQ + Redis | Job queue for async AI operations | |
| 127 | +| FFmpeg | Video processing & subtitle burning | |
| 128 | +| Resend | OTP and transactional emails | |
| 129 | + |
| 130 | +## Setup |
| 131 | + |
| 132 | +```bash |
| 133 | +cp .env.example .env # Fill in credentials |
| 134 | +pnpm install |
| 135 | +pnpm run dev --filter=api |
| 136 | +``` |
22 | 137 |
|
23 | | -- [Official Documentation](https://docs.nestjs.com) - A progressive Node.js framework for building efficient, reliable and scalable server-side applications. |
24 | | -- [Official NestJS Courses](https://courses.nestjs.com) - Learn everything you need to master NestJS and tackle modern backend applications at any scale. |
25 | | -- [GitHub Repo](https://github.com/nestjs/nest) |
| 138 | +Runs at [http://localhost:8000](http://localhost:8000). |
0 commit comments