{
  "meta": {
    "title": "Electret mic + NPN preamp -> ESP32 ADC (dense analog)",
    "version": "1.0"
  },
  "symbols": {
    "electret_mic_2pin": {
      "symbol_id": "electret_mic_2pin",
      "category": "analog",
      "body": { "width": 90, "height": 56 },
      "pins": [
        { "name": "MIC+", "number": "1", "side": "right", "offset": 20, "type": "analog" },
        { "name": "MIC-", "number": "2", "side": "right", "offset": 38, "type": "ground" }
      ]
    },
    "npn_bjt_generic": {
      "symbol_id": "npn_bjt_generic",
      "category": "analog",
      "body": { "width": 92, "height": 74 },
      "pins": [
        { "name": "B", "number": "1", "side": "left", "offset": 37, "type": "analog" },
        { "name": "C", "number": "2", "side": "top", "offset": 46, "type": "analog" },
        { "name": "E", "number": "3", "side": "bottom", "offset": 46, "type": "analog" }
      ]
    },
    "mcu_adc_1pin": {
      "symbol_id": "mcu_adc_1pin",
      "category": "generic",
      "body": { "width": 126, "height": 64 },
      "pins": [
        { "name": "ADC_IN", "number": "1", "side": "left", "offset": 32, "type": "analog" },
        { "name": "3V3", "number": "2", "side": "top", "offset": 32, "type": "power_in" },
        { "name": "GND", "number": "3", "side": "bottom", "offset": 32, "type": "ground" }
      ]
    }
  },
  "instances": [
    { "ref": "V1", "part": "connector", "properties": { "value": "3.3V/GND source" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
    { "ref": "M1", "symbol": "electret_mic_2pin", "properties": { "value": "Electret mic" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
    { "ref": "Q1", "symbol": "npn_bjt_generic", "properties": { "value": "2N3904" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
    { "ref": "R1", "part": "resistor", "properties": { "value": "4.7k", "role": "mic bias" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
    { "ref": "C1", "part": "capacitor", "properties": { "value": "1uF", "role": "mic AC coupling" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
    { "ref": "R2", "part": "resistor", "properties": { "value": "220k", "role": "base bias top" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
    { "ref": "R3", "part": "resistor", "properties": { "value": "100k", "role": "base bias bottom" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
    { "ref": "RC", "part": "resistor", "properties": { "value": "47k", "role": "collector resistor" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
    { "ref": "RE", "part": "resistor", "properties": { "value": "1k", "role": "emitter resistor" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
    { "ref": "C2", "part": "capacitor", "properties": { "value": "1uF", "role": "output AC coupling" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
    { "ref": "R4", "part": "resistor", "properties": { "value": "100k", "role": "ADC mid-rail top" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
    { "ref": "R5", "part": "resistor", "properties": { "value": "100k", "role": "ADC mid-rail bottom" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
    { "ref": "C3", "part": "capacitor", "properties": { "value": "100nF", "role": "ADC mid-rail filter" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
    { "ref": "C4", "part": "capacitor", "properties": { "value": "100nF", "role": "local decoupling" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } },
    { "ref": "U1", "symbol": "mcu_adc_1pin", "properties": { "value": "ESP32-S3 (ADC pin)" }, "placement": { "x": null, "y": null, "rotation": 0, "locked": false } }
  ],
  "nets": [
    {
      "name": "3V3",
      "class": "power",
      "nodes": [
        { "ref": "V1", "pin": "3V3" },
        { "ref": "R1", "pin": "1" },
        { "ref": "R2", "pin": "1" },
        { "ref": "RC", "pin": "1" },
        { "ref": "R4", "pin": "1" },
        { "ref": "C4", "pin": "1" },
        { "ref": "U1", "pin": "3V3" }
      ]
    },
    {
      "name": "GND",
      "class": "ground",
      "nodes": [
        { "ref": "V1", "pin": "GND" },
        { "ref": "M1", "pin": "MIC-" },
        { "ref": "R3", "pin": "2" },
        { "ref": "RE", "pin": "2" },
        { "ref": "R5", "pin": "2" },
        { "ref": "C3", "pin": "2" },
        { "ref": "C4", "pin": "2" },
        { "ref": "U1", "pin": "GND" }
      ]
    },
    {
      "name": "MIC_BIAS",
      "class": "analog",
      "nodes": [
        { "ref": "R1", "pin": "2" },
        { "ref": "M1", "pin": "MIC+" },
        { "ref": "C1", "pin": "1" }
      ]
    },
    {
      "name": "BASE_NODE",
      "class": "analog",
      "nodes": [
        { "ref": "C1", "pin": "2" },
        { "ref": "R2", "pin": "2" },
        { "ref": "R3", "pin": "1" },
        { "ref": "Q1", "pin": "B" }
      ]
    },
    {
      "name": "COLLECTOR_NODE",
      "class": "analog",
      "nodes": [
        { "ref": "Q1", "pin": "C" },
        { "ref": "RC", "pin": "2" },
        { "ref": "C2", "pin": "1" }
      ]
    },
    {
      "name": "EMITTER_NODE",
      "class": "analog",
      "nodes": [
        { "ref": "Q1", "pin": "E" },
        { "ref": "RE", "pin": "1" }
      ]
    },
    {
      "name": "ADC_MID",
      "class": "analog",
      "nodes": [
        { "ref": "R4", "pin": "2" },
        { "ref": "R5", "pin": "1" },
        { "ref": "C3", "pin": "1" },
        { "ref": "C2", "pin": "2" },
        { "ref": "U1", "pin": "ADC_IN" }
      ]
    }
  ],
  "constraints": {
    "groups": [
      {
        "name": "MicFrontEndCluster",
        "members": ["M1", "R1", "C1", "Q1", "R2", "R3", "RC", "RE", "C4"],
        "layout": "cluster"
      },
      {
        "name": "ADCBiasCluster",
        "members": ["R4", "R5", "C3", "C2", "U1"],
        "layout": "cluster"
      }
    ],
    "near": [
      { "component": "C4", "target_pin": { "ref": "Q1", "pin": "C" } },
      { "component": "C3", "target_pin": { "ref": "U1", "pin": "ADC_IN" } }
    ]
  },
  "annotations": [
    { "text": "Dense analog frontend + ADC bias test case." }
  ]
}
