- RENDER HOSTED so please assume delay around 1 to 2 minute for server to wakeup from sleep
The Inventory Management System is a modern web application developed using React and Vite. It provides a user-friendly interface for performing various inventory management tasks, such as adding new items, deleting existing items, searching for items, and viewing detailed product information.
- Add Items: Easily add new items to the inventory with a few simple clicks.
- Delete Items: Remove unwanted items from the inventory effortlessly.
- Search Functionality: Quickly find items by searching their names.
- Product Details: View detailed information about selected products.
- Pagination Support: Navigate through large inventories with ease using pagination.
To get started with the Inventory Management System, please start go for https://github.com/harrisazmi/inventorymanagementOnlineBE for starting the backend api and then can continue to follow these steps:
-
Clone the Repository:
git clone <repository-url>
-
Navigate to the Project Directory:
cd inventory-management-system -
Edit the Environment Variables:
- Create a
.envfile in the root directory if it doesn't exist. - Add the following line to the
.envfile, replacing<yourbackendhost>with the URL of your backend API:VITE_BACKEND_URL = <yourbackendhost>
- Create a
-
Install Dependencies:
npm install
-
Start the Development Server:
-
I have set up so if you are using LAN, anyone connected to the same network can use what you serve
npm run dev
The development server will start, allowing you to access the Inventory Management System locally at http://localhost:5173.
If you're on a local area network (LAN), other devices connected to the same network can also access the application by using your host machine's IP address and port 3000. For example:
http://<your-ip-address>:5173Replace
<your-ip-address>with the IP address of your host machine where the development server is running. Ensure that your firewall settings allow inbound connections to port 3000 if you're hosting the application over LAN.
- Access the Application: Open your web browser and navigate to http://localhost:5173 to access the Inventory Management System.
You can also run the Inventory Management System using Docker. Follow these steps to build and run the application in a Docker container:
-
Create Dockerfile:
Create a
Dockerfilein the root directory of your project with the following content:FROM node:18 WORKDIR /app COPY package*.json ./ RUN npm install COPY . . EXPOSE 5173 CMD [ "npm", "run", "dev" ]
-
Build Docker Image:
Run the following command to build the Docker image:
docker build -t inventory-management-system . -
Run Docker Container:
Once the image is built, start a Docker container with the following command:
docker run -p 5173:5173 -d inventory-management-system
This command will start the Docker container in detached mode, mapping port 5173 inside the container to port 3000 on your host machine. You can now access the Inventory Management System by navigating to http://localhost:5173 in your web browser.
-
Accessing the Application:
If you're on a local area network (LAN) and want other devices to access the application, replace
localhostwith the IP address of your host machine in the URL. Ensure that your firewall settings allow inbound connections to port 3000.
The Inventory Management System assumes the presence of a backend API for managing inventory. Ensure to specify the base URL of the API using the VITE_BACKEND_URL environment variable.
This repository contains the backend code for an Inventory Management System. It's built using Node.js, Express.js, and MongoDB, providing RESTful API endpoints for managing inventory items and suppliers.
-
Clone the repository to your local machine:
git clone <repository_url>
-
Install dependencies:
cd inventorymanagementOnlineBE npm install -
Set up environment variables:
Create a
.envfile in the root directory and define the following variables:PORT=3001 MONGO_DB_URL=<your_mongodb_connection_string> -
Start the server:
npm run dev
-
(Good Alternative for live server) Nodemon is available for local hosting, so change them in package.json for only the dev part
"scripts" : { "dev": "nodemon index.js" }
Then can Start the server.
npm run dev
You can also run the backend using Docker. Follow these steps:
-
Build the Docker image:
docker build -t inventory-backend . -
Run the Docker container:
docker run -p 3133:3133 -d inventory-backend
This will start the backend server inside a Docker container, exposing port 3133 on your host machine.
- GET /api/inventory: Fetch all inventory items with filtering, sorting, and pagination.
- GET /api/inventory/:id: Get information for a specific inventory item by ID.
- POST /api/inventory: Add a new inventory item.
- DELETE /api/inventory/:id: Delete an inventory item.
- PUT /api/update-inventory/:id: Update an inventory item or supplier.
- POST /api/remove-all-data: Remove all data from the database.
- POST /api/populate-database: Populate the database with at least 1000 rows of random data.
- Inventory: Represents an inventory item with properties such as item name, quantity, and supplier.
- Supplier: Represents a supplier with properties like name, address, and contact information.
- URL:
/api/inventory - Method:
GET - Query Parameters:
sortBy: Sort field (default:itemName)sortOrder: Sort order (default:asc)itemName: Filter by item name (optional)
- Response: Returns an array of inventory items and the total count.
- URL:
/api/inventory/:id - Method:
GET - Parameters:
id(Inventory item ID) - Response: Returns the details of the specified inventory item.
- URL:
/api/inventory - Method:
POST - Body: JSON object containing
itemName,quantity, andsupplierId. - Response: Returns the newly added inventory item.
- URL:
/api/inventory/:id - Method:
PUT - Parameters:
id(Inventory item ID) - Body: JSON object containing updated
itemName,quantity, andsupplierId. - Response: Returns the updated inventory item.
- URL:
/api/inventory/:id - Method:
DELETE - Parameters:
id(Inventory item ID) - Response: Returns a success message upon successful deletion.
- URL:
/api/populate-database - Method:
POST - Response: Populates the database with sample data. (Note: Implementation of this endpoint is pending.)
- URL:
/api/remove-all-data - Method:
POST - Response: Removes all data from the database.
- Express: Web framework for Node.js.
- Mongoose: MongoDB object modeling tool.
- Cors: Middleware for enabling CORS (Cross-Origin Resource Sharing).
- Dotenv: Module for loading environment variables from a .env file.
- Nodemon: Alternative for a live server
Contributions are welcome! If you find any bugs or have suggestions for improvements, please open an issue or submit a pull request.