Group Name: DBLegends
Group Members:
- Lu Li
- Bhavya Jain
- Apoorva Adimulam
- Nivedita Nair
The Inventory Management System leverages machine learning, Flask for the user interface, LLM-based image recognition, and MongoDB as a NoSQL database. This system processes images to identify products, manages inventory data, and provides comprehensive CRUD operations for inventory management.
-
app.py- Main Flask application file.
- Handles routes for processing images, viewing inventory, updating inventory, deleting products, and uploading JSON files.
- Contains MongoDB functions for inserting, updating, and deleting products.
- Uses the
ProductImageProcessorclass for image processing.
-
create_db_with_json.py- Script to create and populate the MongoDB database using a JSON file.
- Drops the existing database and inserts data from
products.json. - Ensures unique indexing on
HashID. - Creates initial batches for every unique product.
-
csv_json_conversion.py- Converts
inventory.csvinto a JSON file namedproducts.json. - Generates
HashIDfor each product based on its name and brand.
- Converts
-
insert_update_from_image.py- Contains the
ProductImageProcessorclass for processing images. - Defines MongoDB functions for generating
HashIDand inserting/updating products. - Processes images to identify products and update the database.
- Adds new batches to existing products or inserts new records for products not found in the database.
- Supports timestamp-based batch tracking.
- Contains the
-
delete_op.py- Contains the
delete_productfunction for deleting records from the database using a combination of product and type.
- Contains the
-
range_query.py- Script to perform range queries on the MongoDB database.
- Creates an index on the
Productfield for faster queries. - Retrieves all items for a specific product.
-
inquiry.py- Script to query the MongoDB database for a specific product.
- Generates
HashIDand retrieves product data based on the hash.
-
dependencies/setup_mongodb_pymongo.sh- Bash script to set up MongoDB and
pymongoon a Linux system. - Installs MongoDB, starts the service, and installs
pymongo.
- Bash script to set up MongoDB and
-
dependencies/LLM_dependencies.sh- Bash script to set up LLM dependencies on a Linux system.
- Installs
transformers,torch(GPU support version), andeinops.
-
dependencies/frontend.sh- Bash script to set up frontend dependencies.
- Installs Flask.
- Python 3.x
- MongoDB
- Flask
pymongolibrarytransformerslibraryPillow(PIL) library
-
Clone the repository:
git clone https://github.com/luliCloud/CMPE180B_Group-project.git cd CMPE180B_group-project/integrate_image_recog_backend_mongodb -
Set up dependencies:
chmod +x dependencies/setup_mongodb_pymongo.sh ./dependencies/setup_mongodb_pymongo.sh chmod +x dependencies/frontend.sh ./dependencies/frontend.sh chmod +x dependencies/LLM_dependencies.sh ./dependencies/LLM_dependencies.sh
Rigorous tests have been written for all key components of the inventory management system.
-
test_app.py- Tests all functions in
app.py, including database creation and CRUD operations.
- Tests all functions in
-
test_db_creation.py- Tests all functions in
create_db_with_json.py. - Verifies normal database creation.
- Tests all functions in
-
test_db_delete.py- Tests the
delete_productfunction indelete_op.py. - Verifies records can be deleted using product and type.
- Tests the
-
test_image_process.py- Tests image processing functions in
insert_update_from_image.py. - Verifies uploaded images can be found in the target directory, and their information is properly recognized and extracted by LLM.
- Tests image processing functions in
-
test_insert_update.py- Tests insert and update functions in
insert_update_from_image.py. - Verifies extracted information is inserted or updated in the database accordingly.
- Tests insert and update functions in
-
test_query_range_index.py- Tests
range_query.pyandinquiry.py. - Verifies second indexes can be created, and both precise and range queries work as expected.
- Tests
- Start the Flask application:
python app.py
- Access the application in a web browser:
http://localhost:5000
-
Create the database using a JSON file:
python3 create_db_with_json.py
-
Insert and update information from newly scanned images:
python3 insert_update_from_image.py
-
Delete records from the database:
python3 delete_op.py
-
Perform precise queries:
python3 inquiry.py
-
Perform range queries:
python3 range_query.py
-
Create second indexes:
python3 range_query.py