π Pinterest Clone β Built with the MERN Stack
Med-Spire is a full-stack Pinterest Clone application developed using the MERN stack: MongoDB, Express.js, React, and Node.js. It replicates core Pinterest features such as:
-
π User authentication
-
πΈ Image uploads via ImageKit
-
π Pinboard creation and browsing
-
π± Fully responsive design
The project also includes component testing using Vitest and utilizes various modern libraries to ensure clean, efficient, and scalable development.
-
User Authentication (Register, Login, Logout)
-
Create and Save Pins
-
Upload Images
-
Responsive Masonry Grid Layout
-
Like and Comment on Pins
-
User Profiles
-
Search Functionality
-
Fully Tested Components with Vitest
-
React.js
-
Tailwind CSS β for responsive and fast styling
-
React Router DOM β for routing
-
React Query - for state management
-
Axios β for API calls
-
Material-UI β for beautiful icons
-
Imagekit.io β for image uploading and download
-
Vitest + React Testing Library β for unit/component testing
-
Node.js
-
Express.js
-
MongoDB with Mongoose
-
JWT (JSON Web Tokens) β for authentication
-
bcrypt β for password hashing
-
Sharp β to convert large images in common formats to smaller
π¦ clone-pinterest
βββ clients
β βββ public
β βββ src
β β βββ components
β β βββ routes
β β βββ utils
β β βββ main.jsx
β βββ Dockerfile
β
βββ backend
β βββ controllers
β βββ models
β βββ routes
β βββ utils
β βββ Dockerfile
β βββ index.js
β
βββ README.md
βββ docker-compose.yml
This project uses Vitest along with React Testing Library to verify that components function correctly and the UI renders as expected.
cd client
npm run test
This command runs all unit and component tests in the terminal.
To open the Vitest UI dashboard:
cd client
npm run test:ui
This will launch a visual interface where you can explore test results interactively.
-
Clone the repository:
git clone https://github.com/sekak/pinterest-clone.git cd pinterest-clone -
Set up the frontend:
cd client npm install -f
To configure the frontend environment, you need to define two environment variables:
VITE_URL_ENDPOINT_KIT=
VITE_API_BASE_URL=http://localhost:3000/api
-
Go to https://imagekit.io and log in to your account.
-
On the Dashboard, click on the βURL Endpointβ icon in the top-right corner.
-
Navigate to:
Configuration β URL Endpoint -
You will see your existing URL endpoint. You can either:
-
Use the existing one
-
Or click βAdd Newβ to create a new endpoint
-
π Copy the full URL (e.g., https://ik.imagekit.io/your_folder) and paste it into your .env file:
VITE_URL_ENDPOINT_KIT=https://ik.imagekit.io/your_folder
Once your .env file is ready, run the development server:
npm run dev
Your app will now use the correct API base URL and ImageKit endpoint for uploading and rendering images.
3: Set up the Back-end:
cd backend
npm install
To configure the back-end environment, create a .env file in the /backend folder and add the following variables:
MONGO=your_mongo_connection_string
CORS_ORIGIN=http://localhost:5173
JWT_SECRET=your_jwt_secret
IK_URL_ENDPOINT=your_imagekit_url_endpoint
IK_PUBLIC_KEY=your_imagekit_public_key
IK_PRIVATE_KEY=your_imagekit_private_key
PORT=3000
-
MONGOβ MongoDB connection string-
Sign in to MongoDB Atlas.
-
Follow this guide to set it up and get your connection string:
π FreeCodeCamp MongoDB Setup Guide -
Replace
<password>in the string with your actual password, and paste it in the.envfile.
-
-
CORS_ORIGINβ Frontend origin allowed to access the backend-
Use
http://localhost:5173for development -
Use
http://localhost:4173when building for production -
This secures the connection between the client and server.
-
-
JWT_SECRETβ A secret string used to sign JSON Web Tokens- Choose a strong, unique string. Keep it secret.
-
IK_URL_ENDPOINTβ ImageKit URL endpoint-
This should match the one used in the frontend.
-
See the frontend setup section for steps to obtain it.
-
-
IK_PUBLIC_KEY&IK_PRIVATE_KEYβ ImageKit API keys-
Log in to ImageKit.io
-
Go to the Dashboard β Developer Options
-
Copy both the public and private keys and add them to your
.envfile.
-
-
PORTβ Server port (default:3000)- Use this to define the port your Express app will run on. 3000.
Once your .env file is ready, run the development server:
npm start
Instead of running the frontend and backend separately, you can run everything with Docker using the following command:
sudo docker compose up --build
Once the containers are built and running, open your browser and visit:
πΈ Screenshots
Responsive










