How Melamine is produced?

Today most industrial manufacturers use urea in the following reaction to produce melamine:

6 (NH2)2CO → C3H6N6 + 6 NH3 + 3 CO2

It can be understood as two steps.

First, urea decomposes into cyanic acid and ammonia in an endothermic reaction:

(NH2)2CO → HCNO + NH3

Then, cyanic acid polymerizes to form melamine and carbon dioxide:

6 HCNO → C3H6N6 + 3 CO2

The second reaction is exothermic but the overall process is endothermic.