The various compounds released by the (organic (containing carbon)) explosives can be metabolized by bacteria. And bacterial metabolism is often linked to sensors within the bacteria already - so that the machinery for metabolizing X isn't actually produced unless the bacteria can sense X in its environment. If we find a bacteria that already has this system, we can commandeer it so that upon sensing TNT/DNT/Nitrates it produces a reporter (color, it moves, another sense-able chemical) instead of or along with the enzymes used to metabolize those explosive materials.
A list of tested analytes and reporters: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4625088/table/T...
And a very basic diagram: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4625088/figure/...
And images of what the bacteria look like when 'turned on' by TNT, DNT, or nitrates: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4625088/figure/...
[From the paper: https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4625088/ ]