Imagify is an AI-powered image generation platform built with the MERN stack. It allows users to create images from text prompts using the ClipDrop API while managing usage through a credits-based system.
To run client
npm run devTo run server
npm run serverFrontend
npm install react react-dom react-router-dom react-toastify motion
Backend
npm install express mongoose dotenv bcrypt jsonwebtoken axios form-data cors nodemon
To run this project, you will need to add the following environment variables to your .env file
MONGODB_URI
CLIPDROP_API
JWT_SECRET
-
Learned how to implement JWT-based authentication and protect routes with middleware.
-
Gained experience with MongoDB and Mongoose for managing user data and credit balances.
-
Understood how to securely call third-party APIs (ClipDrop) and handle responses like Base64 image data.
-
Improved at using React Context API to manage global states such as token and creditBalance.
-
Learned how to give real-time feedback with toasts, loaders, and credit checks in the frontend.
-
Initially faced token issues with JWT; solved this by standardizing headers: { token } across backend and frontend.
-
Sometimes credits weren’t updating correctly; fixed this by always fetching updated user data after image generation.
-
Learned how to handle binary image data by converting it to Base64 and rendering as data:image/png;base64,....
-
Secured routes with userAuth middleware and avoided exposing secrets by using .env.
You can create an account using the /api/user/register endpoint and log in using /api/user/login. Both return a JWT token which you must pass in the headers as { token } for protected routes.
Each user has a creditBalance stored in MongoDB. Every time you generate an image, one credit is deducted. You can view your balance using /api/user/buyCredit.
You will not be able to generate images. The app will automatically redirect you to the "Buy Credits" page.
Imagify integrates with the ClipDrop Text-to-Image API, which generates images based on your prompts.
The ClipDrop API responds with binary data. This is converted to Base64 and sent back as data:image/png;base64,..., so it can be directly displayed in the frontend.
JWT is used for authentication, middleware (userAuth) protects routes, and sensitive data such as MongoDB URI and API keys are stored in .env files.
Yes, but the app restricts NSFW/seductive content for safe use.