Electrocatalytic nitrate reduction reaction (NitRR) in neutral condition offers a promising strategy for green ammonia synthesis and wastewater treatment, the rational design of electrocatalysts is the cornerstone. Inspired by modern factory design where both machines and logistics matter for manufacturing, it is reported that cobalt phosphide (CoP) nanoparticles embedded in zinc-based zeolite imidazole frameworks (Zn-ZIF) function as a nanofactory with high performance. By selective phosphorization of ZnCo bimetallic zeolite imidazole framework (ZnCo-ZIF), the generated CoP nanoparticles act as "machines" (active sites) for molecular manufacturing (NO3 - to NH4 + conversion). The purposely retained framework (Zn-ZIFs) with positive charge promotes logistics automation, i.e., the automatic delivery of NO3 - reactants and timely discharge of NH4 + products in-and-out the nanofactory due to electrostatic interaction. Moreover, the interaction between Zn-ZIF and CoP modulates the Co sites into electron insufficient state with upshifted d-band center, facilitating the reduction/hydrogenation of NO3 - to ammonia and restricting the competitive hydrogen evolution. Consequently, the assembled CoP/Zn-ZIF nanofactory exhibits superior NitRR performances with a high Faraday efficiency of ≈97% and a high ammonia yield of 0.89mmol cm-1 h-1 in neutral condition, among the best of reported electrocatalysts. The work provides new insights into the design principles of efficient NitRR electrocatalysts.