Herein, Nitrogen-doped graphyne/porous g-C3N4 composites are firstly in-situ synthesized via the ultrasound vibration of CaC2, triazine, and porous g-C3N4 in absolute ethanol. A variety of characterizations are performed to investigate the morphology, microstructure, composition, and electrical/optical features of the obtained composites, such as transmission electron microscopy, scanning electron microscopy, X-ray diffraction, Fourier transform infrared spectra, X-ray photoelectron spectroscopy, and so forth. It is found that N-doped graphyne with flexible folds lamellar structure is intimately attached to flake g-C3N4 in the as-prepared composites. An enlargement of 1.68 and 1.44 folds for the photocatalytic degradation of levofloxacin, rhodamine B, Methylene blue, and Tetracycline is realized by N-doped graphyne/g-C3N4 in comparison with that of pristine g-C3N4, respectively. In addition, the highest NH3 production rate attains 1.71 mmol⋅gcat−1⋅h−1 for N-doped graphyne/g-C3N4, which is 5.89 times larger than that of g-C3N4 (0.29 mmol⋅gcat−1⋅h−1). The improved mechanism of photocatalysis including higher photo-response and carrier separation rate is verified by transient photo-current, transient photo-potential, Mott-Schottky plots, Tafel plots, electrochemical impedance spectroscopy, turn-over frequency, photoluminescence spectra, and UV–vis diffuse absorption spectra, etc. Overall, the current study shows that N-doped graphyne synthesized from CaC2 and triazine is a useful decoration to modulate the photocatalytic features of g-C3N4, which can also be widely extended for in-situ modification of other photocatalysts.