We need orbiting companions in order to measure masses. Fortunately, most stars are really binaries or multiple star systems. Visual binaries can be seen as two separate objects. Spectroscopic binaries are systems in which we can see the spectral lines move back and forth due to doppler shift. In eclipsing binaries one star passes in front of the other.
Light curves give radii, periods, relative brightnesses and colours.
An individual system can be any combination of these. Orbital periods can be hours to 1000's of years. If we know T and a, we can measure the sum of the masses. We can often measure T directly, and a can be estimated from the velocities or the separations. The mass ratio is needed to determine the individual masses.