The is a certain way of talking where you can end just about anything you say in わけ.
What is the sentence structure for this way of talking?
While sawa's answer does cover the basic construction rules, it's definitely worth it to go over the different use cases of わけ. Grab a comfy chair and your favorite beverage, because this is a long one.
The best and most complete analysis I've found of this use of わけ is in this 2001 paper by Atsuko Yokota:
It's freely available as a PDF (yay!) but it's entirely in Japanese (hrm), so the best I can give you here is a summary of the five (yes, five) distinct uses of わけだ which Yokota lists.
Yokota's Differentiation of わけだ
Diagrammatically, Yokota charts out the first four uses of わけだ in her paper. Here is a clarified and prettified version:
1. Marks a logical conclusion or result based on some known fact
The common thread in this type of sentence is that a known fact Y is used as the logical basis for a conclusion Z:
2. Marks a reason or cause for some matter
This is like the first use, only in the opposite direction. We take some known fact Y, and use わけ to mark X, the reason for or cause of Y:
3. Marks the speaker's acceptance/acknowledgement of some truth
This is a little more complicated than the first two uses. Essentially, we again start with some known fact Y (which may be unspoken). An answer for why Y is true is presented as X, and this leads to the conclusion that X naturally yields Y:
4. Marks a restatement of some fact
This is one of the simplest uses of わけ. Here, a known fact Y is restated or presented from a different angle as Yʹ. Often you'll find this use of わけ paired with つまり:
5. Does something entirely untranslatable
Unfortunately, there has to be a catch-all category, since わけ gets used kind of like a sentence-final particle without any significant effect on the meaning of the sentence. Even Yokota admits that "speakers often use [わけ in this way] unconsciously."
This わけ doesn't fit nicely into any of the four preceding categories. You might think it falls under #1 (a conclusion based on some known fact), but this sentence isn't a conclusion of anything; it's merely a statement of some known fact, without any connection. We could, in fact, remove わけ entirely, without affecting the meaning, by replacing 暮【く】らしたわけです with 暮【く】らしました.
Inside this category is the use of わけ to set up a context or prologue for a succeeding statement. We find ～のだ being used in a similar way:
Here, わけ marks a prologue ("I specialize in history") and provides the foundation for the following statement: it informs the listener of how qualified the speaker is to make such a statement. わけ could be replaced by の (ん) in this example.
Forming Sentences with わけだ
The rules for わけ follow the normal rules for forming a subordinate clause before a noun: the clause must end in a plain form, with the exception that (plain present) な-adjectives connect to わけ with な, and (plain present) nouns can connect with either な or (less commonly) の:
Often the speaker will use という to "wrap up" the preceding clause (or sentences) and use it to modify わけ (というわけだ). This doesn't change the usage, and the rules for using という are the same as those for the use of と to mark a quote or thought. This use of という is often used at the beginning of a sentence as a transition:
This is especially common in TV or radio shows when the host needs to press the show forward or move on to the next topic. The という wraps up the preceding statements into わけ and essentially means, "Now that all this has been said, let's move on." というわけで has the following colloquial forms:
ということで is also used as a transition with a meaning similar to というわけで.
Negative Forms of わけ
There are at least four negative forms of わけ, each with slightly different meanings. One is using わけだ after a negative clause, which shows up in the examples here. This answer is getting too long to cover these, so I will simply list the other three here and wait for those interested in more complete explanations to ask a question:
In actual usage, it does not mean much, but is used when you want to establish intermediate steps for explaining something.