A direct object is a noun phrase that refers to a person or thing that is indirectly affected by the action of the verb in a sentence.
The indirect object directly follows a verb + preposition, so it is very easy to see the effect that the verb has on that person.
Marie donne un cadeau à Pierre.
Subject: Marie
Verb: donne
Question: À qui?
COI: à Pierre
Marie lui donne un cadeau.