r/learnprogramming • • 17d ago

Developers often struggle with unfamiliar GitHub projects

Hey there, I have run into this problem a few times. I'd clone/fork a GitHub repository that had something useful for me, but the project structure was often so confusing that I couldn't figure out what anything did or where to start. Most of the time, I'd just give up on it. I was wondering if any of you have experienced the same thing and how do you usually deal with it? Do you use any specific tools, or do you just explore the codebase manually?

17 Upvotes

13 comments sorted by

5

u/AndrewNggg 17d ago edited 17d ago

That’s a skill in itself, for me personally I go to the main files, look at indexing, look at services, etc see how it’s put together where the logic lives, you click something what happens where’s the flow etc

If I need to work on the project to make changes I will add print logs

2

u/teerre 17d ago

Familiarity is the eye of the beholder. Just because it's unfamiliar to you, it doesn't mean it's bad. In fact, just because it's unfamiliar to most people it doesn't mean it's bad. You can only judge the structure and organization of a project after you understand why it's the way it is

As for getting better at it, just like anything, it's practice. The more different patterns, different languages, different styles you know, the less likely you'll be surprised by some random github project

2

u/pixel293 17d ago

When I'm looking at new projects it's because I'm fixing a bug, updating a feature, or adding a feature. In the bug case, I'm not focusing on the whole project, just the function that either has the bug or the function(s) that call the function with the bug, I ignore everything else. Same basic idea with a updating a feature, I'm only focusing on the functions/structs related to that feature. Adding a feature means looking at the another feature that is close or does some of the same stuff, and just understanding how that feature is implemented, so I can implement the new feature.

Do this enough times with a project and you start understanding the whole project. So really it's just constraining your scope, only focus on what you need to focus on to achieve your goal. Don't try to understand the whole project, that will come with time. Also don't under estimate the benefit of stepping through code as it is running and sometimes looking at the call stack can give you a very clear idea of the path the code takes.

1

u/xchino 17d ago

Do you know the technology it was created with? Knowing the norms of how a language or framework works is hugely helpful, even the project not following them is useful info. Even just knowing where the entrypoints are is very helpful. Look for and read any markdown files in the project, especially any related to build info as that often plainly lays out the tech stack involved. Aside from that, running a typical grep looking for strings related to what I'm interested in is usually one the first steps. Then attaching a debugger or inspecting the running version while I'm browsing the project structure if applicable. I will run it through a small, fast local LLM and treat the results as speculative, and saving that I will ask a frontier model and still treat the results a speculative. If after all of that I am still in the weeds I will join a discord or community for the project if there is one and ask there, I usually want to bug another human about it as a last resort. After that you have to ask yourself "If this project is so incomprehensible is it worth whatever you wanted to do with it?" and if that's a yes you just put your head down and start reading code and taking notes.

1

u/Amuro_Ray 17d ago

What do you mean by had something useful for you?

Most of the time I just read the Readme then do ripgrep for what I need. It's also not something I often have to do without knowing the specific thing I'm looking for

1

u/ledatherockband_ 17d ago

Find a part of the app you like. Trace the happy path of a feature end to end. Do that for other features you are interested in.

1

u/Comprehensive_Mud803 17d ago

It’s experience and mostly a reading skill.

Most projects follow a certain convention. Recognizing this convention is a matter of experience, the rest is being able to read the code.

Personally, most of the time, I don’t even clone the repo, but I explore it online.

1

u/josephjnk 17d ago

I don’t generally read repos unless I have some specific reason, like debugging an issue or trying to add a specific feature. Generally I first try to find the area that’s immediately relevant and then I zoom out from there as needed until I have the context necessary. Trying to understand the project as a whole up front is usually an easy way to burn a lot of time and effort without making much progress.

1

u/droefkalkoen 17d ago

If you're a visual learner, try replacing 'GitHub' in the link to the repo with 'Gitdiagram'. It will build a diagram of how all scripts and components interact.

DeepWiki is similar: it uses AI to parse the contents of a repo and shows the content in a wiki-like format. You can ask questions about the repo as well.

-3

u/Available_Safe1818 17d ago

This is why I think the advice for beginners to contribute to open source projects is nuts.