Diatonic Harmony question

Hello. I am relatively new to this forum but had a question while reading a magazine and thought this would be a great place to ask it.
Question:
The magazine refrenced to diatonic harmony, it actually got quite into it, but it did not get into how it could be applied. I understand the idea of the I, IV, and V chord being major and the II, III, and the VI being minor. But how would I go about using those, the notes that they encompass and so forth, in a song/jam/practice?

It, the article, also touched on how to decipher which key the music was in based on diatonic's. And once again how could these be applied?

It's great that you want to get deeper into the music. And it's pretty easy to get into the mathematics of everything and lose sight of the fact that music is an aural art form. All any kind of music theory (legit, jazz/pop functional harmony, etc.) tries to do is describe the tendency of certain sounds to act in certain ways.

Daitonic harmony is just referring to the manner in which chords are built in the same key. If you take the C major scale

Functional harmony will give you some direction when you're trying to determine where you are pointing when you get a non-diatonic chord in a progression. Say you're in C major and suddenly you hear a D7 chord (D F#A C). Well there's no F# in C major, right? And any chord built off of the second scale degre would need to be a minor seventh chord if it was diatonic to a major key, right? So what key would have a dominant chord based on a D root? Gmajor or G minor would be my first thought.

So don't think of these things as "rules to be applied", think of them as guidelines. We're playing in C major, what other chords can I use to give this some movement? We're in C major, how can I imply movement to another key? We're in Cmajor and moving between C major and F major, what notes can I play besides the roots? Besides the other notes in each chord? How can I make a melodic line that incorporates notes form both chords?