It's pretty much all in this function:
https://github.com/bitcoin/bitcoin/blob/master/src/wallet/walletdb.cpp#L322The wallet.dat is either a BerkeleyDB database, or a SQLite database, depending on whether you have decided to make a descriptor wallet (SQLite if so).
The database is used as a key-value store, where every key always begins with a length prefixed ascii string indicating the type of the record. From there, the data stored depends on the record type and is just a bunch of different objects serialized. You will have to look at each object's serialization methods to figure that out.
BerkeleyDB is a key-value database so libraries for it provide access to that directly. For SQLite, the database is a single table with two columns, the first named "key" and the second "value".