inventory-management-system

shereenjohn/inventory-management-system

3.2

If you are the rightful owner of inventory-management-system and would like to certify it and/or have it hosted online, please leave a comment on the right or send an email to henry@mcphub.com.

The Inventory Management System with NLP Interface is a natural language-powered solution for managing inventory data using plain English.

Inventory Management System with NLP Interface

A natural language-powered inventory management system that lets you interact with inventory data using plain English. The system consists of two main components: an Inventory Service (AWS Lambda) and a Model Control Plane (MCP) Server that processes natural language.


✨ Key Features

  • Natural Language Interface: Manage inventory using everyday English.
  • Multi-Operation Support: Handle complex queries like "add 3 shirts and remove 2 pants."
  • Clarification System: Intelligently asks for more information when needed.
  • Serverless Backend: Scalable AWS Lambda-based inventory service.
  • In-Memory Storage: Fast data access with singleton pattern implementation.
  • AI-Powered: Uses OpenAI's GPT models for language understanding.
  • Error Handling: Gracefully manages edge cases like insufficient inventory.
  • OpenAPI Integration: Dynamic API discovery and specification.

šŸ—ļø Project Structure

inventory-management-system/
ā”œā”€ā”€ inventory-service/              # Serverless inventory API
│   ā”œā”€ā”€ src/inventory/app.py        # Lambda function handler
│   ā”œā”€ā”€ template.yaml               # SAM template
│   ā”œā”€ā”€ samconfig.toml              # SAM configuration
│   └── openapi.yaml                # API specification
│
ā”œā”€ā”€ mcp-server/                     # Natural language processor
│   ā”œā”€ā”€ app/
│   │   ā”œā”€ā”€ __init__.py
│   │   ā”œā”€ā”€ main.py                 # FastAPI application
│   │   ā”œā”€ā”€ inventory.py            # Inventory client
│   │   ā”œā”€ā”€ llm_service.py          # OpenAI integration
│   │   ā”œā”€ā”€ openapi_parser.py       # OpenAPI spec parser
│   │   ā”œā”€ā”€ auth.py                 # Authentication handling
│   │   └── utils.py                # Utility functions
│   ā”œā”€ā”€ run.py                      # Server startup
│   ā”œā”€ā”€ ui.py                       # Gradio UI for demo
│   ā”œā”€ā”€ requirements.txt            # Python dependencies
│   └── openapi.yaml                # Copy of API specification
│
ā”œā”€ā”€ openapi.yaml                    # API specification
└── README.md                       # Project documentation

šŸ“‹ Requirements

  • Python 3.9+
  • AWS Account with configured credentials
  • AWS CLI
  • AWS SAM CLI
  • OpenAI API Key
  • FastAPI and Uvicorn
  • httpx for async HTTP requests
  • pydantic for data validation
  • gradio (for optional UI)

šŸ› ļø Technologies Used

  • Backend: Python 3.9+, FastAPI, AWS Lambda, AWS API Gateway, AWS SAM
  • Natural Language Processing: OpenAI GPT-3.5, Regular Expressions
  • API & Documentation: OpenAPI 3.0, YAML
  • Development Tools: httpx, pydantic, python-dotenv, uvicorn, gradio

🧠 Design Approach

  • Serverless Architecture: For scalability and cost-efficiency.
  • Singleton Pattern: For in-memory data storage as required by the project.
  • Hybrid NLP Approach: Regex for common queries and OpenAI GPT for complex phrasings.
  • Clarification System: Handles ambiguous queries.
  • OpenAPI Integration: For dynamic API discovery and specification.
  • Modular Design: Separation of concerns with dedicated modules.

šŸ“ Limitations & Future Improvements

  • Data Persistence: Currently uses in-memory storage; could be extended with a database like DynamoDB.
  • Limited Items: Only tracks t-shirts and pants as specified; can be expanded.
  • Authentication: Basic implementation that could be enhanced for production use.
  • Testing: Could be expanded with comprehensive unit and integration tests.

šŸ“¦ Installation & Setup

Prerequisites

Before starting, ensure you have the following installed:

Step 1: Clone the Repository

git clone https://github.com/shereenjohn/inventory-management-system.git
cd inventory-management-system

Step 2: Deploy the Inventory Service

cd inventory-service

# Build the SAM application

sam build

# Deploy to AWS

sam deploy --guided

Follow the prompts during guided deployment:

Stack Name: inventory-service

AWS Region: Your preferred region

Confirm changes before deployment: Y

Allow SAM CLI to create IAM roles: Y

Important: Note the API endpoint URL from the deployment output. You'll need this for the MCP server.

Step 3: Set Up the MCP Server

cd ../mcp-server

# Install dependencies
pip install -r requirements.txt

# Create .env file with your configuration
# Replace with your actual API URL and OpenAI key
echo "INVENTORY_API_URL=your_api_url" > .env
echo "OPENAI_API_KEY=your_openai_api_key" >> .env

# If using authentication (optional)
echo "COGNITO_TOKEN=your_cognito_token" >> .env
echo "COGNITO_REFRESH_TOKEN=your_refresh_token" >> .env
echo "COGNITO_CLIENT_ID=your_client_id" >> .env
echo "COGNITO_USER_POOL_ID=your_user_pool_id" >> .env
echo "COGNITO_ENDPOINT=https://cognito-idp.us-east-1.amazonaws.com/" >> .env
echo "AWS_REGION=us-east-1" >> .env

# Start the server
python run.py

Step 4: Start the UI

# In a separate terminal
cd mcp-server
python ui.py

# Access UI at http://localhost:7860

šŸ–„ļø Usage Examples

Natural Language Queries You can interact with the system using queries like:

"What is in the inventory?"

"Add 5 pants"

"sold 3 shirts"

"Add 2 shirts and remove 1 pant"

"+5 t-shirts, -3 pants"