Assonance is the repetition of similar vowel sounds in stressed syllables of nearby words; alliteration, on the other hand, is the repetition of similar consonant sounds in the initial syllables of neighboring words.
In other words, assonance and alliteration differ in two crucial aspects: the type of repeated sounds (vowels vs. consonants) and their position (anywhere in the word vs. only in the first syllable); hence, they are easily discernible from each other.
Consider the following verse (498) from William Shakespeare’s Venus and Adonis:
Do I delight to die, or life desire?
Here, “I,” “delight,” “die,” “life” and “desire” all contain an identical vowel sound: the “long i” [aɪ]; this is an example of assonance. At the same time, four words—“do,” “delight,” “die” and “desire”—all begin with the same consonant: “d”; and this is an example of alliteration.