Terahertz (THz) communications have been envisioned as a promising enabler to provide ultra-high data transmission for sixth generation (6G) wireless networks. To tackle the blockage vulnerability brought by severe attenuation and poor diffraction of THz waves, a nanoscale reconfigurable intelligent surface (NRIS) is developed to smartly manipulate the propagation directions of incident THz waves. In this paper, the electric properties of the graphene are investigated by revealing the relationship between conductivity and applied voltages, and then an efficient hardware structure of electrically-controlled NRIS is designed based on Fabry-Perot resonance model. Particularly, the phase response of NRIS can be programmed up to 306.82 degrees. To analyze the hardware performance, we jointly design the passive and active beamforming for NRIS aided THz communication system. Particularly, an adaptive gradient descent (A-GD) algorithm is developed to optimize the phase shift matrix of NRIS by dynamically updating the step size during the iterative process. Finally, numerical results demonstrate the effectiveness of our designed hardware architecture as well as the developed algorithm.