A full-stack e-commerce store prototype that displays products with multiple storage variants and EMI plans. It uses a modern React UI with a lightweight Node/Express API and MongoDB backend.
- Frontend: React + Vite + Tailwind CSS
- Backend: Node.js + Express
- Database: MongoDB (Mongoose)
- Node.js (v18+)
- MongoDB Atlas (or any MongoDB URI)
-
Open a terminal and navigate to:
cd backend -
Install dependencies:
npm install
-
Configure environment variables (recommended):
Create a
.envfile inbackend/with:MONGODB_URI=mongodb+srv://<user>:<pass>@<cluster>.mongodb.net/<dbname>?retryWrites=true&w=majority
-
Seed the database (this will clear existing products and add the sample products):
node seed/seedData.js
-
Run the backend server:
node server.js
The API will be available at:
http://localhost:5000
-
In a new terminal, navigate to the frontend folder:
cd frontend/1fi -
Install dependencies:
npm install
-
(Optional) Create a
.envfile to override the API base URL in development:VITE_API_BASE_URL=http://localhost:5000/api
-
Start the dev server:
npm run dev
The app will open at
http://localhost:5173(or whatever Vite provides).
All API routes are prefixed with /api.
Response example:
[
{
"_id": "...",
"name": "iPhone 17 Pro",
"slug": "iphone-17-pro",
"variant": "256GB",
"price": 127400,
"mrp": 134900,
"variants": [
{ "storage": "256GB", "price": 127400, "mrp": 134900, "stock": 12 },
{ "storage": "512GB", "price": 147400, "mrp": 154900, "stock": 9 }
],
"image": "/iphone.jpg",
"colors": ["orange", "silver", "blue"],
"colorImages": [
{ "color": "orange", "image": "/iphone orange.jpg" }
],
"emiPlans": [
{ "monthlyPayment": 44967, "tenure": 3, "interestRate": "0%", "cashback": 7500 }
]
}
]Example: GET /api/products/iphone-17-pro
Response: the full product object matching the slug.
Example: PUT /api/products/iphone-17-pro/variants/256GB
Payload:
{ "price": 120000, "mrp": 130000, "stock": 10 }Response: Updated product object.
name(String) — requiredslug(String) — required, uniquevariant(String) — legacy single-variant fieldprice(Number) — requiredmrp(Number)variants(Array)storage(String) — requiredprice(Number) — requiredmrp(Number) — requiredstock(Number)
image(String)colors(Array of strings)colorImages(Array)color(String) — requiredimage(String) — required
emiPlans(Array)monthlyPayment(Number)tenure(Number)interestRate(String)cashback(Number)
- Make sure
MONGODB_URIis set in the environment variables. - The API is mounted at
/api.
- Set
VITE_API_BASE_URLto your backend’s/apiURL (e.g.https://your-backend.onrender.com/api).
From any machine, you can confirm the backend is working:
curl https://<your-backend-domain>/api/productsIf you see a JSON array of products, the backend and DB are connected correctly.