The X-bar theory is used when performing syntactic analysis on a phrase or sentence usually in the form of a syntactic tree. Essentially what this theory states is that there are syntactic features that are common to all human languages, one structural similarity of which is the "x-bar"
Essentially what you do is use X as an arbitrary lexical category, which can later become an N, V, A, or P (noun, verb, adjective, preposition respectively). The rules of X-bar theory are as follows:
1. An X Phrase consists of an optional specifier and an X-bar, in any order:
2. One kind of X-bar consists of an X-bar and an adjunct, in either order:
3. One kind of X-bar consists of an X-bar and an adjunct, in either order:
Applying these rules we can know that:
A sentence is always composed of a noun phrase, and a verb phrase (rule two).
A verb phrase is always composed of a verb and a complement (rule 3).
A noun phrase can be composed of adjective phrases, and must contain a noun (rule one).
Prepositional phrases must contain a preposition and a noun phrase (rule one).
The same goes for adverb phrases.