ImageHub Backend is the server-side component of the ImageHub application, developed using Node.js and Express.js. This repository handles user authentication, image storage, and API endpoints for the front-end application. It employs Bcrypt for secure password hashing, JWT for token-based authentication, and Cloudinary for image management. This project also helped me understand the process of hosting Node.js APIs on Vercel.
- User Authentication: Secure login and signup using JWT.
- Image Storage: Upload and manage images with Cloudinary integration.
- API Endpoints: Provides RESTful APIs for frontend communication.
- Password Security: Utilizes Bcrypt for hashing passwords.
- Modular Architecture: Clean and maintainable code structure.
- Vercel Hosting: Deployed on Vercel for seamless API hosting.
- Node.js: JavaScript runtime for server-side programming.
- Express.js: Web application framework for building REST APIs.
- Bcrypt: Password hashing library for secure storage.
- JWT (JSON Web Tokens): For secure user authentication.
- Cloudinary: Cloud service for image storage and management.
- MongoDB: NoSQL database for storing user and image data.
- Mongoose: ODM for MongoDB, providing schema-based data modeling.
- Vercel: Hosting platform for Node.js applications.
The backend serves the ImageHub Frontend, a React-based application for managing and displaying images.
Access the live API hosted on Vercel: https://image-hub-backend-xi.vercel.app/
-
Clone the repository:
git clone https://github.com/vishwasshar/ImageHub-Backend.git
-
Navigate to the project directory:
cd ImageHub-Backend
-
Install dependencies:
npm install
-
Set up environment variables:
Create a
.env
file in the root directory and add the following environment variables:PORT=5000 MONGO_URI=your_mongodb_uri JWT_SECRET=your_jwt_secret CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name CLOUDINARY_API_KEY=your_cloudinary_api_key CLOUDINARY_API_SECRET=your_cloudinary_api_secret
-
Run the development server:
npm start
The server will run at http://localhost:5000
.
-
POST /img/submit
: Submit a new image.- Middleware:
isAuth
- Controller:
imgSubmission
- Middleware:
-
PUT /img/updateView/:id
: Update view count for an image.- Middleware:
isAuth
- Controller:
updateImgView
- Middleware:
-
POST /img
: Search for images.- Middleware:
isAuth
- Controller:
searchImg
- Middleware:
-
PUT /user/create
: Create a new user.- Controller:
createUser
- Controller:
-
POST /user/login
: Log in a user.- Controller:
loginUser
- Controller:
.
├── controller
│ ├── Img.js
│ └── user.js
├── middleware
│ └── isAuth.js
├── routes
│ ├── Img.js
│ └── user.js
├── util
│ └── database.js
├── .env
├── app.js
└── package.json
For any questions, feedback, or contributions, feel free to reach out to me via:
- Email: vishwassharma3287@gmail.com
- LinkedIn: Vishwas Sharma
I welcome your input and look forward to connecting with you!