Click the structures and reaction arrows in sequence to view the 3D models and animations respectively
The second step is the formation of an ester enamine, which is produced by condensation of the second equivalent of the β-ketoester with ammonia.
Note: Step 1 and Step 2 can happen in either order
H. G. O. Alvim, E. N. da Silva Júnior and B. A. D. Neto, RSC Adv., 2014, 4, 54282–54299.