varuntree ReelMate .cursorrules file for TypeScript

AI Reel Generation Service: Instructions
General Guidelines
Add Comments: Always include comments for each section of the code to explain its purpose and functionality.
Follow Industry Standards: Write clean, maintainable, and modular code adhering to industry best practices.
Make Code Reusable: Ensure the code is modular and reusable to allow for future modifications and scalability.
Project Overview
The service provides automatic faceless reel generation using AI. Below is the detailed workflow:

Prompt Submission
Users submit a text prompt describing the topic or content for the reel.
Video Generation Process
Retrieve Stock Videos: Use stock video platforms like Unsplash or Pexels to get relevant video clips based on the user's prompt.
Generate Overlay Text: Use an AI model to create text that aligns with the video's theme and purpose.
Convert Text to Speech: Use a text-to-voice AI model (e.g., Amazon Polly) to generate background audio for the video.
Editing Features
After the reel is generated, users can customize it using a user-friendly interface:

Change the background video.
Modify the overlay text (content and positioning).
Adjust the placement of elements in the video overlay.
Goal
To create a seamless, AI-driven solution for generating and customizing engaging faceless reels for social media with minimal effort.

Code Organization
Use a Modular Structure
Organize the code by feature or functionality. Each module should have a specific responsibility.
Always write and use the mobile friendly code.

alwys follow the theme that is defined in the tailwind.config.ts file:
text: '#09090a',
background: '#f5f5f9',
primary: '#0000a7', // for buttons and links
secondary: '#1468cf', // for hover effects
accent: '#ffffff' // for cards

Folder Structure Example:

graphql
Copy code
src/
  ├── api/                   # API clients
  │   ├── googleApi.ts       # Google API integration
  │   ├── amazonPollyApi.ts  # Amazon Polly integration
  │   ├── pixabayApi.ts      # Pixabay integration
  │   └── awsStorage.ts      # AWS storage handling
  ├── services/              # Business logic
  │   ├── textGenerationService.ts
  │   ├── textToSpeechService.ts
  │   └── videoContentService.ts
  ├── utils/                 # Utility functions
  │   ├── httpClient.ts      # Axios or fetch wrapper
  │   ├── logger.ts          # Logging utility
  │   └── config.ts          # Environment variables and configuration
  ├── middleware/            # Middlewares for requests and responses
  ├── routes/                # API routes for Next.js or your chosen framework
  │   ├── generateReel.ts
  │   └── uploadReel.ts
  ├── components/            # Frontend components (if using React/Next.js)
  ├── pages/                 # Next.js pages
  └── app.ts                 # Application entry point
Implementation Details
1. Abstract API Calls
Create reusable modules for each API integration. Use environment variables for keys and configuration.

Example for googleApi.ts:

typescript
Copy code
import axios from '../utils/httpClient';

const API_KEY = process.env.GOOGLE_API_KEY;

// Function to generate text using Google API
export const generateText = async (prompt: string) => {
  try {
    const response = await axios.post(
      'https://api.google.com/text-generation',
      { prompt },
      { headers: { Authorization: `Bearer ${API_KEY}` } }
    );
    return response.data;
  } catch (error) {
    throw new Error(`Google API Error: ${error.message}`);
  }
};
2. Centralize Configuration
Store all API keys and configurations in a central file or .env to keep the code clean and secure.

Example: config.ts:

typescript
Copy code
export const config = {
  googleApiKey: process.env.GOOGLE_API_KEY,
  amazonPollyKey: process.env.AMAZON_POLLY_KEY,
  pixabayApiKey: process.env.PIXABAY_API_KEY,
  aws: {
    region: process.env.AWS_REGION,
    bucket: process.env.AWS_BUCKET,
  },
};
3. Service Layer for Business Logic
Handle core application logic in a dedicated service layer.

Example for textToSpeechService.ts:

typescript
Copy code
import { synthesizeSpeech } from '../api/amazonPollyApi';
import { storeFile } from '../api/awsStorage';

// Function to generate speech audio and store it in AWS
export const generateAndStoreSpeech = async (text: string) => {
  const speech = await synthesizeSpeech(text);
  const storedFileUrl = await storeFile(speech.audio, 'speech.mp3');
  return storedFileUrl;
};
4. Utility Functions
Create shared utilities for common tasks like HTTP requests, logging, or configuration.

Example: httpClient.ts:

typescript
Copy code
import axios from 'axios';

const httpClient = axios.create({
  timeout: 5000, // Set timeout for API requests
});

httpClient.interceptors.response.use(
  (response) => response,
  (error) => {
    console.error('API Error:', error.response?.data || error.message);
    return Promise.reject(error);
  }
);

export default httpClient;
Key Principles
Always write reusable, modular, and testable code.
Follow a structured folder hierarchy to keep the project organized.
Abstract API interactions and keep sensitive data secure with environment variables.
Ensure comments explain each code section for future maintainability.
aws
css
golang
graphql
javascript
less
next.js
react
+2 more

First Time Repository

TypeScript

Languages:

CSS: 0.7KB
JavaScript: 0.5KB
TypeScript: 190.4KB
Created: 1/3/2025
Updated: 1/16/2025

All Repositories (1)