[noun] + のように + [verb] [noun] + のように + [i-adj] [noun] + のような + [noun] [noun] + のようだ [verb (plain)] + ように + [verb]
のように and のような mean "like": they compare something to a noun. The noun takes の, then のように goes before a verb or an adjective and のような before a noun.
The word that follows decides. ように works like an adverb and describes how something is done or how something is. ような works like a な-adjective and describes a noun.
At the end of a sentence it is のようだ. まるで in front makes the comparison stronger.
These go beyond comparing one thing to another.
のような also gives an example of a kind, and the noun is then one of them: a big city like Tokyo includes Tokyo.
After a verb in the plain form, ように takes no の and means "as": the way someone said or did it.