Having been the person who made the replay mod, I'll leave what I remember:
It's actually much easier than it would look like as the game already tries to convert the game state into a byte string and vis-versa for networking, so all that's really needed is to fork and store the stream of bytes sent every frame. This is easiest on the server, I have not implemented it on the client as the client never receives something en masse, it calls for data piecewise. It should still be possible in theory by modifying the receiveMessage function (or whatever it's called).
Displaying a replay is done by taking a client and hacking the receiveMessage function to take all data from the file. The client then automatically converts that into a game, and simple locking to TEAM_SPECTATOR prevents the watcher from influencing the game, and also removes HUDs etc. Fast-forward can be done by raising the game fps.
It's also necessary to be able to separate different frames of input so that the client doesn't "receive" everything in one frame. I did this with a length-prefixing, maybe there's a better and more stable way.