  We show that an electronic phase transition described by the Cahn-Hilliard
equation has important applications to cuprate superconductors. The simulations
of the local charge density and free energy reveal two main features: i) The
segregation process creates tiny isolated regions with potential wells where
the holes can be bound in single-particle levels. ii) The clustering process
also gives rise to an effective two-body pairing interactions and
superconducting amplitudes $\Delta_{sc}(\vec r)$ at low temperatures. The
resulting system resembles a granular superconductor with the resistivity
transition driven by Josephson coupling among these nanoscale grains. This
approach reproduces the well known critical temperature transition $T_c(p)$ as
function of the doping level $p$. The derived $p \times T$ phase diagram
reproduces the main features measured by several experiments. Furthermore, the
local density of states with spatial dependent gaps $\Delta(\vec r)$ is due to
the intragrain single-particle bound states that remain above $T_c$, which
characterizes the pseudogap phase and reproduces many measurements.
