How to learn about the design of TiDB’s code infra?

Says I was trying to add some fields and methods to the session struct, then I found I was aware of nothing about the struct except it’s a “Context” shared through the whole TiDB codebase.

I’d like to know how it was created, should it be thread safe, will it always be Closed before released, where it can be accessed, etc.

Is there any documentation about this?