Streamline Electronic Component Sourcing, Optimize Costs, and Mitigate Supply Chain Risks during New Product Introduction (NPI).
- General Info
- White Paper
- Technologies Used
- Features
- Screenshots
- Setup
- Usage
- Project Status
- Contact
- License
The BOM Analyzer is a Python-based desktop application designed to automate the time-consuming process of analyzing Bill of Materials (BOMs) for new electronic products. It integrates directly with major supplier APIs to fetch real-time pricing, stock, and lead time data, calculates optimal purchasing strategies, assesses multi-factor risks, provides predictive insights, and generates AI-powered summaries to support faster, data-driven decision-making.
- Core: Python 3
- GUI: Tkinter, ttk (Standard Library)
- Data Handling: Pandas, NumPy
- API Communication: Requests
- Authentication: python-dotenv, http.server, ssl (for DigiKey OAuth)
- Prediction: Prophet (via
prophetlibrary) - AI Summary: OpenAI (
openailibrary) - Visualization: Matplotlib, Seaborn
- Packaging (Optional): PyInstaller (for creating executables)
- Automated Data Aggregation: Fetches real-time data (pricing tiers, stock, lead time, COO, HTS, lifecycle) via official APIs (Digi-Key, Mouser, Octopart/Nexar, Arrow, Avnet).
- BOM Import & Validation: Loads CSV BOMs, handles common column names, cleans basic data.
- Optimal Cost Calculation: Determines lowest total cost considering MOQs and price breaks, including optional "buy-up" logic.
- Multiple Sourcing Strategies: Calculates and compares Lowest Cost (Strict, In Stock, w/ LT), Fastest, and a user-configurable Optimized strategy (balancing cost/lead time).
- Multi-Factor Risk Assessment: Scores each part (0-10) based on sourcing depth, stock, lead time, lifecycle, and geographic origin. Visually highlights risk levels.
- Tariff Estimation: Incorporates custom tariff rates or attempts USITC HTS code lookup for estimated duty costs.
- Predictive Analytics: Uses historical data (locally saved) and the Prophet library to forecast future cost and lead time trends. Allows tracking actuals vs. predictions.
- AI-Powered Summary (OpenAI): Generates concise executive summaries, highlights critical risks (EOL, Unknown Parts, Stock Gaps), and provides actionable recommendations using GPT models.
- Data Export: Exports analysis results and calculated purchasing strategies to CSV files.
- Interactive GUI: Built with Tkinter/ttk, featuring sortable tables, tabbed results, interactive plots (powered by Matplotlib/Seaborn), and integrated tooltips.
-
Clone the Repository:
git clone [Your GitHub Repository URL] cd bom-analyzer # Or your repository name
-
Create a Virtual Environment (Recommended):
python -m venv venv source venv/bin/activate # On Windows use `venv\Scripts\activate`
-
Install Dependencies:
- Prophet installation can sometimes require specific C++ build tools. Refer to the official Prophet installation guide if you encounter issues.
- Install libraries from
requirements.txt:(You need to generatepip install -r requirements.txt
requirements.txtusingpip freeze > requirements.txtin your activated virtual environment)
-
API Keys (
keys.envfile):- Create a file named
keys.envin the main project directory (wheretest_local.pyresides). - Add your API keys in the following format:
# DigiKey API Credentials (OAuth - Required for DigiKey Search/Substitutions) DIGIKEY_CLIENT_ID=YOUR_DIGIKEY_CLIENT_ID DIGIKEY_CLIENT_SECRET=YOUR_DIGIKEY_CLIENT_SECRET # Mouser API Key (Required for Mouser Search) MOUSER_API_KEY=YOUR_MOUSER_API_KEY # Nexar/Octopart API Credentials (OAuth - Required for Octopart Search) NEXAR_CLIENT_ID=YOUR_NEXAR_CLIENT_ID NEXAR_CLIENT_SECRET=YOUR_NEXAR_CLIENT_SECRET # OpenAI API Key (Optional - Required for AI Summary Feature) OPENAI_API_KEY=YOUR_OPENAI_API_KEY # Arrow API Key (Optional - Not fully implemented yet) ARROW_API_KEY=YOUR_ARROW_API_KEY # Avnet API Key (Optional - Not fully implemented yet) AVNET_API_KEY=YOUR_AVNET_API_KEY
- Important: Ensure the Redirect URI for your DigiKey App registration is set to
https://localhost:8000.
- Create a file named
-
DigiKey OAuth Certificate (
localhost.pem):- The DigiKey API requires a local HTTPS server for the OAuth callback. You need a self-signed certificate.
- If you have
opensslinstalled, you can generate one using a command like this in your terminal (run from the project directory):openssl req -x509 -newkey rsa:4096 -keyout localhost.pem -out localhost.pem -sha256 -days 3650 -nodes -subj "/C=US/ST=State/L=City/O=Organization/OU=Unit/CN=localhost" - This creates
localhost.pemcontaining both the key and certificate, valid for 10 years. Place this file in the same directory as the script.
-
Run the Application:
python BOM_Analyzer.py
(Ensure your virtual environment is activated)
-
Load BOM: Click "Load BOM..." and select your CSV file. Ensure it has 'Part Number' and 'Quantity' columns.
-
Configure Analysis: Adjust 'Total Units to Build' and other parameters in the 'Optimized Strategy Configuration' and 'Custom Tariff Rates' sections.
-
Run Analysis: Click "1. Run Analysis". API data will be fetched (may require browser interaction for first-time DigiKey OAuth).
-
Review Results:
- BOM Analysis Tab: Examine the main table (sortable columns) and the summary metrics. Double-click rows for alternates.
- AI & Predictions Tab:
- Click "3. AI Summary" (if OpenAI key is configured) to view AI recommendations in the top box and full details below. Export the recommended strategy using the dedicated button.
- Click "2. Run Predictions" to generate forecasts based on historical data.
- Select rows in the "Predictions vs Actuals" table, enter real-world data, and click "Save" to track accuracy.
- Visualizations Tab: Select plots from the dropdown to visualize results. Hover over points in "Cost vs Lead Time" for details.
-
Export: Use the buttons at the bottom of the "BOM Analysis" or "AI & Predictions" tabs to export data/strategies to CSV.
Project is: complete / In process of prioritizing features on future roadmap.
- Enhanced API integrations (Arrow, Avnet, more distributors).
- Direct ERP/PLM integration for BOM import/export.
- Automated Purchase Order draft generation.
- Advanced AI/ML features (Real RAG, fine-tuning, explainability).
- Accuracy-gated autonomous procurement workflows.
- Potential Web-based/SaaS version.
Created by @ctylerallen - feel free to contact me!
MIT License
Copyright (c) 2025 Tyler Allen
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.


