A full-stack e-commerce web application built with the MERN stack, featuring dual payment gateways, cloud image management, and secure JWT authentication.
- Features
- Tech Stack
- Project Structure
- Getting Started
- Environment Variables
- Scripts
- API Overview
- Deployment
- Contributing
- π Secure Authentication β JWT-based login/signup with bcrypt password hashing
- ποΈ Full Shopping Experience β Browse, filter, add to cart, and place orders
- π¨βπΌ Admin Dashboard β Manage products, orders, and users from a dedicated panel
- π³ Dual Payment Gateway β Pay via Stripe or Razorpay (INR supported)
- πΌοΈ Cloud Image Uploads β Product images stored and served via Cloudinary
- π± Responsive UI β Clean, mobile-first design with Tailwind CSS
- π Toast Notifications β Real-time feedback with React Toastify
| Technology | Purpose |
|---|---|
| React.js 18 | UI Library |
| Tailwind CSS | Styling & Responsive Design |
| React Router DOM v6 | Client-side Routing |
| Axios | HTTP Requests |
| React Toastify | Notifications |
| Technology | Purpose |
|---|---|
| Node.js | Runtime Environment |
| Express.js | Web Framework |
| Mongoose | MongoDB ODM |
| JWT | Authentication Tokens |
| bcryptjs | Password Hashing |
| Multer | File Upload Handling |
| Validator | Input Validation |
| Service | Purpose |
|---|---|
| MongoDB | Database |
| Cloudinary | Image Storage & CDN |
| Stripe | International Payment Gateway |
| Razorpay | Indian Payment Gateway |
apnastore/
βββ client/ # React Frontend
β βββ public/
β βββ src/
β β βββ assets/
β β βββ components/ # Reusable UI components
β β βββ context/ # React context (cart, auth, etc.)
β β βββ pages/ # Route-level pages
β β βββ App.jsx
β βββ package.json
β βββ tailwind.config.js
β
βββ server/ # Express Backend
β βββ config/ # DB & Cloudinary config
β βββ controllers/ # Route logic
β βββ middleware/ # Auth & upload middleware
β βββ models/ # Mongoose schemas
β βββ routes/ # API routes
β βββ server.js
β βββ package.json
β
βββ README.md
Make sure you have the following installed:
- Node.js v18+
- npm or yarn
- A MongoDB database (local or Atlas)
- A Cloudinary account
- A Stripe account
- A Razorpay account
git clone https://github.com/your-username/apnastore.git
cd apnastorecd server
npm installCreate a .env file in the server/ directory (see Environment Variables below).
npm run devServer will start on http://localhost:4000 (or your configured port).
cd client
npm install
npm run devFrontend will run on http://localhost:5173.
Create a .env file inside the server/ directory and add the following:
# βββ Database βββββββββββββββββββββββββββββββββββββββ
MONGODB_URI=your_mongodb_connection_string
# βββ Cloudinary βββββββββββββββββββββββββββββββββββββ
CLOUDINARY_NAME=your_cloudinary_cloud_name
CLOUDINARY_API_KEY=your_cloudinary_api_key
CLOUDINARY_SECRET_KEY=your_cloudinary_secret_key
# βββ Authentication ββββββββββββββββββββββββββββββββββ
JWT_SECRET=your_super_secret_jwt_key
# βββ Admin Credentials βββββββββββββββββββββββββββββββ
ADMIN_EMAIL=admin@example.com
ADMIN_PASSWORD=securepassword
# βββ Stripe ββββββββββββββββββββββββββββββββββββββββββ
STRIPE_SECRET_KEY=your_stripe_secret_key
STRIPE_PUBLISHABLE_KEY=your_stripe_publishable_key
# βββ Razorpay ββββββββββββββββββββββββββββββββββββββββ
RAZORPAY_KEY_ID=your_razorpay_key_id
RAZORPAY_KEY_SECRET=your_razorpay_key_secret
# βββ App Config ββββββββββββββββββββββββββββββββββββββ
CURRENCY=INR
β οΈ Never commit your.envfile. Add it to.gitignoreimmediately.
| Command | Description |
|---|---|
npm start |
Start server in production mode |
npm run dev |
Start server with nodemon (hot reload) |
| Command | Description |
|---|---|
npm run dev |
Start Vite dev server |
npm run build |
Build for production |
npm run preview |
Preview production build locally |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/user/register |
Register a new user |
| POST | /api/user/login |
Login and receive JWT |
| POST | /api/user/admin |
Admin login |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/product/list |
Get all products |
| GET | /api/product/single |
Get single product |
| POST | /api/product/add |
Add product (Admin) |
| POST | /api/product/remove |
Remove product (Admin) |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/cart/get |
Get user cart |
| POST | /api/cart/add |
Add item to cart |
| POST | /api/cart/update |
Update cart item |
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/order/place |
Place order (COD) |
| POST | /api/order/stripe |
Place order via Stripe |
| POST | /api/order/razorpay |
Place order via Razorpay |
| POST | /api/order/userorders |
Get user's orders |
| POST | /api/order/list |
List all orders (Admin) |
| POST | /api/order/status |
Update order status (Admin) |
ApnaStore is deployed on Vercel.
cd client
vercelcd server
vercelπ‘ Make sure to add all environment variables in your Vercel project's Settings β Environment Variables panel.
To access the admin panel, navigate to /admin and log in using the credentials set in your .env:
Email: ADMIN_EMAIL (from .env)
Password: ADMIN_PASSWORD (from .env)
{
"bcryptjs": "^3.0.3",
"cloudinary": "^2.5.1",
"cors": "^2.8.5",
"dotenv": "^16.4.7",
"express": "^4.21.2",
"jsonwebtoken": "^9.0.2",
"mongoose": "^7.8.0",
"multer": "^1.4.5-lts.1",
"nodemon": "^3.1.9",
"razorpay": "^2.9.5",
"stripe": "^17.5.0",
"validator": "^13.12.0"
}{
"axios": "^1.7.9",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-router-dom": "^6.27.0",
"react-toastify": "^10.0.6"
}Pull requests are welcome! For major changes, please open an issue first to discuss what you'd like to change.
- Fork the repo
- Create your feature branch:
git checkout -b feature/amazing-feature - Commit your changes:
git commit -m 'Add some amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Open a Pull Request
This project is licensed under the MIT License.