Chemical thermodynamics studies the energy changes that accompany chemical and physical transformations. The system is the part of the universe under study (the reacting chemicals in a beaker); the surroundings are everything else, separated by an imaginary boundary.
Systems are classified by what crosses the boundary. An open system exchanges both matter and energy with its surroundings (hot tea in an open cup). A closed system exchanges energy but not matter (a sealed flask). An isolated system exchanges neither (an ideal thermos flask). The state of a system is fixed by its state variables $P$, $V$, $T$ and amount $n$, linked for an ideal gas by $PV=nRT$.
A quantity whose value depends only on the present state, not on how it was reached, is a state function ($U$, $H$, $S$, $P$, $V$, $T$). Heat $q$ and work $w$ are path functions — their values depend on the route taken between two states.
The internal energy $U$ is the total energy stored in a system. We can never measure absolute $U$, only its change $\Delta U=U_{final}-U_{initial}$. Energy crosses the boundary as heat $q$ or work $w$.
By the IUPAC sign convention, $q$ is positive when heat flows into the system and $w$ is positive when work is done on the system. The first law of thermodynamics (conservation of energy) is then written
$\Delta U=q+w$
For chemical reactions the most common work is pressure–volume (expansion) work. When a gas expands by $\Delta V$ against a constant external pressure $P_{ext}$, the work done on the system is $w=-P_{ext}\Delta V$. In a reversible isothermal expansion of an ideal gas, $w=-nRT\ln\!\left(\dfrac{V_2}{V_1}\right)$. At constant volume $\Delta V=0$, so $w=0$ and $\Delta U=q_V$ — the heat measured in a bomb calorimeter equals $\Delta U$.
Most reactions are run in open vessels at constant pressure, so chemists define enthalpy $H=U+PV$. At constant pressure the heat absorbed equals the enthalpy change: $\Delta H=q_P$. Combining the gas law with $\Delta(PV)=\Delta n_g RT$ for gaseous species gives the working relation
$\Delta H=\Delta U+\Delta n_g RT$
where $\Delta n_g$ is (moles of gaseous products) minus (moles of gaseous reactants). A reaction with $\Delta H<0$ is exothermic (releases heat); $\Delta H>0$ is endothermic.
The heat capacity $C$ is the heat needed to raise the temperature by 1 K. The molar values $C_v$ and $C_p$ (at constant volume and pressure) are linked for an ideal gas by Mayer’s relation $C_p-C_v=R$. Finally, calorimetry measures heat as $q=mc\,\Delta T$, letting us determine $\Delta U$ (bomb calorimeter, constant $V$) or $\Delta H$ (constant $P$).