Documentation for Purescript Compiler?

Is there a documentation for purescript compiler or even a design document which can help in understanding the codebase?

None that I know of. Still, be sure to start in app/Main.hs, so you can follow the functions/values it calls/uses.

Cool thanks. I was just doing that.

Is the general flow of the program like this?
Tokenize --> Pattern match on tokens --> Create JS AST --> Parse AST --> Get JS code?

I see that the patterns are being matched in CodeGen/JS.hs file, especially the binderToJs' functon.

If I want to say have a custom JS function and create all PS data constructors with it, how do you think I should proceed?