Resources theories: derivation of the foundational structure