Composing Melody First vs. Composing Chords First
Neither composing chords first and then finding a melody on top of them nor the other way around are optimal composition principles. In both ways you’re lacking ultimate control over what you’re writing.
For example you have a chord progression that you like which is 8 bars long and has its harmonic climax in bar 5. Unless you are absolutely aware of this and have a tremendous flexibility to shape a melody on top of these chords that mirrors the same dramaturgy and climaxes in bar 5 as well, chances are quite high that your two dramaturgical arcs will not be in sync completely which will musically not be ideal.
Generally, you should try to get to the point where you can compose both levels simultaneously thinking at the same time about harmonic progression and melodic dramaturgy. Your compositions will become way more stringent if you take control over these two elements at the same time and mold them together.