This is a first-order linear differential equation. We solve it using the integrating factor method. The equation is:
\[
\frac{dy}{dx} + y = e^x.
\]
The integrating factor is given by:
\[
\mu(x) = e^{\int 1 \, dx} = e^x.
\]
Multiplying both sides of the differential equation by the integrating factor \( e^x \), we get:
\[
e^x \frac{dy}{dx} + e^x y = e^{2x}.
\]
The left-hand side is the derivative of \( y e^x \), so we can rewrite the equation as:
\[
\frac{d}{dx}(y e^x) = e^{2x}.
\]
Now, integrate both sides with respect to \( x \):
\[
y e^x = \int e^{2x} \, dx = \frac{1}{2} e^{2x} + C.
\]
Thus,
\[
y = \frac{1}{2} e^x + C e^{-x}.
\]
Using the initial condition \( y(0) = 0 \):
\[
0 = \frac{1}{2} e^0 + C e^0 \quad \Rightarrow \quad C = -\frac{1}{2}.
\]
Therefore, the solution is:
\[
y = \frac{1}{2} e^x - \frac{1}{2} e^{-x}.
\]