Skip to content

parthnarkar/FitMart

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

31 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

FitMart

FitMart

Your All-in-One Fitness & Nutrition E-Commerce Platform

A full-stack MERN e-commerce application combining premium fitness gear, nutrition products, and seamless payments β€” built for learning, collaboration, and real-world use.


React Node.js MongoDB Firebase Razorpay Tailwind CSS License: MIT Status PRs Welcome


Quick Start | Docs | Contribute | Report Bug | Request Feature


πŸ“Œ Table of Contents


🧠 About the Project

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.


✨ Features

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

πŸ› οΈ Tech Stack

Frontend

  • React v19 + Vite β€” fast dev experience
  • Tailwind CSS β€” utility-first styling
  • Firebase Authentication β€” client-side auth

Backend

  • Node.js + Express β€” REST API
  • Mongoose β€” MongoDB ODM
  • Razorpay SDK β€” payment processing

Database & Services

  • MongoDB (Atlas or local)
  • Firebase (Auth)
  • Razorpay (Payments)

πŸ“ Project Structure

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

πŸš€ Quick Start

Prerequisites

Make sure you have these installed:


1. Clone the Repository

git clone https://github.com/parthnarkar/FitMart.git
cd FitMart

2. Set Up the Server

cd server
npm install

Create a .env file in the server/ folder (see Environment Variables):

cp .env.example .env   # if available, or create manually

Seed the database with sample products:

npm run seed

Start the backend dev server:

npm run dev

The server runs at http://localhost:5000 by default.


3. Set Up the Client

Open a new terminal and run:

cd client
npm install

Create a .env file in the client/ folder (see Environment Variables):

npm run dev

The client runs at http://localhost:5173 by default.


πŸ”‘ Environment Variables

⚠️ Never commit your .env files or API secrets to GitHub! They are already in .gitignore.

Server β€” server/.env

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>

Client β€” client/.env

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=

🌱 Seeding the Database

The seed script populates your MongoDB with sample fitness products:

cd server
npm run seed

Each product includes: productId, name, brand, category, price, originalPrice, rating, reviews, badge, image, stock, and reserved.


▢️ Running the App

Development

# Terminal 1 β€” Backend
cd server && npm run dev

# Terminal 2 β€” Frontend
cd client && npm run dev

Production

# Build the frontend
cd client && npm run build

# Start the server
cd server && npm start

πŸ“‘ API Reference

Base URL: http://localhost:5000 (or your VITE_API_URL)

πŸ›οΈ Products

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

πŸ›’ Cart

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

πŸ“¦ Orders

Method Endpoint Description
POST /api/orders Create order β€” body: { userId, items? }
GET /api/orders/:userId List all orders for a user

πŸ’³ Payments

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_id with RAZORPAY_KEY_SECRET.


πŸ—ƒοΈ Data Models

Product

{
  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
}

Cart

{
  userId: String (indexed),
  items: [{ productId, quantity }]
}

Order

{
  userId: String,
  items:  [{ productId, quantity, price }],  // price snapshotted at purchase
  total:  Number,
  status: String
}

πŸ“ Notes & Recommendations

  • API URL consistency β€” Some client files still use the hardcoded http://localhost:5000. It's recommended to standardize everything on VITE_API_URL. This is a great first contribution!
  • Cart reservation β€” Product.reserved increments 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_SECRET to the client.
  • Firebase β€” Only client-facing Firebase config keys go in the Vite .env.local. Never put service account credentials there.

🀝 Contributing

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! 🌱


πŸ‘₯ Contributors

Thanks to everyone who contributes to FitMart.

FitMart contributors

πŸ“„ License

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!

About

A full-stack MERN e-commerce application combining premium fitness gear, nutrition products, and seamless payment built for learning, collaboration, and real-world use.

Resources

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages