Component Search Engine Integration - bglen/wire-harness-core GitHub Wiki

Below is a rough outline of how these features might be implemented:

๐Ÿ“ฆ External Parts Search Integration Guide

Integrate real-time electronic parts search and import features into your wire harness design tool. This feature enables users to find and add manufacturer-verified parts directly to the internal library.wh_lib component database.


๐ŸŽฏ Goals

  • Search: Enable part lookup via keywords, MPN, or category.
  • Preview: Display real-time part data (image, specs, pricing, etc.).
  • Import: Let users import part metadata into your library structure.
  • Maintain: Support multiple sources with fallback and rate limiting.

๐Ÿ”Œ Data Source APIs

Octopart API

  • URL: https://octopart.com/api/v4/
  • Auth: API key (free tier available)
  • Features: Rich metadata, pricing, distributor links, datasheets
  • Docs: https://octopart.com/api/

Findchips API

Digi-Key API

Mouser API


๐ŸŒ Backend Proxy Architecture

Avoid exposing API keys to the frontend by routing all external API calls through a backend proxy.

Example Node.js (Express) Route

app.get('/api/parts-search', async (req, res) => {
  const { query } = req.query;
  const response = await fetch(`https://octopart.com/api/v4/parts/search?q=${query}&apikey=YOUR_KEY`);
  const data = await response.json();
  res.json(data);
});

Proxy Server Responsibilities

  • Handle API authentication (keys, OAuth)
  • Rate limit and cache requests
  • Normalize results from multiple sources

๐Ÿง  Frontend Integration

UI Components

  • Search Input: Keyword or MPN with debounce
  • Result Panel: Shows name, MPN, manufacturer, preview image, specs, pricing, datasheet
  • Import Button: Maps selected part into library.wh_lib

Example Component Import Format

{
  "type": "connector_shell",
  "mpn": "TE-282834-2",
  "manufacturer": "TE Connectivity",
  "name": "Superseal 2 Position",
  "datasheet": "https://www.te.com/...pdf",
  "footprint": "2pos_superseal.stp",
  "price": {
    "1": 0.93,
    "100": 0.74
  },
  "distributors": {
    "digikey": "https://www.digikey.com/en/products/detail/.../123456",
    "mouser": "https://www.mouser.com/ProductDetail/.../654321"
  }
}

๐Ÿ—‚ Mapping to library.wh_lib

Create a part mapping module that translates external part data into your internal component schema. Fields may include:

  • mpn, manufacturer, description
  • component_type (e.g., terminal, connector, shell)
  • package, footprint, library_name
  • datasheet_url, distributor_links
  • price_tiers, available_stock

๐Ÿงช Optional Enhancements

  • ๐Ÿ” Recent Search History
  • โญ Favorite Parts / Preferred Distributors
  • ๐Ÿ’ต Price Comparison Table
  • ๐Ÿ“Ž Attach STEP / footprint files
  • ๐Ÿง  Auto-category detection (via Octopart taxonomy)

โš ๏ธ Implementation Notes

  • Caching: Store common lookups (e.g. Redis, localStorage)
  • Rate Limiting: Use throttling on both client and server
  • Error Handling: Fallback gracefully across APIs
  • Licensing: Ensure TOS compliance for each API

โœ… Summary Workflow

  1. User searches for part
  2. Backend fetches data from Octopart / Mouser / etc.
  3. Frontend displays parts with import preview
  4. User clicks "Import" โ†’ component added to library.wh_lib

๐Ÿ“Ž Resources