General advice: be it a web app or low level cryptography library in rust or a unity game.<p>Always run it first! And I mean run from the code you downloaded and built (not prebuilt binaries). Then try to debug it.<p>Also read every bit of documentation you can get your hands on.<p>Remember many will be built idiomatically, for example if tailwind is being used your life is easier if you read the tailwind docs and come back to the repo rather than try to figure it out yourself. The more idioms being used you know, the easier it is to understand, and the less surface area of unknowns there are.
It depends on the project and what you are looking for.<p>If I’m looking out of curiosity I either try to find the entry point and/or the “core” logic (the code that does the main thing the project does).<p>But usually I’m interested in something specific and then I’ll use search or click around based on naming. Then it’s mostly just tracing function calls until you find what you are looking for.<p>Some tips:<p>- Read the docs if available!<p>- Read docs on the language/framework/libraries used<p>- package.json and similar requirement files contain a lot of info<p>- Knowing “standard” structures for languages and frameworks helps: for example phoenix projects often have similar structures<p>- Searching often works really well if you know a name or keyword<p>- If it’s a webapp or website, the browser devtools can reveal class names, api routes and other things that you can search for in the code<p>- Generally interfaces (ui, cli, apis etc) are great starting points to find out how things work<p>I think the way to learn it is to do it a lot. Important is to have a purpose: fix a bug, figure out how it works, make a change. Reading code without purpose is not that useful imo.<p>And write more code, debug more, learn new languages and frameworks (do make sure to also specialize, aim for T shape).
Usually I search for something which is exposed to the user of the repo (particular CLI command, particular interface or function, particular GUI element, ..) because I want to understand how that part works and to me there's no better way to achieve that than starting where the user starts .<p>Repeat this enough and architectural patterns reveal themselves naturally.
It's a bit older, but <i>Code Reading: The Open Source Perspective</i>, by Diomidis Spinellis, is my go-to. <<a href="https://www.spinellis.gr/codereading/" rel="nofollow noreferrer">https://www.spinellis.gr/codereading/</a>>
I look at the database schema and data structures first. That will tell me what I need to know about the domain entities. Open source or not, data structures usually tell me more than reading the code.