Surface-enhanced Raman spectroscopy (SERS) refers to an emerging and promising spectroscopic technique for a range of analytical purposes. However, the common SERS substrates based on silicon, glass, and porous alumina are considered to be rigid, brittle, expensive. and not environmentally friendly. In the present study, polydopamine-coated cellulose nanofibers were facially self-assembled into a 3D architecture that was under mediation by a DNA template. In addition, the multilevel structure of the involved biomacromolecules could be conducive to achieving a significant junction and an effective dispersion of the decorated Ag NPs, thereby leading to the production of a flexible SERS substrate. As impacted by the large-area hotspots within the 3D substrate, the enhancement factor approached to 10 8 , and sample-to-sample repeatability could take up 5.39% to detect Rhodamine 6G. Moreover, charged dye molecules were selectively detected as impacted by the pH response characteristics of the substrate. Furthermore, for the SERS substrate, thiamethoxamon was quantitatively detected in situ on the surface of fruits, and the limit of detection could be up to 0.003 mg/kg. The mentioned aggregations based on ordered structures have a potential practical application as an on-site SERS substrate in the environment and health industry.