usually the melody is written first and then chords/bass are to it, but do you have any trouble doing it the other way around? like writing the melody as the last step? could you still come up with a strong melody or would it sound more improvisational? could you still write a melody over a song with a ton of changes?
you can do it any of those ways. i prefer to do it as much together as possible, always with the lyrics and melody simultaneously, and usually the general idea of the chords and groove/tempo are also right on board with that. all other details would come later