"Aí" Points to the location of the listener.
"O gato está aí (na sua casa)". = The cat is there (at your house)
"Saia daí (de onde você está)" = Get out of there (where you are)
"Lá" points away from speaker AND listener. "Over there" is best.
"Aqui" is the location of the speaker (just to complete the scene).
"Ali" is not so far. It's also away from both, but not far.
There are no rules to say what is far and what is not. It's about feeling.
Something that happens a lot:
A "carioca" (person from Rio de Janeiro) asks a "mineiro" (person from Minas Gerais) how to go to the station.
And the "mineiro" answers: segue por essa rua, é logo ali. (logo ali = right over there)
"Carioca" goes out walking through that street, and after what he considers very far, he starts swearing the "mineiro".
Their idea of distance a "a little" different.