ieeeColors = ({
navy: "#2C3E50",
teal: "#16A085",
orange: "#E67E22",
gray: "#7F8C8D",
red: "#E74C3C",
green: "#27AE60",
purple: "#8E44AD",
blue: "#3498DB",
yellow: "#F1C40F",
darkGray: "#34495E",
lightGray: "#ECF0F1"
})
// Format definitions for reference
formats = [
{ id: "json", name: "JSON", color: ieeeColors.orange, overhead: 1.0 },
{ id: "msgpack", name: "MessagePack", color: ieeeColors.teal, overhead: 0.6 },
{ id: "protobuf", name: "Protocol Buffers", color: ieeeColors.blue, overhead: 0.4 },
{ id: "cbor", name: "CBOR", color: ieeeColors.purple, overhead: 0.55 },
{ id: "avro", name: "Apache Avro", color: ieeeColors.green, overhead: 0.45 },
{ id: "binary", name: "Raw Binary", color: ieeeColors.red, overhead: 0.25 }
]
// IoT Scenarios
scenarios = [
{
name: "LoRa/NB-IoT Constrained",
description: "Battery-powered sensors with limited bandwidth",
constraints: { bandwidth: "Very Low", processing: "Low", battery: "Critical" },
recommended: ["binary", "cbor", "protobuf"],
avoid: ["json"],
reason: "Every byte counts; schema-based formats enable smallest payloads"
},
{
name: "Industrial MQTT",
description: "Factory sensors publishing to MQTT broker",
constraints: { bandwidth: "Medium", processing: "Medium", battery: "N/A" },
recommended: ["msgpack", "protobuf", "cbor"],
avoid: [],
reason: "Balance of efficiency and debugging capability"
},
{
name: "Cloud API Integration",
description: "Devices communicating with REST APIs",
constraints: { bandwidth: "High", processing: "High", battery: "Medium" },
recommended: ["json", "msgpack"],
avoid: ["binary"],
reason: "Compatibility with web infrastructure; debugging ease"
},
{
name: "Edge Analytics",
description: "Local processing before cloud upload",
constraints: { bandwidth: "Variable", processing: "High", battery: "Medium" },
recommended: ["avro", "protobuf", "msgpack"],
avoid: ["json"],
reason: "Schema evolution for data pipelines; efficient storage"
},
{
name: "Real-time Telemetry",
description: "High-frequency sensor streams",
constraints: { bandwidth: "High", processing: "Critical", battery: "N/A" },
recommended: ["protobuf", "binary", "msgpack"],
avoid: ["json", "avro"],
reason: "Fastest encode/decode for high throughput"
},
{
name: "Device Configuration",
description: "Sending settings to devices",
constraints: { bandwidth: "Low", processing: "Low", battery: "Low" },
recommended: ["json", "cbor"],
avoid: ["binary"],
reason: "Human readability for debugging; flexibility for schema changes"
}
]
html`
<div style="font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;">
<div style="display: grid; gap: 15px;">
${scenarios.map(s => html`
<div style="background: white; border: 1px solid ${ieeeColors.gray}30; border-radius: 12px; overflow: hidden;">
<div style="background: ${ieeeColors.navy}; color: white; padding: 15px; display: flex; justify-content: space-between; align-items: center;">
<div>
<div style="font-weight: bold; font-size: 16px;">${s.name}</div>
<div style="font-size: 12px; opacity: 0.8;">${s.description}</div>
</div>
<div style="display: flex; gap: 10px;">
${s.recommended.slice(0, 2).map(r => {
const format = formats.find(f => f.id === r);
return html`<span style="background: ${format?.color || ieeeColors.gray}; padding: 4px 12px; border-radius: 20px; font-size: 12px;">${format?.name || r}</span>`;
})}
</div>
</div>
<div style="padding: 15px;">
<div style="display: grid; grid-template-columns: repeat(3, 1fr); gap: 15px; margin-bottom: 15px;">
<div style="text-align: center;">
<div style="font-size: 11px; color: ${ieeeColors.gray};">Bandwidth</div>
<div style="font-weight: bold; color: ${s.constraints.bandwidth === 'Very Low' ? ieeeColors.red : s.constraints.bandwidth === 'Low' ? ieeeColors.orange : ieeeColors.green};">${s.constraints.bandwidth}</div>
</div>
<div style="text-align: center;">
<div style="font-size: 11px; color: ${ieeeColors.gray};">Processing</div>
<div style="font-weight: bold; color: ${s.constraints.processing === 'Critical' ? ieeeColors.red : s.constraints.processing === 'Low' ? ieeeColors.orange : ieeeColors.green};">${s.constraints.processing}</div>
</div>
<div style="text-align: center;">
<div style="font-size: 11px; color: ${ieeeColors.gray};">Battery</div>
<div style="font-weight: bold; color: ${s.constraints.battery === 'Critical' ? ieeeColors.red : s.constraints.battery === 'N/A' ? ieeeColors.gray : ieeeColors.green};">${s.constraints.battery}</div>
</div>
</div>
<div style="background: ${ieeeColors.teal}10; padding: 10px; border-radius: 6px; border-left: 3px solid ${ieeeColors.teal};">
<div style="font-size: 12px; color: ${ieeeColors.darkGray};">${s.reason}</div>
</div>
${s.avoid.length > 0 ? html`
<div style="margin-top: 10px; font-size: 11px; color: ${ieeeColors.red};">
<strong>Avoid:</strong> ${s.avoid.map(a => formats.find(f => f.id === a)?.name || a).join(', ')}
</div>
` : ''}
</div>
</div>
`)}
</div>
</div>
`