How fundamental Physics is constructed? I was wondering, how do theoretical physicist arrive to such fundamental things like Lagrangians or actions.
For example, the QED, action is given by:
$$
\mathcal S_{QED} = \int_{\mathcal M} {\mathrm d^4x \; \left \{ -\frac{1}{4}F^{\mu \nu} F_{\mu \nu} + \bar{\psi} \left(i\gamma^\mu D_\mu - m \right)\psi \right \} }
$$
Applying Euler-Lagrange equations for $\psi$ and $A_\mu$ we get the following:
$$
(i\gamma^\mu \partial_\mu - m)\psi=e \gamma^\mu A_\mu \psi \\
\partial_\mu F^{\mu\nu} = ej^\nu
$$
But I assume they just go the other way around, from the equations of motion to the actions, how do they do it?. If not, what other procedure do they follow?
 A: There's been a lot of back-and-forth in the past few centuries in the way physics laws are written. Sometimes laws that were fundamental became mere consequences of deeper ones. Sometimes there were laws that were equivalent, but one version was more suited for newer topics.
Maxwell's equations have the very special property of having remained unchanged with progress in physics. Sure, they have been rewritten with new tools, the mathematical nature of the terms inside them have evolved, but their overall form didn't change.
It was already known before quantum physics that Maxwell's equations could be derived in a relativistic setting by using the variational reasoning that was already successful for mechanics. My history lessons are a bit vague now, but Lorentz boosts were already known by the end of the 19th century, so Lorentz group was available, and some work on gauge invariance was already on the way, using Maxwell's equations as a starting point.
Things moved in the 30s when Wigner brought the idea of a generalized use of group theory. Take the symmetry groups that were used in a classical setting, keep them as you move to a quantum setting, but change the algebra (roughly speaking, move to another space for the representation of the same group). That's how you get equations that have the same structure as the old Maxwell's equations, but with fields that have a different mathematical nature (live in another space).
Since a similar process was working well for another parts of physics, it was decided to keep the process, to elevate it to a very fundamental status. This effectively reversed the roles, as Maxwell's equations ceased to be fundamental and joined Newton's laws (for example) as derived laws.
Careful, however, not to over-interpret this. There's no single physical law from which all others derive. This is only a mathematical procedure, based on group theory, that can build theories "on demand": you input a set of symmetry groups and specify the algebra, and you get a theory as output. Some of those theories make no sense or collapse by themselves, but Poincaré group+gauge group $U(1)$ will give you Maxwell's equations, in classical or quantum form, depending on the algebraic context.
So yes, Maxwell's equations came first historically. But if you forget history and see things just from a formal point of view, we have built enough trust in the symmetry group approach to consider the lagrangian / action building process to be more fundamental.
