How article endings help determine adjective endings
A German noun phrase has to display three pieces of grammatical information: which of four cases it is playing (nominative, accusative, dative, or genitive), which of three genders the noun belongs to (masculine, neuter, or feminine), and whether it is singular or plural. That information has to show up somewhere in the phrase, and the article and adjective coordinate their endings. The case-marking contrast is a useful starting point, rather than a claim that every feature is marked on only one word. Wikipedia's "Deutsche Deklination" entry states the governing rule directly, citing Duden-Redaktion's reference grammar Die Grammatik (8th edition, 2009, p. 363): "Wenn dem Adjektiv ein Artikelwort mit Beugungsendung vorangeht, wird das Adjektiv schwach flektiert, sonst stark," meaning "if an article word with an inflectional ending precedes the adjective, the adjective inflects weakly; otherwise it inflects strongly."
That single rule produces the pair every German course eventually points to: der kalte Kaffee ("the cold coffee") next to kalter Kaffee (the same two words with no article, closer to "cold coffee" as a general statement). In der kalte Kaffee, der already marks masculine, nominative, and singular, so kalt only needs the weak ending -e. In kalter Kaffee, nothing precedes kalt, so the adjective has to carry that information itself, and it does so by taking -er, the same ending der would have carried in that exact slot. For these inflecting adjectives, the article pattern determines which set of endings applies; case, gender, and number then determine the form within that set.
Weak endings: after der, die, and das, only two forms ever show up
When a definite article (der, die, das and its other case forms) or a similar word like dieser or jener precedes the adjective, the ending is called weak, and the entire system collapses to two possible endings: -e and -en. The rule for choosing between them is short: -en covers every plural form, every dative form, and every genitive form, plus the masculine singular accusative; -e covers everything left over, the nominative singular in all three genders plus the accusative singular in the feminine and neuter. Working through kalter Kaffee (cold coffee, masculine), kaltes Wasser (cold water, neuter), kalte Milch (cold milk, feminine), and kalte Getränke (cold drinks, plural, all capitalized nouns as standard German orthography requires, a convention covered in more detail in the Schadenfreude entry) with der, das, die, and die in front produces der kalte Kaffee, das kalte Wasser, die kalte Milch, and die kalten Getränke in the nominative. Switching to the accusative changes only the masculine form, to den kalten Kaffee, while das kalte Wasser and die kalte Milch stay exactly as they were.
The dative and genitive erase the gender distinction from the ending entirely. Dem kalten Kaffee, dem kalten Wasser, and der kalten Milch all take -en in the dative, as does den kalten Getränken in the plural; des kalten Kaffees, des kalten Wassers, der kalten Milch, and der kalten Getränke do the same in the genitive. Two endings, spread across four cases, three genders, and a plural, is the entire weak system.
Strong endings: the adjective takes over the article's job
Drop the article entirely, and the adjective has to carry the case, gender, and number information on its own. It does this by borrowing almost exactly the endings the definite article itself would have used in that spot: kalter Kaffee takes -er the way der does, kaltes Wasser takes -es the way das does, and kalte Milch and kalte Getränke take -e the way die does in the nominative. The dative singular masculine and neuter both take -em, matching dem: mit kaltem Kaffee, mit kaltem Wasser. The dative and genitive plural track the article closely too: mit kalten Getränken in the dative, trotz kalter Getränke in the genitive, echoing den and der.
There is one standing exception, in the genitive singular of the masculine and neuter. The article-matching pattern would predict kaltes Kaffees and kaltes Wassers, following des, but the actual forms are wegen kalten Kaffees and wegen kalten Wassers, with -en instead. Wikipedia's "Deutsche Deklination" entry, citing the same Duden reference grammar (Die Grammatik, 8th edition, 2009, p. 363), records this as the one place strong declension departs from the article pattern it otherwise mirrors. The noun also carries a genitive -s in these examples (Kaffees, Wassers). The standard strong-declension table uses -en for the adjective here.
Mixed endings: after ein, kein, and mein, it splits down the middle
The indefinite article ein, the negative article kein, and possessives (mein, dein, sein, ihr, unser, euer) do not fit neatly into either the weak or the strong pattern, because they only sometimes carry an ending of their own. Ein and mein have no ending at all in the masculine nominative singular, the neuter nominative singular, and the neuter accusative singular; everywhere else, they inflect just like der does. The adjective that follows fills in exactly the gap this leaves: strong wherever the article has no ending to show the case itself, weak everywhere the article already has one.
Working through mein kalter Kaffee, mein kaltes Wasser, meine kalte Milch, and meine kalten Getränke in the nominative shows the split directly. Mein has no ending before Kaffee or Wasser, so kalt takes the strong -er and -es exactly as it would with no article at all, while meine already marks feminine and plural, so kalt drops back to the weak -e and -en. The same three-way split holds in the accusative, where für mein kaltes Wasser keeps the strong -es (mein still has no ending here) while für meinen kalten Kaffee, für meine kalte Milch, and für meine kalten Getränke are all weak, because meinen and meine both carry endings of their own. Every dative and genitive form is weak across the board, mit meinem kalten Kaffee, wegen meines kalten Kaffees, and so on, since mein always has an ending in those two cases.
Predicate and adverbial adjectives skip all of this
These tables describe attributive adjectives before a noun. Ordinary predicative and adverbial uses follow a different pattern; word position alone is not the grammatical test. Wikipedia's "Deutsche Deklination" article draws the line clearly: the tables describe adjectives used attributively before their nouns; ordinary predicative and adverbial uses are uninflected. Used predicatively, after a linking verb like sein, or adverbially, modifying a verb instead of a noun, German adjectives take no ending whatsoever, regardless of the noun's case, gender, or number. Der Wahn ist kurz, die Reu ist lang, a line from Friedrich Schiller's Das Lied von der Glocke, leaves kurz and lang completely unmarked even though Wahn is masculine and Reu is feminine; an attributive version of the same idea, like der kurze Wahn, would need the weak -e.
French organizes similar noun-phrase agreement without German's extra case layer. French nouns do not inflect for case the way German nouns do, so a French adjective agrees only in gender and number with the noun it modifies, independent of whatever the article is doing; the French articles guide covers how French sorts nouns by definiteness rather than case in the first place. German adds case to gender and number, and the article pattern helps determine the adjective ending.