What exactly happens during Database Mirroring? What about during a fail over?
When you do a failover, a role reversal happens i.e. your primary becomes secondary and your secondary becomes primary.

ALTER DATABASE [yourDatabase]
SET PARTNER FAILOVER
GO


Doing so, only the role reversal happens (this is what happens when you initiate a failover using above command) and mirroring direction is reversed - principal becomes mirror and vice-versa. Note that MIRRORING is not BROKEN. Refer to my answer : If I fail over one database, do the others that share the same mirror endpoint fail over as well? for more details.

You can have your application use Failover Partner=your_mirror_serve_name, so that your application is redirected to replica database when a failover happens.

Refer to : connectionstring in Database Mirror setup