  Origin of LIGO/Virgo gravitational wave events may involve production of
binaries with relativistic components in dense stellar systems - globular or
nuclear star clusters - and their subsequent evolution towards merger. Orbital
parameters of these binaries (the inner orbit) and their motion inside the
cluster (the outer orbit) evolve due to both external agents - random
encounters with cluster stars and cluster tides due to the smooth cluster
potential - and the internal ones - various sources of dissipation and
precession within the binary. We present a numerical framework - Binary
Evolution in Stellar Clusters (BESC) - that follows the evolution of the binary
inner and outer orbits accounting for all these effects simultaneously,
enabling efficient Monte Carlo studies. The secular effect of cluster tides is
computed in the singly-averaged approximation, without averaging over the outer
binary orbit. As to stellar encounters, we include the effects of both close
and distant flybys on the inner and outer orbits of the binary, respectively.
In particular, this allows us to explicitly account for the dynamical friction
sinking the binary towards the cluster centre. Also, given our focus on the
LIGO/Virgo sources, we include the general relativistic precession (which
suppresses cluster tides at high eccentricities) and the gravitational wave
emission (shrinking the binary orbit). We use BESC to illustrate a number of
characteristic binary evolutionary outcomes and discuss relative contributions
of different physical processes. BESC can also be used to study other objects
in clusters, e.g. blue stragglers, hot Jupiters, X-ray binaries, etc.
