Caption.io is a web-based platform that allows users to upload images and generate captions using artificial intelligence. This project was built as part of a challenge where the objective was to create an AI-powered application in one day.
- Challenge: Build an AI-powered application in one hour.
- Planning: I thought that I will build the Backend only. And I completed it in 30-45 minutes.
- Timeline:
- Backend (Node.js, Express, and Gemini API) was built in 30-45 minutes.
- Frontend (React.js and Tailwind CSS) took around 2 hours.
- Afterward, I spent time fixing bugs and finalizing the project.
The project integrates both a Node.js/Express backend and a React.js frontend, and uses the Gemini API for AI-based caption generation.
- Image Upload: Users can upload images directly from their devices.
- AI Caption Generator: Uses AI (via Gemini API) to generate captions based on the uploaded image.
- Toast Notifications: Displays success, error, and information messages using toast notifications.
- Responsive Design: The application is mobile-friendly and scales well across different screen sizes.
- Static Pages: Includes Terms and Conditions, Privacy Policy, and Contact Us pages.
- 404 Handling: Displays a custom "Not Found" page for invalid URLs.
-
Clone the Repository:
git clone https://github.com/your-username/caption-io.git
-
Navigate to the Backend Directory:
cd caption-io/backend -
Install Backend Dependencies:
Make sure you have Node.js installed. Then run:
npm install
-
Set Up Environment Variables:
Create a
.envfile in thebackenddirectory and add the following environment variables:PORT=8000 GEMINI_API_KEY=your_gemini_api_key_here
-
Start the Backend Server:
npm start
The backend will run on
http://localhost:8000.
-
Navigate to the Frontend Directory:
cd ../frontend -
Install Frontend Dependencies:
npm install
-
Start the Frontend Development Server:
npm start
-
Visit the Application:
Open your browser and visit
http://localhost:5173to view the app.
Note: The frontend will make API calls to
http://localhost:8000/api/v1/<route>for caption generation.
- Image Upload: Click on the upload button to upload an image and generate a caption using the AI system.
- Notifications: Toast notifications will appear for success or error messages based on actions performed.
- Pages: Visit
/terms-conditions,/privacy-policy, and/contact-usfor additional static information. - 404 Handling: Accessing invalid URLs will show a "Page Not Found" message.
caption-io/
│
├── backend/ # Backend code (Node.js, Express)
│ ├── controllers/ # Controllers for API endpoints
│ ├── routes/ # API routes
│ ├── config/ # Gemini API configuration and integration
│ ├── .env # Environment variables
│ ├── index.js # Main Express app
│
├── frontend/ # Frontend code (React.js)
│ ├── src/
│ │ ├── components/ # Reusable components
│ │ ├── pages/ # Static pages (Terms, Privacy, etc.)
│ │ ├── App.jsx # Main app component
│ │ ├── Main.jsx # Entry point of the app
│
├── .gitignore # Git ignore file
├── README.md # Project documentation
└── package.json # NPM dependencies and scripts
- Node.js: JavaScript runtime for backend development.
- Express.js: Web framework for Node.js used to build the backend.
- Gemini API: Used for AI caption generation.
- React.js: JavaScript library for building user interfaces.
- Tailwind CSS: Utility-first CSS framework for styling.
- React Router: Handles routing between different pages in the frontend.
- Toast Notifications: For real-time success and error messages.
In the project directory, you can run the following commands for both frontend and backend:
npm start: Runs the Node.js backend server.npm run dev: Runs the backend in development mode using nodemon.
npm run dev: Runs the React app in development mode.npm run build: Builds the app for production to thebuildfolder.
Contributions are welcome! If you would like to contribute, please follow these steps:
- Fork the repository.
- Create a new branch:
git checkout -b feature-branch. - Make your changes and commit them:
git commit -m 'Added a new feature'. - Push to the branch:
git push origin feature-branch. - Submit a pull request.
Please ensure your code follows the project's code style and conventions.
This project is licensed under the MIT License - see the LICENSE file for details.