Well for a spell checker I think that you will need a database that conatins all the words you want, and have a facility to allow users to add words into this dictionary.
Then as the user types in words they are compared with words in the dictonary, and if there is a match then the work is correct, otherwise it will be a spelling mistake. Then it will prompt the user to correct it.
Also for a little more advanced functionality; assuming the word isn't in the dictionary, you can have the program compare the work with other words in the dictonary and have it list those words in the dictionary that most resemble the word that is wrong. That way you can give the user some suggestions to correct the word.
Then you can also add some automatic corrections, ex. a lot of people sometimes right "teh" instead of "the" so have the program automatically change it.
There are a lot of stuff you can do, but I think that this is the basic framework of a spell checker.
About the grammer thing I have no idea. Maybe have a list of nouns, verbs and so on each in a different dictionary, then make sure that they come in a specific order to make a correct sentence or so on. So you would check from a starting "." to an edning "." and that makes one sentence; so the program checks between those that there is a verb, noun, and so on in a specifc order to make a correct word.