Skip to content

gc-MayankPun/AI-Caption-Generator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

23 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SnapScribe 🧠✨

Your AI-Powered Social Media Caption Assistant

SnapScribe is a powerful AI-based caption generator designed for content creators, influencers, brands, and marketers. Upload an image, take a photo directly from your device camera, or type a prompt β€” and let SnapScribe craft scroll-stopping, tone-appropriate captions tailored for Instagram, Twitter / X, Facebook, and LinkedIn.


βš™οΈ About This Project

SnapScribe is a personal project built to explore integrating Generative AI into real-world web applications. It combines file handling, camera capture, API rate-limiting, prompt engineering, image processing, and AI model invocation to deliver a practical, production-ready caption-generation tool.

The frontend is built with React and served directly from the Express backend β€” no separate static host needed.


πŸ”— Live Demo

🌐 Live App: gc-snapscribe
πŸ› οΈ Source Code: GitHub Repository


πŸš€ Features at a Glance

  • πŸ“· Smart Image Upload – Drag & drop, browse, or take a live photo. Max 5MB per image.
  • πŸ“Έ In-App Camera – Capture directly from your front or back camera with a live viewfinder. Preview, retake, or accept before use.
  • πŸ“ Text Prompt Input – Enter a topic, keyword, or scene description to guide the caption.
  • 🎭 Tone Selection – Choose from Fun, Romantic, Aesthetic, Sassy, Professional, Inspirational, Witty, Chill, Luxury, Dark Humor, and Nostalgic.
  • 🌐 Platform Awareness – Select your target platform (Instagram, Twitter / X, Facebook, LinkedIn) so the AI adapts the caption's style, length, and tone accordingly.
  • ✨ Single, High-Quality Captions – One unique, emotionally resonant caption per generation β€” no noise, no filler.
  • πŸ“‹ Ready-to-Copy Output – Each caption card shows its platform tag and tone, with a one-click copy button.
  • πŸ›‘οΈ Rate Limiting – Built-in protection against misuse.
  • πŸ”’ Secure & Fast – Helmet, CORS, and timeout handling included.

🧠 How It Works

  1. Upload or capture an image (optional) β€” drag & drop, browse files, or use the in-app camera.
  2. Select a tone that matches your post's vibe.
  3. Choose your platform β€” Instagram, Twitter / X, Facebook, or LinkedIn.
  4. Enter a text prompt (optional) β€” describe the scene, mood, or intent.
  5. The AI processes your inputs and returns a scroll-stopping caption within ~180 characters.
  6. Copy and post πŸš€

When both an image and a prompt are provided, the AI combines both into a single, context-aware caption β€” it does not treat them separately.


πŸ“Έ Camera Feature

  • Opens a full-screen camera modal with a live viewfinder.
  • Toggle between front camera (selfie) and back camera on supported devices.
  • Hit the shutter button to capture, then accept the photo to use it or retake if needed.
  • Captured photos are automatically resized and passed to the AI alongside your prompt.

🎯 Use Cases

  • πŸ“± Influencers curating their brand identity
  • πŸ“Έ Creators posting daily lifestyle content
  • 🧠 Marketers running campaigns across platforms
  • 🧍 Individuals breaking through creative block

πŸ§ͺ Example Inputs & Outputs

Input Type Prompt / Image Description Tone Platform Output Caption
Image Cozy coffee shop corner Aesthetic Instagram "Where lattes meet lazy afternoons β˜•πŸ“–"
Text Monday Motivation Inspirational LinkedIn "You were not born to be mediocre. Rise. πŸ’₯"
Both Selfie at beach, "golden hour" Romantic Facebook "You + me + sunsets = everything I need. πŸŒ…β€οΈ"
Camera Live photo at a rooftop Witty Twitter /X "Sky's the limit β€” until rent's due. πŸ˜… #RooftopLife"

🧩 Tech Stack

Backend

  • Node.js + Express β€” API server and static file host for the React frontend
  • Mistral AI (mistral-small-latest) via @langchain/mistralai β€” primary caption generation model
  • Google Gemini (gemini-2.5-flash-lite) via @langchain/google-genai β€” fallback / image-capable model
  • Multer β€” multipart file upload handling
  • Helmet & CORS β€” security middleware
  • Rate Limiting β€” request throttling
  • Timeout handling β€” reliability under load

Frontend

  • React + Vite β€” UI framework and build tool
  • TanStack Query β€” async state and mutation management
  • react-dropzone β€” drag-and-drop image uploads
  • MediaDevices API β€” in-browser camera access (front & back)
  • shadcn/ui β€” accessible select components
  • react-toastify β€” toast notifications
  • Outfit + Playfair Display β€” typography

πŸ—‚οΈ Project Structure

SnapScribe/
β”œβ”€β”€ client/                  # React frontend (built output served by Express)
β”‚   └── src/
β”‚       β”œβ”€β”€ api/
β”‚       β”‚   └── generatePrompt.js
β”‚       β”œβ”€β”€ components/
β”‚       β”‚   β”œβ”€β”€ App.jsx
β”‚       β”‚   β”œβ”€β”€ Logo.jsx
β”‚       β”‚   β”œβ”€β”€ CaptionUploader.jsx
β”‚       β”‚   β”œβ”€β”€ FileUploader.jsx
β”‚       β”‚   β”œβ”€β”€ CameraModal.jsx       # ← New: in-app camera
β”‚       β”‚   β”œβ”€β”€ PlatformSelector.jsx  # ← New: platform buttons
β”‚       β”‚   β”œβ”€β”€ Selector.jsx
β”‚       β”‚   β”œβ”€β”€ Input.jsx
β”‚       β”‚   └── CaptionLogs.jsx
β”‚       β”œβ”€β”€ hooks/
β”‚       β”‚   └── useGenerateCaption.js
β”‚       └── utils/
β”‚           └── ImageResolution.js
β”œβ”€β”€ server/
β”‚   β”œβ”€β”€ services/
β”‚   β”‚   └── ai.service.js     # Mistral + Gemini model logic
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ utils.js          # buildPrompt
β”‚   β”‚   └── constants.js
β”‚   └── server.js             # Serves API + built React frontend
β”œβ”€β”€ .env
β”œβ”€β”€ package.json
└── README.md

πŸ‘¨β€πŸ’» Setup Instructions

1. Clone the repository

git clone https://github.com/gc-MayankPun/AI-Caption-Generator.git
cd AI-Caption-Generator

2. Install dependencies

# Backend
npm install

# Frontend
cd client && npm install && cd ..

3. Configure environment variables

Create a .env file in the root:

MISTRAL_API_KEY=your_mistral_api_key
GEMINI_API_KEY=your_gemini_api_key
PORT=3000

4. Build the frontend

cd client && npm run build && cd ..

The Express server serves the built React app from client/dist β€” no separate deployment needed.

5. Start the server

npm start

Visit http://localhost:3000 β€” the app is live.


πŸ“Œ Coming Soon

  • πŸ’Ύ Caption History & Save Feature
  • πŸͺ„ Tone Suggestions via AI
  • 🎨 Auto-style formatting per platform
  • πŸ“ˆ Performance dashboard
  • πŸ” Bulk caption generator for creators

πŸ“„ License

MIT β€” see LICENSE for details.

About

πŸ“Έ SnapScribe β€” Instantly generate AI-powered Instagram captions from your images or text prompts. Built for creators, influencers, and marketers.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors