Common Development Tasks¶
Step-by-step guides for recurring development workflows.
Task 1: Adding a New Component Type¶
Scenario: You want to add a new category of RF components (e.g., "phase_shifter")
Steps¶
-
Create backend database directory:
-
Add component JSON files:
// backend/categorized_databases/phase_shifter/1_6ghz/HMC939.json { "part_number": "HMC939", "manufacturer": "Analog Devices", "type": "phase_shifter", "frequency_min_ghz": 0.5, "frequency_max_ghz": 6.0, "phase_shift_deg": 360, "insertion_loss_db": 4.5, "datasheet_url": "https://www.analog.com/...", "package": "QFN-16", "price_usd": 15.50, "in_stock": true } -
Update category index:
-
Create AI agent (optional but recommended):
# backend/agents/simple_phase_shifter_agent.py from typing import List, Dict from .base_agent import BaseAgent class SimplePhaseShifterAgent(BaseAgent): def select(self, requirements: Dict, candidates: List[Dict]) -> Dict: # Selection logic with scoring scores = [] for component in candidates: score = self._calculate_score(component, requirements) scores.append((component, score)) # Sort by score and return best match best = sorted(scores, key=lambda x: x[1], reverse=True)[0] return best[0] def _calculate_score(self, component: Dict, requirements: Dict) -> float: frequency_score = self._score_frequency_match(component, requirements) phase_score = self._score_phase_range(component, requirements) return frequency_score * 0.6 + phase_score * 0.4 -
Add frontend selection service:
// frontend/src/services/component/phaseShifter/phaseShifterSelection.ts import { Component, SelectionRequirements } from '../../../types/rfComponents'; export const selectPhaseShifter = ( candidates: Component[], requirements: SelectionRequirements ): Component | null => { const filtered = candidates.filter(c => c.frequency_min_ghz <= requirements.frequency && c.frequency_max_ghz >= requirements.frequency && c.phase_shift_deg >= requirements.minPhaseShift ); if (filtered.length === 0) return null; // Score and select best match const scored = filtered.map(c => ({ component: c, score: calculatePhaseShifterScore(c, requirements) })); return scored.sort((a, b) => b.score - a.score)[0].component; }; -
Test:
Task 2: Modifying Component Selection Logic¶
Scenario: You want to adjust PA selection to prioritize efficiency over cost
Steps¶
-
Edit the AI agent:
-
Test with custom weights:
-
Verify results in FastAPI docs at http://localhost:8000/docs
Task 3: Adding a New Export Format¶
Scenario: You want to export to Altium Designer format
Steps¶
-
Create export utility:
# backend/utils/altium_export.py from typing import Dict, List import json class AltiumExporter: def __init__(self, rf_chain: Dict): self.rf_chain = rf_chain def export(self) -> bytes: """Generate Altium .PcbDoc format (simplified example)""" altium_data = self._convert_to_altium_format() return self._serialize(altium_data) def _convert_to_altium_format(self) -> Dict: # Conversion logic pass -
Add route:
# backend/routes/exports.py from ..utils.altium_export import AltiumExporter @router.post("/altium") async def export_altium(rf_chain: dict): try: exporter = AltiumExporter(rf_chain) altium_file = exporter.export() return Response( content=altium_file, media_type="application/octet-stream", headers={"Content-Disposition": "attachment; filename=rf_module.PcbDoc"} ) except Exception as e: logger.error(f"Altium export failed: {e}") raise HTTPException(status_code=500, detail=str(e)) -
Create frontend service:
// frontend/src/services/export/altiumExportService.ts import axios from 'axios'; export const exportToAltium = async (rfChain: any): Promise<Blob> => { const response = await axios.post( `${import.meta.env.VITE_FASTAPI_URL}/api/exports/altium`, rfChain, { responseType: 'blob' } ); return response.data; }; -
Add UI button in export component
Task 4: Updating PCB Stackup Logic¶
Scenario: Add support for PTFE-based materials
Steps¶
-
Add material to database:
-
Update impedance calculations:
// frontend/src/utils/impedance/impedanceCalculatorUtils.ts export const calculateMicrostripImpedance = ( width: number, height: number, dk: number, frequency: number // Add frequency-dependent dk for PTFE ): number => { // Update calculation for PTFE's unique characteristics const effectiveDk = calculateEffectiveDk(dk, width, height, frequency); // ... rest of calculation }; -
Update type definitions if needed:
-
Test calculations with PTFE materials
Task 5: Adding Documentation¶
Scenario: Document a new feature
Steps¶
-
User guide (for end users):
-
Technical documentation (for developers):
-
Update main documentation index:
-
API documentation: Auto-generated by FastAPI at
/docsendpoint