shereenjohn/inventory-management-system
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:
- Python 3.9+
- AWS CLI (configured with your credentials)
- AWS SAM CLI
- An OpenAI API key
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"