In summary, without knowing the symptoms, we will assume that your diagnostic is correct, that the battery is bad, in which case you can replace your battery or top case without losing your data.
The long answer:
The mother board has on it the CPU and storage (SSD). The battery is glued to the top case which is independent from the mother board.
The top case can be replaced entirely, or you can replace just the battery (takes mores skill and time, saves money). Follow this link to learn how, and what tools to use.
This, of course, assuming the battery is really bad since at 2 years of age, they should rarely fail; detailed symptoms can help validate battery failure as sometimes other issues on the board can prevent the battery from charging, and/or the charger itself can be bad.