|
| 1 | +--- |
| 2 | +title: Internal Part Number (IPN) Generation |
| 3 | +layout: default |
| 4 | +parent: Usage |
| 5 | +nav_order: 12 |
| 6 | +--- |
| 7 | + |
| 8 | +# Internal Part Number (IPN) Generation |
| 9 | + |
| 10 | +Part-DB supports automatic generation and management of Internal Part Numbers (IPNs) for your parts. IPNs are unique identifiers that help you organize and track your inventory in a structured way. |
| 11 | + |
| 12 | +1. TOC |
| 13 | +{:toc} |
| 14 | + |
| 15 | +## What is an IPN? |
| 16 | + |
| 17 | +An Internal Part Number (IPN) is a unique identifier assigned to each part in your inventory. Unlike manufacturer part numbers (MPNs), IPNs are defined and controlled by you, following your own naming conventions and organizational structure. |
| 18 | + |
| 19 | +IPNs are useful for: |
| 20 | +- Creating a consistent numbering scheme across your entire inventory |
| 21 | +- Organizing parts hierarchically based on categories |
| 22 | +- Quickly identifying and locating parts |
| 23 | +- Generating barcodes for parts |
| 24 | +- Integrating with external systems (like EDA tools) |
| 25 | + |
| 26 | +## Basic Concepts |
| 27 | + |
| 28 | +### IPN Structure |
| 29 | + |
| 30 | +An IPN typically consists of several components: |
| 31 | +- **Prefix**: Identifies the category or type of part (e.g., "RES" for resistors, "CAP" for capacitors) |
| 32 | +- **Separator**: Divides different parts of the IPN (default is `-`) |
| 33 | +- **Number**: A sequential number that makes the IPN unique |
| 34 | + |
| 35 | +Example: `RES-0001`, `CAP-IC-0042`, `MCU-ARM-1234` |
| 36 | + |
| 37 | +### Category-Based IPN Prefixes |
| 38 | + |
| 39 | +Categories in Part-DB can have their own IPN prefix. When creating a new part in a category, Part-DB can automatically suggest IPNs based on the category's prefix. |
| 40 | + |
| 41 | +To set an IPN prefix for a category: |
| 42 | +1. Navigate to the category edit page |
| 43 | +2. Find the "Part IPN Prefix" field |
| 44 | +3. Enter your desired prefix (e.g., "RES", "CAP", "IC") |
| 45 | + |
| 46 | +### Hierarchical Prefixes |
| 47 | + |
| 48 | +Part-DB supports hierarchical IPN generation based on parent categories. For example: |
| 49 | +- Parent category "IC" with prefix "IC" |
| 50 | +- Child category "Microcontrollers" with prefix "MCU" |
| 51 | +- Generated IPN could be: `IC-MCU-0001` |
| 52 | + |
| 53 | +This allows you to create deeply nested categorization schemes while maintaining clear IPNs. |
| 54 | + |
| 55 | +## Configuring IPN Generation |
| 56 | + |
| 57 | +You can configure IPN generation in the system settings under `Tools -> System -> Settings -> Miscellaneous -> IPN Suggest Settings`. |
| 58 | + |
| 59 | +### Available Settings |
| 60 | + |
| 61 | +#### Regex Pattern |
| 62 | +Define a regular expression pattern that valid IPNs must match. This helps enforce consistency across your inventory. |
| 63 | + |
| 64 | +Example: `^[A-Za-z0-9]{3,4}(?:-[A-Za-z0-9]{3,4})*-\d{4}$` |
| 65 | + |
| 66 | +This pattern requires: |
| 67 | +- 3-4 alphanumeric characters for prefixes |
| 68 | +- Optional additional prefix groups separated by `-` |
| 69 | +- Ending with a 4-digit number |
| 70 | + |
| 71 | +#### Regex Help Text |
| 72 | +Provide custom help text that explains your IPN format to users. This text is shown when users are creating or editing parts. |
| 73 | + |
| 74 | +#### Auto-Append Suffix |
| 75 | +When enabled, Part-DB automatically appends a suffix (`_1`, `_2`, etc.) to IPNs that would otherwise be duplicates. This prevents IPN collisions when multiple parts might generate the same IPN. |
| 76 | + |
| 77 | +**Example:** |
| 78 | +- First part: `RES-0001` |
| 79 | +- Duplicate attempt: automatically becomes `RES-0001_1` |
| 80 | +- Next duplicate: automatically becomes `RES-0001_2` |
| 81 | + |
| 82 | +#### Suggest Part Digits |
| 83 | +Defines how many digits should be used for the sequential part number (default: 4). |
| 84 | +- 4 digits: `0001` to `9999` |
| 85 | +- 6 digits: `000001` to `999999` |
| 86 | + |
| 87 | +#### Use Duplicate Description |
| 88 | +When enabled, Part-DB will suggest the same IPN for parts with identical descriptions. This is useful when you want to track variants of the same component with the same IPN scheme. |
| 89 | + |
| 90 | +#### Fallback Prefix |
| 91 | +The prefix to use when a category has no IPN prefix defined (default: `N.A.`). This ensures all parts can get an IPN suggestion even without category-specific prefixes. |
| 92 | + |
| 93 | +#### Number Separator |
| 94 | +The character that separates the prefix from the number (default: `-`). |
| 95 | + |
| 96 | +Example: With separator `-`, you get `RES-0001`. With separator `.`, you get `RES.0001`. |
| 97 | + |
| 98 | +#### Category Separator |
| 99 | +The character that separates hierarchical category prefixes (default: `-`). |
| 100 | + |
| 101 | +Example: With separator `-`, you get `IC-MCU-0001`. With separator `.`, you get `IC.MCU.0001`. |
| 102 | + |
| 103 | +#### Global Prefix |
| 104 | +An optional prefix that is prepended to all IPNs in your system. Useful if you want to distinguish your inventory from other systems. |
| 105 | + |
| 106 | +Example: With global prefix `ACME`, IPNs become `ACME-RES-0001`, `ACME-CAP-0042`, etc. |
| 107 | + |
| 108 | +## Using IPN Suggestions |
| 109 | + |
| 110 | +### When Creating a New Part |
| 111 | + |
| 112 | +When you create a new part, Part-DB provides IPN suggestions based on: |
| 113 | + |
| 114 | +1. **Global Prefix** (if configured): Suggestions using your global prefix |
| 115 | +2. **Description Matching** (if enabled): If another part has the same description, its IPN is suggested |
| 116 | +3. **Direct Category Prefix**: The IPN prefix of the part's assigned category |
| 117 | +4. **Hierarchical Prefixes**: IPNs combining parent category prefixes with the current category |
| 118 | + |
| 119 | +Each suggestion includes: |
| 120 | +- The suggested IPN |
| 121 | +- A description of how it was generated |
| 122 | +- An auto-incremented version (ending with the next available number) |
| 123 | + |
| 124 | +### IPN Suggestion Types |
| 125 | + |
| 126 | +#### Common Prefixes |
| 127 | +These show just the prefix part without a number. Use these as a starting point to manually add your own number. |
| 128 | + |
| 129 | +Example: `RES-` (you then type `RES-1234`) |
| 130 | + |
| 131 | +#### Prefixes with Part Increment |
| 132 | +These show complete IPNs with automatically incremented numbers. The system finds the highest existing number with that prefix and suggests the next one. |
| 133 | + |
| 134 | +Example: If `RES-0001` through `RES-0005` exist, the system suggests `RES-0006`. |
| 135 | + |
| 136 | +### Manual IPN Entry |
| 137 | + |
| 138 | +You can always manually enter any IPN you want. If you've configured a regex pattern, Part-DB will validate your IPN against it and show an error if it doesn't match. |
| 139 | + |
| 140 | +## IPN Uniqueness |
| 141 | + |
| 142 | +IPNs must be unique across your entire Part-DB instance. Part-DB enforces this constraint: |
| 143 | + |
| 144 | +- When manually entering an IPN, you'll see an error if it already exists |
| 145 | +- When auto-append suffix is enabled, duplicate IPNs are automatically made unique |
| 146 | +- Existing parts retain their IPNs even if you change their category |
| 147 | + |
| 148 | +## IPNs in Labels and Barcodes |
| 149 | + |
| 150 | +IPNs can be used in label templates through placeholders: |
| 151 | + |
| 152 | +- `[[IPN]]` - The IPN as text |
| 153 | +- `[[IPN_BARCODE_C39]]` - IPN as Code 39 barcode |
| 154 | +- `[[IPN_BARCODE_C128]]` - IPN as Code 128 barcode |
| 155 | +- `[[IPN_BARCODE_QR]]` - IPN as QR code |
| 156 | + |
| 157 | +See the [Labels documentation]({% link usage/labels.md %}) for more information. |
| 158 | + |
| 159 | +## IPNs in Barcode Scanning |
| 160 | + |
| 161 | +Part-DB can scan barcodes containing IPNs to quickly find parts. When a barcode is scanned, Part-DB: |
| 162 | +1. Attempts to parse it as an IPN |
| 163 | +2. Searches for the part with that IPN |
| 164 | +3. Displays the part information |
| 165 | + |
| 166 | +This enables quick inventory operations using barcode scanners. |
| 167 | + |
| 168 | +## IPNs in EDA Integration |
| 169 | + |
| 170 | +When using Part-DB with EDA tools like KiCad, the IPN is automatically added to the component fields as "Part-DB IPN". This creates a direct link between your schematic components and your Part-DB inventory. |
| 171 | + |
| 172 | +See the [EDA Integration documentation]({% link usage/eda_integration.md %}) for more information. |
| 173 | + |
| 174 | +## Best Practices |
| 175 | + |
| 176 | +### Choosing Prefixes |
| 177 | + |
| 178 | +- **Keep them short**: 2-4 characters work well (e.g., "RES", "CAP", "IC") |
| 179 | +- **Make them memorable**: Use abbreviations that are obvious (avoid "XYZ" or "ABC") |
| 180 | +- **Be consistent**: Use the same style across all categories (all caps or all lowercase) |
| 181 | +- **Avoid ambiguity**: Don't use similar prefixes like "IC" and "1C" |
| 182 | + |
| 183 | +### Numbering Schemes |
| 184 | + |
| 185 | +- **Pad with zeros**: Use leading zeros for cleaner sorting (0001, 0042 instead of 1, 42) |
| 186 | +- **Leave room for growth**: If you have 50 parts now, use 4 digits (up to 9999) instead of 2 |
| 187 | +- **Don't encode information**: Let the prefix and category do the work, not the number |
| 188 | +- **Sequential is fine**: You don't need gaps - 0001, 0002, 0003 is perfectly valid |
| 189 | + |
| 190 | +### Hierarchical Categories |
| 191 | + |
| 192 | +- **Limit depth**: 2-3 levels is usually sufficient (IC-MCU vs IC-MCU-ARM-STM32) |
| 193 | +- **Balance specificity**: More levels = longer IPNs but more precise categorization |
| 194 | +- **Consider searching**: Very specific categories are harder to search across |
| 195 | + |
| 196 | +### Changing Your Scheme |
| 197 | + |
| 198 | +- **Plan ahead**: Changing IPN schemes later is difficult |
| 199 | +- **Document your convention**: Add your IPN format to your regex help text |
| 200 | +- **Existing parts**: Don't feel obligated to renumber existing parts if you change schemes |
| 201 | +- **Migration**: Use import/export to batch-update IPNs if needed |
| 202 | + |
| 203 | +## Common Issues and Solutions |
| 204 | + |
| 205 | +### "IPN already exists" |
| 206 | + |
| 207 | +**Problem**: You're trying to use an IPN that's already assigned to another part. |
| 208 | + |
| 209 | +**Solutions**: |
| 210 | +- Choose a different number |
| 211 | +- Enable "Auto-Append Suffix" to automatically handle duplicates |
| 212 | +- Search for the existing part to see if it's a duplicate you should merge |
| 213 | + |
| 214 | +### "IPN doesn't match regex pattern" |
| 215 | + |
| 216 | +**Problem**: Your IPN doesn't follow the configured format. |
| 217 | + |
| 218 | +**Solutions**: |
| 219 | +- Check the regex help text to understand the expected format |
| 220 | +- Contact your administrator if the regex is too restrictive |
| 221 | +- Use the suggested IPNs which are guaranteed to match |
| 222 | + |
| 223 | +### Suggestions not showing |
| 224 | + |
| 225 | +**Problem**: IPN suggestions are empty or not appearing. |
| 226 | + |
| 227 | +**Solutions**: |
| 228 | +- Ensure the part has a category assigned |
| 229 | +- Check that the category has an IPN prefix defined |
| 230 | +- Verify that a fallback prefix is configured in settings |
| 231 | +- Save the part first before getting suggestions (for new parts) |
| 232 | + |
| 233 | +### Wrong prefix being suggested |
| 234 | + |
| 235 | +**Problem**: Part-DB suggests an IPN with the wrong prefix. |
| 236 | + |
| 237 | +**Solutions**: |
| 238 | +- Check the part's category - suggestions are based on the assigned category |
| 239 | +- Verify parent categories and their prefixes if using hierarchical structure |
| 240 | +- Set the correct IPN prefix in the category settings |
| 241 | +- Use manual entry with your desired prefix |
| 242 | + |
| 243 | +## Example Scenarios |
| 244 | + |
| 245 | +### Simple Electronic Components Inventory |
| 246 | + |
| 247 | +**Setup**: |
| 248 | +- Categories: Resistors, Capacitors, ICs, etc. |
| 249 | +- Prefixes: RES, CAP, IC |
| 250 | +- 4-digit numbering |
| 251 | + |
| 252 | +**Results**: |
| 253 | +- `RES-0001` - 10kΩ resistor |
| 254 | +- `CAP-0001` - 100nF capacitor |
| 255 | +- `IC-0001` - ATmega328 |
| 256 | + |
| 257 | +### Professional Lab with Detailed Categories |
| 258 | + |
| 259 | +**Setup**: |
| 260 | +- Hierarchical categories: Components > Passive > Resistors > Surface Mount |
| 261 | +- Prefixes: COMP, PAS, RES, SMD |
| 262 | +- Global prefix: LAB |
| 263 | +- 6-digit numbering |
| 264 | + |
| 265 | +**Results**: |
| 266 | +- `LAB-COMP-PAS-RES-SMD-000001` - 0805 10kΩ resistor |
| 267 | +- `LAB-COMP-PAS-CAP-SMD-000001` - 0805 100nF capacitor |
| 268 | + |
| 269 | +### Makerspace with Mixed Inventory |
| 270 | + |
| 271 | +**Setup**: |
| 272 | +- Categories for electronics, mechanical parts, tools |
| 273 | +- Simple prefixes: ELEC, MECH, TOOL |
| 274 | +- Fallback prefix for miscellaneous: MISC |
| 275 | +- 4-digit numbering |
| 276 | + |
| 277 | +**Results**: |
| 278 | +- `ELEC-0001` - Arduino Uno |
| 279 | +- `MECH-0001` - M3 screw set |
| 280 | +- `TOOL-0001` - Soldering iron |
| 281 | +- `MISC-0001` - Cable ties |
| 282 | + |
| 283 | +## Environment Variables |
| 284 | + |
| 285 | +IPN settings can be configured via environment variables (useful for Docker deployments): |
| 286 | + |
| 287 | +- `IPN_SUGGEST_REGEX` - Override the regex pattern |
| 288 | +- `IPN_SUGGEST_REGEX_HELP` - Override the regex help text |
| 289 | +- `IPN_AUTO_APPEND_SUFFIX` - Enable/disable auto-append suffix (boolean) |
| 290 | +- `IPN_SUGGEST_PART_DIGITS` - Number of digits for part numbers (integer) |
| 291 | +- `IPN_USE_DUPLICATE_DESCRIPTION` - Enable/disable duplicate description matching (boolean) |
| 292 | + |
| 293 | +Example in docker-compose.yaml: |
| 294 | +```yaml |
| 295 | +environment: |
| 296 | + IPN_SUGGEST_REGEX: "^[A-Z]{3}-\d{4}$" |
| 297 | + IPN_AUTO_APPEND_SUFFIX: "true" |
| 298 | + IPN_SUGGEST_PART_DIGITS: "4" |
| 299 | +``` |
| 300 | +
|
| 301 | +## Related Documentation |
| 302 | +
|
| 303 | +- [Getting Started]({% link usage/getting_started.md %}) - Initial setup guide |
| 304 | +- [Concepts]({% link concepts.md %}) - Understanding Part-DB concepts |
| 305 | +- [Labels]({% link usage/labels.md %}) - Using IPNs in labels |
| 306 | +- [EDA Integration]({% link usage/eda_integration.md %}) - IPNs in electronic design tools |
0 commit comments