〜ところだった
Nearly, almost… (but didn't happen)machine translation
FormationVerb dictionary form + ところだった (usually with もう少しで)
〜ところだった expresses that something (usually something bad) very nearly happened but luckily did not: 電車に乗り遅れるところだった (I almost missed the train). The verb before it is usually in the dictionary form even though the event belongs to the past — it's ところだった itself that carries the past meaning.
This pattern very often pairs with もう少しで (just a little more and…) or 危なく to stress how close a call it was: もう少しで忘れるところだった (I very nearly forgot). The first clause also often contains the たら・ば conditionals you learned at N4: 教えてくれなかったら、忘れるところだった (if you hadn't told me, I would have forgotten).
Don't confuse it with 〜るところだ, which marks the moment of being "about to do something": これから食べるところです talks about the actual present, whereas 〜ところだった always implies "that outcome did NOT happen." Thanks to this "escaped by a hair" nuance, the sentence usually comes with a feeling of relief or a close shave.
Examples
もう少しで電車に乗り遅れるところでした。
I very nearly missed the train.
車にぶつかるところだったよ。気をつけて。
You almost got hit by a car! Be careful.
教えてくれなかったら、大切な会議を忘れるところでした。
If you hadn't reminded me, I would have forgotten an important meeting.