Skip to content

Lg007-git/invento_management

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Here's a complete `README.md` for your **Inventory Management Web App** project. It includes everything from **tech stack**, **features**, **setup**, **flow**, **issues solved**, and **future updates**.

---

```md
# 🧾 Inventory Management Web App

A full-stack inventory management system with role-based access. Users can register/login, view their own products, and optionally enter admin (CRUD) mode to add, update, or delete items β€” including image upload via Cloudinary.

---

## πŸ”§ Tech Stack Used

### πŸ”Ή Frontend:
- **React.js** – SPA with responsive design
- **Material-UI (MUI)** – UI components
- **Axios** – API requests
- **React Router DOM** – Routing

### πŸ”Ή Backend:
- **Node.js + Express** – Server-side framework
- **MongoDB + Mongoose** – Database and modeling
- **JWT (jsonwebtoken)** – Auth tokens
- **Multer** – Handling file uploads
- **Cloudinary** – Storing product images
- **CORS** – Secure cross-origin requests

---

## ✨ Features

- πŸ” User registration & login (JWT based)
- πŸ‘€ User-specific product inventory
- πŸ”’ Admin (CRUD) mode protected with a second password
- πŸ–ΌοΈ Image upload using Cloudinary
- πŸ“¦ Product listing with details: name, price, option, and image
- πŸ“² Fully mobile responsive
- 🌐 Frontend hosted on **Vercel**, backend on **Render**

---

## πŸ”„ Flow of the Application

1. **User visits app** β†’ lands on login page.
2. **Registers or logs in** β†’ gets JWT token stored in localStorage.
3. **Dashboard loads** β†’ user sees their product list.
4. **Wants to edit/add/delete?** β†’ Enters Admin Mode by submitting CRUD password.
5. **In Admin Mode**:
   - Can add product (name, price, option, image)
   - Product image uploaded to **Cloudinary**
   - Product is saved in MongoDB with user ID
6. **Logout** β†’ Tokens cleared from localStorage.

---

## 🧠 Key Decisions & Why

### πŸ“€ Image Upload: Multer + Cloudinary
- **Multer** used to handle form-data and temporarily store file.
- **Cloudinary** used for hosting images (secure, fast CDN, easy APIs).
- After upload, the local file is removed using `fs.unlinkSync()`.

### πŸ›‘οΈ CRUD Mode
- Separate password layer even after login.
- CRUD token issued only when valid password is entered.
- Secure operations like update/delete/add product are protected.

### 🧭 Deployment
- **Frontend** on **Vercel**: Free, fast CI/CD for React apps.
- **Backend** on **Render**: Simple setup, good free tier for APIs.

---

## ⚠️ Problems Faced & Solutions

| Problem | Solution |
|--------|----------|
| Product added but not visible without refresh | Used state update callback `onProductAdded()` to update UI immediately |
| Cloudinary upload success but image not showing | Ensured correct image URL is saved and used directly (not prefixed with localhost) |
| Image not uploaded to Cloudinary | Ensured multer middleware ran before controller, and `req.file.path` used for upload |
| CORS errors on frontend | Whitelisted frontend URL on backend with full CORS setup |
| Refreshing backend deletes uploads/ folder | Solved by using Cloudinary for permanent storage |

---

## πŸ“ Folder Structure (Important Parts)

```

/frontend
└── src
β”œβ”€β”€ pages/
β”‚    └── Dashboard.js
β”œβ”€β”€ components/
β”‚    β”œβ”€β”€ AddProduct.js
β”‚    β”œβ”€β”€ Cards.js
└── App.js

/backend
β”œβ”€β”€ controllers/
β”‚    └── productController.js
β”œβ”€β”€ middleware/
β”‚    └── authMiddleware.js
β”œβ”€β”€ models/
β”‚    └── Products.js
β”œβ”€β”€ routes/
β”‚    └── productRoutes.js
β”œβ”€β”€ config/
β”‚    └── cloudinaryConfig.js
└── server.js

````

---

## πŸš€ How to Run Locally

### πŸ”§ Prerequisites:
- Node.js, npm
- MongoDB (local or Atlas)
- Cloudinary account

### πŸ”¨ Backend Setup

```bash
cd backend
npm install
````

Create `.env`:

```env
PORT=5000
MONGO_URI=<your_mongodb_uri>
JWT_SECRET=<your_jwt_secret>
CLOUDINARY_CLOUD_NAME=<your_cloud_name>
CLOUDINARY_API_KEY=<your_api_key>
CLOUDINARY_API_SECRET=<your_api_secret>
```

Run server:

```bash
node server.js
```

---

### 🌐 Frontend Setup

```bash
cd frontend
npm install
npm start
```

---

## 🌍 Deployment

### 🧩 Backend (Render)

* Create new Web Service
* Add environment variables
* Use `node server.js` as start command
* Add CORS: allow frontend Vercel URL

### πŸ“¦ Frontend (Vercel)

* Connect GitHub repo
* Set framework = React
* Ensure API URL in Axios is updated to Render domain

---

## πŸ’‘ Future Updates

* βœ… Edit/Delete products (UI + backend already set)
* 🧾 Sort/filter by category/price
* πŸ–ΌοΈ Live camera capture for product image
* πŸ” User roles (admin/user)
* πŸ“Š Stats & charts for product count
* ⏳ Pagination for large inventories

---

## πŸ™Œ Acknowledgements

* [Cloudinary](https://cloudinary.com/)
* [Render](https://render.com/)
* [Vercel](https://vercel.com/)
* [MUI](https://mui.com/)

---

## πŸ“¬ Contact

**Developer:** Lalit Gupta
GitHub: [@Lg007-git](https://github.com/Lg007-git)

---

```

Let me know if you want a second version with badges, screenshots, or a PDF export.
```

Releases

Packages

Contributors

Languages