In the early stages of the life of a star, it exists as a protostar, gradually expanding as it gathers mass through gravity. As that mass increases, the pressures acting on its central regions become immense, to the point where hydrogen nuclei began to undergo fusion to form helium. The energy of nuclear fusion will create a spherical region in the heart of the new star, in which the forces of expansion are sufficient to balance the inward pressure of the star's mass. Thus a stellar core is formed, and a new star comes into existence.
In a main sequence star like the Sun, the core is surrounded by a wide radiative zone or stellar envelope, and energy radiated from the core must pass through this region before it reaches the outer convection zone and is ultimately released from the star altogether. This passage from the core to the star's outer layers is a long one: the distance from the core of the Sun to its surface is about twice that from the Earth to the Moon, and photons must pass through the dense radiative zone, deflecting randomly from other particles in the zone. Hence a photon radiated from the core of the Sun can take thousands or even millions of years before it is ultimately released into space.
Over millions and billions of years, the hydrogen reserves within the core will begin to deplete. In order for the fusion within the core to maintain a balance against the inward pressure of the star's mass, the core burns more hotly and brightly. The star thus moves along the main sequence, fron yellow to white to blue, increasing in luminosity over its lifetime.
Red dwarf stars are significantly less massive than other types of star, and for these low-mass stars, the core works in a different way. In a main sequence star, only the hydrogen within the core is available for fusion, but in a star significantly less massive than the Sun, hydrogen and helium from within the entire star are able to mix more freely, vastly increasing the amount of fuel available for fusion, and so vastly extending the star's lifespan.
In more massive stars, however, the hydrogen reserves in the core will eventually be reduced to the point where hydrogen fusion is no longer possible. In a sufficiently massive star, the core will begin to fuse helium into carbon, while still being surrounded by a hydrogen-burning shell. In truly massive stars, this process can continue, creating complex cores with shells producing energy through various different nuclear processes, producing heavier elements through more and more complex processes.
Regardless of the mass of the star, its fusion resources will eventually be consumed. For relatively low-mass stars like the Sun, the core will then collapse into a dense white dwarf, a star which no longer produces energy, but will continue to shine for billions of years as it radiates its residual energy away into space. For more massive stars, the collapse of the core can produce an immensely dense neutron star or, for truly massive stars (with cores massing more than about 130 times that of the Sun), the process of collapse will result in a black hole.