The direct object is used with transitive verbs (action verbs that are received by someone or something) and is not related to the main subject. e.g. Mangio una mela = I eat an apple. The subject here is 'io' = 'I' and the direct object is 'una mela'. 'Mangiare' = 'to eat' is a transitive verb linked to something (in this case, an apple).
The indirect object is used with intransitive verbs (verbs that don't require direct objects) and can be of various kinds (specification, agent, limitations, etc.). e.g. Porta un fiore a Marco = bring a flower to Marco. While 'fiore' is a direct object, 'a Marco' is an indirect object.