Lg007-git/invento_management
Folders and files
| Name | Name | Last commit date | ||
|---|---|---|---|---|
Β | Β | |||
Β | Β | |||
Β | Β | |||
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. ```