Skip to content

Ankur3509/TopNotesAI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

TopNotesAI - Production Ready

Convert YouTube educational lectures into HUMAN-STYLE student notes.

🎯 Production Optimizations

Free-Tier Optimized

  • βœ… Downloads only first 10 minutes of content
  • βœ… Extracts maximum 8 frames using scene detection
  • βœ… Sequential AI calls (no parallel requests)
  • βœ… Automatic retries with exponential backoff
  • βœ… Rate limiting (max 3 concurrent jobs)
  • βœ… Auto-cleanup of old jobs (1 hour expiry)

Reliability Features

  • βœ… Background job processing (no timeouts)
  • βœ… Real-time progress tracking
  • βœ… Graceful degradation (continues without diagrams/frames if they fail)
  • βœ… Comprehensive error handling with user-friendly messages
  • βœ… Fallback notes structure if AI fails
  • βœ… Automatic resource cleanup

πŸ“‹ Prerequisites

  1. Node.js (v18 or higher) - Download
  2. Groq API Key (FREE) - Get one here

Note: FFmpeg and yt-dlp are included automatically via npm packages!

πŸš€ Setup Instructions

1. Install Dependencies

npm install

2. Configure Environment

Create a .env file in the root directory:

PORT=5000
GROQ_API_KEY=your_groq_api_key_here

3. Run the Application

npm start

Open your browser to: http://localhost:5000

πŸ—οΈ Architecture

Backend Flow

User submits URL
    ↓
Job created (returns immediately)
    ↓
Background Processing:
  1. Download first 10min audio + video (360p)
  2. Transcribe audio (Whisper-v3)
  3. Analyze up to 3 frames (Vision AI)
  4. Generate notes (Llama-3.3-70b)
  5. Create diagrams (Mermaid β†’ SVG)
  6. Render PDF (Puppeteer)
    ↓
User downloads PDF
    ↓
Auto-cleanup after 10s

API Endpoints

  • POST /api/generate-notes - Start job (returns jobId)
  • GET /api/status/:jobId - Check progress
  • GET /api/download/:jobId - Download PDF
  • GET /health - Server health check

πŸ›‘οΈ Error Handling

Graceful Failures

  • No audio detected β†’ Returns transcript-only notes
  • Frame extraction fails β†’ Continues with audio analysis
  • Diagram generation fails β†’ Skips diagrams, continues PDF
  • AI timeout β†’ Automatic retry (3 attempts)
  • PDF generation fails β†’ Clear error message to user

Rate Limiting

  • Maximum 3 concurrent jobs
  • Jobs expire after 1 hour
  • Auto-cleanup every 15 minutes

πŸ“Š Free-Tier Limits

Groq API (FREE Tier)

  • Whisper: 30 requests/min
  • Vision: 30 requests/min
  • LLM: 30 requests/min

Our Optimizations

  • Sequential processing (never parallel)
  • 1 second delay between frame analyses
  • Exponential backoff on retries
  • Maximum 3 frames analyzed per video
  • Maximum 3 diagrams generated

πŸ› Troubleshooting

"Connection error" or "ECONNRESET"

  • Cause: Temporary network issue with Groq API
  • Solution: The app automatically retries 3 times. If it persists, wait 1 minute and try again.

"Server is busy"

  • Cause: 3+ jobs already running (free-tier protection)
  • Solution: Wait 1-2 minutes for current jobs to complete.

"Job not found"

  • Cause: Job expired (>1 hour old)
  • Solution: Submit a new request.

PDF not downloading

  • Cause: Browser popup blocker
  • Solution: Allow popups for localhost:5000

πŸ“ Project Structure

topnotesai/
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ index.html          # UI
β”‚   β”œβ”€β”€ app.js              # Job submission & polling
β”‚   └── assets/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ server.js           # Express server
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   └── notes.js        # Job orchestration
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   β”œβ”€β”€ videoProcessor.js   # yt-dlp + FFmpeg
β”‚   β”‚   β”œβ”€β”€ aiAnalyzer.js       # Groq API (sequential)
β”‚   β”‚   β”œβ”€β”€ diagramGenerator.js # Mermaid CLI
β”‚   β”‚   └── pdfGenerator.js     # Puppeteer
β”‚   β”œβ”€β”€ templates/
β”‚   β”‚   └── notes-template.html # PDF layout
β”‚   └── temp/               # Auto-cleaned
β”œβ”€β”€ package.json
β”œβ”€β”€ .env
└── README.md

🎨 Features

Human-Style Notes

  • Active recall headings (question format)
  • Marginalia with "Aha!" moments
  • Emphasis markers (underline, circle, bold)
  • Cheat sheet with key formulas
  • Golden rule summary

Technical Excellence

  • SVG diagrams (crisp at any zoom level)
  • 2-column PDF layout
  • Google Fonts (Inter + Caveat)
  • Glassmorphism UI
  • Real-time progress updates

πŸ“ Development

Run in Development Mode

npm run dev

Environment Variables

PORT=5000                    # Server port
GROQ_API_KEY=gsk_xxx        # Your Groq API key
NODE_ENV=production         # Optional

🚒 Deployment

Free-Tier Hosting Options

  • Backend: Render, Railway, Fly.io
  • Frontend: Vercel, Netlify

Important Notes

  1. Set environment variables on your hosting platform
  2. Ensure NODE_ENV=production
  3. Free-tier servers may sleep after inactivity (first request slower)

πŸ“„ License

MIT License - Feel free to use and modify!

πŸ™ Credits

  • Groq for free-tier AI APIs
  • yt-dlp for YouTube downloading
  • FFmpeg for video processing
  • Mermaid.js for diagram generation
  • Puppeteer for PDF rendering

Made with ❀️ for students who want better notes

About

No description, website, or topics provided.

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors