So the physiology of your breathing starts with your thoracic cavity. Your thoracic cavity is protected by your ribcage, and in the bottom of your thoracic cavity is your diaphragm.
When you inhale, the air goes in through your nose or mouth and goes down through your windpipe. Then goes down your bronchus, where it leads the air to your lungs. Then enters your alveoli, where it takes the oxygen in the air into your blood. Then you exhale carbon dioxide.
When you inhale, the muscles tighten, pushing your ribs outward. When you exhale, the muscles relax pushing carbon dioxide out.
Your body also has a feedback system, it regulates your pH blood. Your body goes through a lot to keep your blood pH level at 7, and it’s not good if it drops or rises.
For example, when you breathe hard, that means your blood pH level is low. There’s too much carbon dioxide in your blood and not enough oxygen. So when your blood vessels detect that your pH level is low, they send a message to your medulla oblongata.
Your medulla oblongata sends a message to your ribcage muscles to contract faster and deeper. This makes you breath harder, and when you exhale, you exhale the carbon dioxide in your blood. Your breathing returns to normal when your pH blood returns to normal.