Flashing of program on the board

Hi, I wanted to know what actually happens to the board (Arduino) and/or the AtMega328 when we upload a program through the IDE. Example, if i wanted to send to the board, the hex file, by myself through the Serial terminal, there's some other stuff i need to perform right? I mean i need to use the reset pin. I need to know how that stuff works. How long should be the pulse, how the data should be sent and anything else even remotely related to this.