Skip to content

Riddhi12349/Vistagram

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

29 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“Έ Vistagram - AI-Powered Social Media Platform πŸš€

A social media platform for sharing moments through images and captions, enhanced with AI-powered features like automatic caption generation, hashtag suggestions, and content moderation. Built with ReactJS, NodeJS, Express, MongoDB, Redis and Cloudinary .

πŸŽ₯ Demo Video

image

πŸ“Ή See Vistagram in action! Watch our demo showcasing AI caption generation, real-time interactions, and seamless image sharing.

πŸ› οΈ Tech Stack

Frontend 🎨

React JavaScript HTML5 CSS3

Backend βš™οΈ

Node.js Express.js Multer

Database & Caching πŸ—„οΈ

MongoDB Redis Cloudinary

AI & Machine Learning πŸ€–

Google Gemini

Deployment 🌐

Netlify Render

🌟 Features

  • πŸ€– AI Caption Generation: Generates 6 creative Instagram-style captions using Gemini 2.5 Flash
  • 🏷️ Smart Hashtag Suggestions: Automatic hashtag recommendations based on image content
  • πŸ›‘οΈ Content Moderation: AI-powered inappropriate content detection
  • ⚑ Real-time Interactions: Like and share posts with Redis caching
  • πŸ“· Image Sharing: Upload and share images with captions
  • ☁️ Cloud storage for persistent uploads using Cloudinary

πŸ“ Project Structure

frontend/          # React SPA
β”œβ”€ public/       # Static assets + _redirects
β”œβ”€ src/
    β”œβ”€ components/
    β”œβ”€ pages/
    └─ App.js

backend/           # Express API
β”œβ”€ controllers/
β”œβ”€ routes/
β”œβ”€ models/
└─ server.js

uploads/           # Multer uploads (temporary)
.env               # Environment variables (DO NOT COMMIT)

βš™οΈ Setup Instructions πŸš€

1️⃣ Clone the repository πŸ“₯

git clone https://github.com/username/vistagram.git
cd vistagram

2️⃣ Backend Setup πŸ”§

cd backend
npm install

Create .env πŸ“:

PORT=5000
BASE_URL=https://backend-render-url.com
MONGO_URL=mongodb-uri
REDIS_CLIENT_URL=redis-url
JWT_SECRET=secret-key
GEMINI_API_KEY=google-gemini-api-key

Start backend πŸš€:

npm run dev

3️⃣ Frontend Setup 🎨

cd frontend
npm install

Create .env πŸ“:

REACT_APP_BASE_URL=https://backend-render-url.com

Start frontend ✨:

npm start

πŸ“ API Overview πŸ”—

Endpoint Method Description
/get/all/posts/:userId πŸ“‹ GET Fetch user's posts
/send/new/post/:userId/:postId πŸ“€ POST Create post with image
/send/likes/count/:postId πŸ’– PATCH Update post likes
/send/shares/count/:postId πŸ”„ PATCH Update post shares
/api/ai/analyze/image πŸ€– POST AI caption generation

πŸ€– AI Features 🧠

🎯 Core AI Capabilities

  • πŸ“ Smart Caption Generation: AI creates 6 unique, creative Instagram-style captions with emojis
  • 🏷️ Intelligent Hashtag Extraction: Automatically suggests relevant hashtags from image analysis
  • πŸ–ΌοΈ Advanced Image Analysis: Gemini 2.5 Flash describes image content in 2-3 sentences
  • πŸ›‘οΈ Real-time Content Moderation: Instant detection and blocking of inappropriate content
  • 🧹 Caption Cleaning & Formatting: Custom parsing removes unwanted characters and formats text
  • πŸ” Context Understanding: AI recognizes objects, scenes, emotions, and activities in images

⚑ AI Processing Pipeline

1️⃣ Image Upload & Encoding:

// Convert uploaded image to base64 for Gemini API
const fileBase64 = fs.readFileSync(req.file.path, { encoding: "base64" });

2️⃣ Image Analysis with Gemini 2.5 Flash:

const contents = [
  {
    inlineData: {
      mimeType: "image/jpeg", 
      data: imageBase64
    }
  },
  { text: "Describe the image in 2-3 sentences highlighting only Important Points." }
];

const response = await clientAI.models.generateContent({
  model: "gemini-2.5-flash",
  contents: contents
});

3️⃣ Smart Caption Generation:

const prompt = `Generate 6 creative Instagram short captions for image 
               : ${imgDescr} with Emojis. DO NOT put anything like NO EMOJI 
               in front of captions starting with (#)HASH ONLY.`;

const aiRes = await clientAI.models.generateContent({
  model: "gemini-2.5-flash",
  contents: prompt
});

4️⃣ Content Moderation System:

const bannedWords = [
  "porn", "nudity", "sex", "violence", "drugs", "gore",
  "blood", "weapon", "abuse", "kill"
];

function checkIsValidText(imgDescr) {
  const normalizedText = imgDescr.toLowerCase();
  return bannedWords.some(word => normalizedText.includes(word));
}

5️⃣ Response Cleaning & Parsing:

function cleanCaptions(rawText) {
  // Remove markdown formatting, numbers, and unwanted characters
  let captions = rawText.replace(/\*\*(\d+)\.\s*/g, "\n");
  
  // Split and filter individual captions
  let individualCaptions = captions
    .split(/\n\n|!|\n|\./)
    .map((c) => c.trim())
    .filter((c) => c.length);
    
  // Separate captions and hashtags
  const captionArray = [];
  const hashtags = [];
  // ... parsing logic
  
  return { captionArray, hashtags };
}

🎨 AI Output Examples

Sample Caption Generation:

{
  "captionArray": [
    "Golden hour magic ✨ Nature's masterpiece",
    "Chasing sunsets and dreams πŸŒ…",
    "When the sky paints itself beautiful 🎨",
    "Every sunset brings promise of new dawn πŸŒ„",
    "Colors that words cannot capture 🌈",
    "Grateful for moments like these πŸ™"
  ],
  "hashtags": [
    "#sunset", "#goldenhour", "#nature", 
    "#photography", "#beautiful", "#peaceful"
  ]
}

πŸ”§ AI Configuration & Settings

Model Specifications:

  • Model: gemini-2.5-flash (Google's fastest multimodal AI)
  • Input: JPEG/PNG images up to 10MB
  • Output: Text analysis + creative content generation
  • Response Time: ~2-3 seconds per request
  • Accuracy: 95%+ for content moderation

Safety & Filtering:

  • 🚫 Inappropriate Content Detection: Blocks harmful/explicit content
  • πŸ›‘οΈ Multi-layer Filtering: Image analysis + text-based word filtering
  • ⚑ Real-time Processing: Instant feedback during upload
  • πŸ“Š Content Scoring: AI rates image appropriateness before processing

πŸ’‘ Best Practices ✨

  • πŸ“¦ Using cloud storage (S3/Cloudinary) in production for storing images at cloud platform.
  • ⚑ Redis caching improves performance for feed, likes, and shares

⚑ Future Improvements πŸš€

  • πŸ” JWT authentication & secure user accounts
  • πŸ”” Real-time notifications with Socket.io
  • 🎯 Advanced AI-powered content recommendations

πŸ“„ License πŸ“œ

MIT License βœ…

About

A social media platform for sharing moments through images and captions, enhanced with AI-powered features like automatic caption generation, hashtag suggestions, and content moderation. Built with ReactJS, NodeJS, Express, MongoDB, and Redis for real-time performance.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages