We propose a first-principles model for self-assembled magnetic surface structures on the water-air interface reported in earlier experiments cite{snezhko2,snezhko4}. The model is based on the Navier-Stokes equation for liquids in shallow water approximation coupled to Newton equations for interacting magnetic particles suspended on the water-air interface. The model reproduces most of the observed phenomenology, including spontaneous formation of magnetic snake-like structures, generation of large-scale vortex flows, complex ferromagnetic-antiferromagnetic ordering of the snake, and self-propulsion of bead-snake hybrids. The model provides valuable insights into self-organization phenomena in a broad range of non-equilibrium magnetic and electrostatic systems with competing interactions.