When we first introduced phase diagrams, we assumed that the two components mix well, i.e. that they "like" each other.  
In other words, the free enthalpy for any mix and temperature is always lower that that of equal amounts of the pure components  
If we examine the Cu  Ni case used as example, we see that in terms of only the enthalpy H  i.e. the binding energy between the atoms  Cu indeed "likes" Ni, but Ni is not so happy with Cu atom as neighbors.  
We see that, because the enthalpy at the Cu side goes down with some Ni atoms added, while on the Ni side it goes up. However, the effect is small, because the total enthalpy curve is close to a straight line between the two extremes, and a straight line simply indicates total indifference as to one's neighbor.  
The entropy always increases with mixing; in consequence the free enthalpy for the Cu  Ni example is always "hanging down" for the temperature range considered (only at extremely low temperatures it must eventually come up).  
What happens if we try to mix atoms that really hate each other; i.e. the enthalpy curve goes up from both ends if we add A or B?  
The answer  you guessed it (hopefully)  is clear: You get eutectic and peritectic behavior.  
How? That's what we are going to look at in this module, however, because it tends to get a bit involved, only in cursory way.  
First let's look at eutectic behavior. For that we only need to go through the possibilities inherent in the superposition of an "up" enthalpy H curve with a "down" –TS curve; what happens then is shown below:  

It's rather obvious. While for high temperatures the –TS term still may win; i.e. the free enthalpy is completely "hanging through" with only one minimum, the situation changes with decreasing temperature T.  
The free enthalpy curve will start to bend upwards somewhere in the middle. It now has two minima (for solid phases), and that means that a mixture of two solid phases is energetically favorable.  
A "miscibility gap" develops at some temperature T_{Mis} and spreads with decreasing T. This produces the light green area in the schematic phase diagram above.  
The phase diagram shown also indicates that the area of complete miscibility in the L + a will no longer be a simple lens, but may be somewhat distorted, too  
The next step is easy to imagine. Just suppose that T_{Mis} is larger than the liquidus temperature at some concentration.  
What you would get then is something like this: 


You end up with an eutectic phase diagram by necessity!  
Of course, the details of the two "ears" with the phase mix liquid and solid depends on the particulars of the system  
And for very peculiar systems, one "ear" flips down to produce a peritectic phase diagram!  
All that's needed for that is that the melting points of the two components are quite different, so one will be smaller than the equilibrium temperature for the three phases in contact.  
What you get then looks like this: 


It is rather straightforward; even in the details, but a closer discussion would still need a lot of words and drawings.  
The important thing to note is that everything follows from the interaction energy of A and B atoms (or components, if you allow molecules for A and B, too).  
Add the entropy of mixing, and you can actually calculate phase diagrams  including rather complicated ones.  
Nobody says it's easy  but by now, standard software is available that produces binary phase diagrams routinely.  
5.5.1 Phasendiagramme  Fortsetzung
5.4.3 Kompliziertere Phasendiagramme: Eutektika
© H. Föll (MaWi 1 Skript)