A full-stack MERN e-commerce application combining premium fitness gear, nutrition products, and seamless payments β built for learning, collaboration, and real-world use.
Quick Start | Docs | Contribute | Report Bug | Request Feature
- About the Project
- Features
- Tech Stack
- Project Structure
- Quick Start
- Environment Variables
- Seeding the Database
- Running the App
- API Reference
- Data Models
- Notes & Recommendations
- Contributing
- Contributors
- License
FitMart is a full-stack e-commerce web application built with the MERN stack. It's designed as both a learning resource and a real-world starting point for building modern storefronts.
The project covers end-to-end functionality including:
- π User authentication via Firebase
- π Cart management with stock reservation logic
- π³ Secure payments via Razorpay (with HMAC verification)
- π¦ Order management with price snapshotting
Whether you're a beginner looking to learn full-stack development or an experienced developer who wants to contribute β FitMart is built for you.
| Feature | Description |
|---|---|
| ποΈ Product Catalog | Browse products with images, pricing, badges & metadata |
| π Smart Cart | Cart with real-time stock reservation logic |
| π¦ Order Management | Orders with price snapshotting at time of purchase |
| π³ Razorpay Payments | Secure order creation & HMAC payment verification |
| π Firebase Auth | Email/password and Google Sign-In |
| π± Seed Script | One-command DB population with demo products |
| π± PWA Ready | Progressive Web App support |
- React v19 + Vite β fast dev experience
- Tailwind CSS β utility-first styling
- Firebase Authentication β client-side auth
- Node.js + Express β REST API
- Mongoose β MongoDB ODM
- Razorpay SDK β payment processing
- MongoDB (Atlas or local)
- Firebase (Auth)
- Razorpay (Payments)
FitMart/
βββ client/ # React + Vite Frontend
β βββ src/
β β βββ components/ # Reusable UI components
β β βββ pages/ # Route-level pages
β β βββ auth/ # Firebase auth helpers
β β βββ utils/ # Helper functions
β βββ public/ # Static assets
β βββ package.json
β
βββ server/ # Node.js + Express Backend
β βββ models/ # Mongoose models (Product, Cart, Order)
β βββ routes/ # Express routes (products, cart, orders, payment)
β βββ db.js # MongoDB connection helper
β βββ index.js # Server entry point
β βββ seed.js # DB seed script
β
βββ CONTRIBUTING.md # Contributor guide
βββ README.md
Make sure you have these installed:
- Node.js v16+
- npm or yarn
- A MongoDB connection (Atlas or local)
- A Firebase project (for auth)
- A Razorpay account (for payments)
git clone https://github.com/parthnarkar/FitMart.git
cd FitMartcd server
npm installCreate a .env file in the server/ folder (see Environment Variables):
cp .env.example .env # if available, or create manuallySeed the database with sample products:
npm run seedStart the backend dev server:
npm run devThe server runs at http://localhost:5000 by default.
Open a new terminal and run:
cd client
npm installCreate a .env file in the client/ folder (see Environment Variables):
npm run devThe client runs at http://localhost:5173 by default.
β οΈ Never commit your.envfiles or API secrets to GitHub! They are already in.gitignore.
MONGO_URI=<your_mongodb_connection_string>
MONGO_DB=<your_database_name> # optional
PORT=5000
RAZORPAY_KEY_ID=<your_razorpay_key_id>
RAZORPAY_KEY_SECRET=<your_razorpay_key_secret>VITE_API_URL=http://localhost:5000
VITE_RAZORPAY_KEY_ID=<your_razorpay_key_id>
# Firebase config (from your Firebase project settings)
VITE_FIREBASE_API_KEY=
VITE_FIREBASE_AUTH_DOMAIN=
VITE_FIREBASE_PROJECT_ID=
VITE_FIREBASE_STORAGE_BUCKET=
VITE_FIREBASE_MESSAGING_SENDER_ID=
VITE_FIREBASE_APP_ID=
VITE_FIREBASE_MEASUREMENT_ID=The seed script populates your MongoDB with sample fitness products:
cd server
npm run seedEach product includes: productId, name, brand, category, price, originalPrice, rating, reviews, badge, image, stock, and reserved.
# Terminal 1 β Backend
cd server && npm run dev
# Terminal 2 β Frontend
cd client && npm run dev# Build the frontend
cd client && npm run build
# Start the server
cd server && npm startBase URL: http://localhost:5000 (or your VITE_API_URL)
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/products |
List all products (sorted by productId) |
GET |
/api/products/:id |
Get product by productId |
POST |
/api/products |
Create a new product |
PUT |
/api/products/:id |
Update product by productId |
DELETE |
/api/products/:id |
Delete product by productId |
| Method | Endpoint | Description |
|---|---|---|
GET |
/api/cart/:userId |
Get or create a user's cart |
POST |
/api/cart/:userId/add |
Add item β body: { productId, quantity } |
POST |
/api/cart/:userId/remove |
Remove item β body: { productId, quantity } |
DELETE |
/api/cart/:userId |
Clear cart and release reserved stock |
| Method | Endpoint | Description |
|---|---|---|
POST |
/api/orders |
Create order β body: { userId, items? } |
GET |
/api/orders/:userId |
List all orders for a user |
| Method | Endpoint | Description |
|---|---|---|
POST |
/create-order |
Create a Razorpay order |
POST |
/verify-payment |
Verify HMAC signature |
POST |
/clear-cart |
Release stock & clear cart β body: { userId } |
POST |
/demo-success |
Simulate successful payment (testing only) |
Security: Payment verification uses HMAC-SHA256 on
razorpay_order_id|razorpay_payment_idwithRAZORPAY_KEY_SECRET.
{
productId: Number (unique, required),
name: String,
brand: String,
category: String,
price: Number (required),
originalPrice: Number,
rating: Number,
reviews: Number,
badge: String,
image: String, // URL
stock: Number | null,
reserved: Number // quantity reserved in carts
}{
userId: String (indexed),
items: [{ productId, quantity }]
}{
userId: String,
items: [{ productId, quantity, price }], // price snapshotted at purchase
total: Number,
status: String
}- API URL consistency β Some client files still use the hardcoded
http://localhost:5000. It's recommended to standardize everything onVITE_API_URL. This is a great first contribution! - Cart reservation β
Product.reservedincrements on cart add and decrements on cart remove/clear. Orders finalize the reservation but don't re-release it. - Razorpay β Always verify payments server-side. Never expose
RAZORPAY_KEY_SECRETto the client. - Firebase β Only client-facing Firebase config keys go in the Vite
.env.local. Never put service account credentials there.
We love contributions! FitMart is an open-source, community-driven project and contributions of all kinds are welcome β from fixing typos to building new features.
Please read our CONTRIBUTING.md for a full guide on:
- How to set up your development environment
- How to pick and work on issues
- How to submit a Pull Request
- Code style and commit conventions
New to open source? Look for issues labelled good first issue β they're perfect starting points! π±
Thanks to everyone who contributes to FitMart.
This project is licensed under the MIT License β see the LICENSE file for details.
Made with β€οΈ by Parth Narkar and the Parth Builds Community
β Star this repo if you find it useful β it means a lot!
