6 Then the Lord said to Cain, “Why are you angry? And why has your countenance fallen? 7 If you do well, will not your countenance be lifted up? And if you do not do well, sin is crouching at the door; and its desire is for you, but you must master it” (Gen 4:6-7, NASB).
As two commentators explain:
In this understanding the expression reverses the earlier imagery of Cain's "downcast" face. When Cain practices what is right, there will be an uplifted face… K. Mathews, Genesis, 1:269-70.
"It will be lifted up"–this probably refers to Cain's face, which has fallen. In other words, his countenance will no longer be one of despondency and dejection. However, if Cain continues to do wrong, then sin will hound him–sin is lurking, waiting to pounce. J. Currid, Genesis, 1:145.
Among other things, this is a reference to depression. To my knowledge, it's the first reference to depression in world literature.
Then there's the additional image. It may depict sin/depression as a predator that's lying in wait on the porch.
Some commentators think this alludes to the Mesopotamian tradition of a doorway demon. One prima facie problem with that interpretation is the anachronism. If this preserves a real conversation between God and Cain, then there was no such Mesopotamian tradition at the time God spoke to Cain.
In principle, the Mesopotamian tradition could be based on something much earlier. And a demonic presence would dovetail nicely with Gen 3.
Still, there's nothing in the imagery that implies that. It can easily be taken to be a personification of sin/depression as an ambush predator. The point of the doorway metaphor is that doors function to keep things out. It marks the barrier between inside and outside. The moment you open the door you either risk letting unwanted intruders inside, or you leave the safety of your shelter to venture out into the unprotected wild.
Connecting this to the theme of depression, for people who suffer from it, depression is like a crouching predator that waits for you, stalks you. You may shake it off, but you never know when it will return. You may face it when you get up in the morning. It follows you, shadows you, overshadows you. Just when you think you put it behind you it's right around the corner. A very apt metaphor for depression.