Once = adverb
upon = two joined prepositions
a = article
time = noun
but the whole group functions as an 'adverb phrase'.
Or you can see 'once' as an 'adverb' and 'upon a time' as an 'adverb phrase'.
Also, you can call 'upon a time' a 'prepositional phrase' too.
Also, the whole phrase is part of something bigger, a 'predicate phrase' that includes the verb 'was'.
'There' is a 'pronoun', that usually 'substitutes' a noun, but in this case, in the same clause, there is also the 'noun' it should substitute, that in this case is the subject of the clause, which you didn't mention, but that we can imagine, going on with the story, it may be, for instance, 'a king'.
So in this case, 'there', in spite of being a pronoun, it doesn't really have the typical function of a pronoun, because it doesn't substitute the noun, but it 'anticipates' it, before the noun is expressed in the same clause.
That's why 'there' here is called, syntactically, a 'preparatory subject'.
In Italian we have the same 'there was' structure that English has, but our grammarians consider the Italian word of the corresponding structure that translates the word 'there' as an 'adverb' instead of a 'pronoun'.
There are many ways of classifying grammar elements and calling them, but what is important is to understand their functions and their reciprocal connections.