An AI-powered Instagram caption generator that creates authentic, human-like captions by analyzing images, incorporating music context, and learning from user preferences.
- AI-Powered Caption Generation: Uses GPT-4 Vision to analyze images and generate contextually relevant captions
- Music Integration: Connect Spotify tracks to enhance captions with music context
- Audio Transcription: Upload audio files to provide context via voice input
- Customization Options:
- Multiple tones (casual, professional, funny, poetic, etc.)
- Variable caption lengths
- Language support (English, Hindi, Hinglish)
- Emoji and hashtag customization
- Learning System: Caption generator learns from user feedback to improve future suggestions
- User Profiles: Track caption history, statistics, and preferences
- Image Storage: Cloudinary integration for persistent image storage
- Spotify Integration: Search and select tracks to enhance caption context
- React 19 - UI framework
- Tailwind CSS - Styling
- React Router - Navigation
- Supabase - Authentication
- Recharts - Data visualization
- Lucide React - Icons
- Node.js - Runtime
- Express - Web framework
- MongoDB - Database
- OpenAI API - GPT-4 Vision for image analysis and caption generation
- Spotify Web API - Music integration
- Cloudinary - Image storage
- Winston - Logging
- Multer - File upload handling
- AWS ECS (Fargate) - Container orchestration
- AWS ECR - Container registry
- Docker - Containerization
- MongoDB Atlas - Managed database
- AWS Secrets Manager - Environment variable management
Instagram-Caption-Generator/
βββ backend/
β βββ deploy.sh # AWS deployment script
β βββ Dockerfile # Container configuration
β βββ .dockerignore # Docker build exclusions
β βββ server.js # Express server entry point
β βββ routes/ # API route handlers
β βββ services/ # Business logic services
β βββ middleware/ # Express middleware
β βββ utils/ # Utility functions
β βββ scripts/ # Migration and utility scripts
βββ frontend/
β βββ src/
β β βββ components/ # React components
β β βββ pages/ # Page components
β β βββ context/ # React context providers
β β βββ utils/ # Frontend utilities
β βββ public/ # Static assets
βββ README.md
- Node.js (v18 or higher)
- npm or yarn
- MongoDB (local or MongoDB Atlas)
- AWS Account (for deployment)
- Docker (for containerization)
- AWS CLI (for deployment)
-
Clone the repository
git clone https://github.com/yourusername/Instagram-Caption-Generator.git cd Instagram-Caption-Generator -
Install dependencies
# Install root dependencies (if any) npm install # Install backend dependencies cd backend npm install # Install frontend dependencies cd ../frontend npm install
-
Configure environment variables
Backend (create
backend/.env):# Server PORT=3001 NODE_ENV=development # Database MONGODB_URI=your_mongodb_connection_string # Authentication JWT_SECRET=your_jwt_secret_key # OpenAI OPENAI_API_KEY=your_openai_api_key # Spotify SPOTIFY_CLIENT_ID=your_spotify_client_id SPOTIFY_CLIENT_SECRET=your_spotify_client_secret SPOTIFY_REDIRECT_URI=http://localhost:3000/callback # Cloudinary (optional, for image storage) CLOUDINARY_CLOUD_NAME=your_cloud_name CLOUDINARY_API_KEY=your_api_key CLOUDINARY_API_SECRET=your_api_secret # CORS CORS_ORIGINS=http://localhost:3000 FRONTEND_URL=http://localhost:3000
Frontend (create
frontend/.env):REACT_APP_BACKEND_URL=http://localhost:3001 REACT_APP_SUPABASE_URL=your_supabase_url REACT_APP_SUPABASE_ANON_KEY=your_supabase_anon_key
-
Start development servers
Backend (from
backend/directory):npm run dev
Server runs on
http://localhost:3001Frontend (from
frontend/directory):npm start
App runs on
http://localhost:3000
npm start- Start production servernpm run dev- Start development server with nodemon
npm start- Start React development servernpm run build- Build production bundlenpm test- Run testsnpm test -- -t "test name"- Run specific test
We use pre-commit to keep basic hygiene checks consistent.
Setup:
- Install pre-commit:
pipx install pre-commit(orpip install pre-commit) - Install the git hook:
pre-commit install - (Optional) Run on all files:
pre-commit run --all-files
Enabled hooks:
- trailing whitespace cleanup
- end-of-file fixer
- check merge conflicts
- enforce LF line endings
- detect private keys
- YAML syntax check
The project includes an automated deployment script for AWS ECS with Fargate.
- AWS CLI configured (
aws configure) - Docker installed
- Valid AWS credentials
The backend/deploy.sh script automates the deployment process:
Dry-run mode (safe testing - no AWS changes):
cd backend
./deploy.sh --dry-runActual deployment:
cd backend
./deploy.shWhat the script does:
- Automatically detects AWS account ID and region from your AWS CLI configuration
- Builds Docker image
- Pushes image to Amazon ECR
- Updates ECS service with new image
Configuration: The script uses these defaults (can be overridden with environment variables):
- ECR Repository:
instagram-caption-backend - ECS Cluster:
instagram-caption-backend - ECS Service:
instagram-caption-backend-service - Region: Auto-detected from AWS CLI config
Override defaults:
ECR_REPOSITORY=my-repo ECS_CLUSTER=my-cluster ./deploy.sh-
Build and push Docker image
cd backend docker build --platform linux/amd64 -t instagram-caption-backend:latest . aws ecr get-login-password --region us-east-1 | docker login --username AWS --password-stdin YOUR_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com docker tag instagram-caption-backend:latest YOUR_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/instagram-caption-backend:latest docker push YOUR_ACCOUNT_ID.dkr.ecr.us-east-1.amazonaws.com/instagram-caption-backend:latest
-
Update ECS service
aws ecs update-service \ --cluster instagram-caption-backend \ --service instagram-caption-backend-service \ --force-new-deployment \ --region us-east-1
For production deployment, use AWS Secrets Manager to store sensitive environment variables. The ECS task definition should reference secrets from Secrets Manager.
-
Create a Cloudinary Account
- Sign up at https://cloudinary.com (free tier available)
- Get your credentials from the dashboard
-
Configure Environment Variables Add these to your backend
.envfile or AWS Secrets Manager:CLOUDINARY_CLOUD_NAME=your_cloud_name CLOUDINARY_API_KEY=your_api_key CLOUDINARY_API_SECRET=your_api_secret -
How It Works
- When Cloudinary is configured, all uploaded images (profile photos and caption images) are automatically uploaded to Cloudinary
- Images are stored in folders:
profile_photos/andcaptions/ - Old images are automatically deleted when replaced
- If Cloudinary is not configured, the app falls back to local storage (which gets wiped on redeployment)
- Images are stored in
backend/uploads/directory - This directory is ephemeral and gets wiped on redeployment
- Not recommended for production as images will disappear after each deployment
The backend allows requests from configured origins. Add your frontend URL to the CORS configuration in backend/server.js or via environment variables:
CORS_ORIGINS=https://your-frontend.com,https://another-domain.com
FRONTEND_URL=https://your-frontend.comThe application uses MongoDB. For production, use MongoDB Atlas or a managed MongoDB service. Update the MONGODB_URI in your environment variables.
POST /api/auth/register- User registrationPOST /api/auth/login- User loginGET /api/auth/me- Get current user
POST /api/captions/generate-caption- Generate new captionGET /api/captions- Get user's captionsGET /api/captions/:id- Get specific captionPUT /api/captions/:id/feedback- Submit feedback on caption
GET /api/spotify/search- Search for tracksGET /api/spotify/recommendations- Get song recommendations
GET /api/dashboard/stats- Get user statistics
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add some amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
This project is licensed under the ISC License.
- OpenAI for GPT-4 Vision API
- Spotify for Web API
- Cloudinary for image storage
- AWS for cloud infrastructure
For issues and questions, please open an issue on GitHub.
Note: Make sure to keep your API keys and secrets secure. Never commit .env files or sensitive credentials to version control.