TL;DR
- To read a large codebase on day one, learn what it is made of and how it starts, find the file everything imports, see where work is happening now, then trace one feature end to end.
- In paperless-ngx (about 200k lines of code), only 166 of 416 Python files are application code, and
documents/models.pyis imported by 49 of those 166. - Tracing one paperless-ngx upload from the browser drop zone to a searchable document took 11 steps across 10 files, found with nothing but
git grep. - For scale: the median public repo with 1,000+ GitHub stars has 513 production source files across 7 top-level modules (repowise's index of 195 such repos, November 2026).
A codebase is everything that makes one piece of software: the source, the config, the build files, and the git history that explains how it got that way. Reading one you did not write is a skill, and most of it is knowing what to skip.
This is the routine I use on the first day in a large repo. To keep it honest I ran every step on a real project I had never read, paperless-ngx, the self-hosted document archive (about 48k stars). Full clone, HEAD 936b1b3 from 9 November 2026, 12,474 commits. Every block below is real output, trimmed only where you see ....
The goal for day one is small. By the end you should be able to say what the system is made of, how it starts, which file everything leans on, where people are working right now, and how one real feature flows through the code.
Step 1: what is this thing, and how big is it
Start with the README, but only the first screen. You want one sentence and the stack.
git clone https://github.com/paperless-ngx/paperless-ngx.git
cd paperless-ngx
head -40 README.md
...
# Paperless-ngx
Paperless-ngx is a document management system that transforms your physical documents into a searchable online archive so you can keep, well, _less paper_.
...
Then the manifests. They tell you the stack faster than any architecture page:
grep -nE 'requires-python|"(django|celery\[redis\]|channels|redis\[hiredis\]|granian\[uvloop\])[~=><]' pyproject.toml
grep -n -i ocrmypdf pyproject.toml
grep '"@angular/core"' src-ui/package.json
8:requires-python = ">=3.11"
22: "celery[redis]~=5.6.2",
23: "channels~=4.2",
29: "django~=5.2.18",
69: "redis[hiredis]~=6.4.0",
95: "granian[uvloop]>=2.7,<2.9",
59: "ocrmypdf[heic]>=17.12,<17.13",
"@angular/core": "~22.2.3",
So: a Django backend, Celery workers on Redis, an Angular frontend, and OCRmyPDF doing the OCR. That is already a mental model with four boxes.
Now the shape. This one-liner counts tracked files per top-level folder, and it works in any repo:
git ls-files | cut -d/ -f1 | sort | uniq -c | sort -rn | head -8
727 src-ui
581 src
142 docker
52 docs
27 .github
7 scripts
7 .devcontainer
1 zensical.toml
Two apps, really. src is the Python backend and src-ui is the Angular frontend. Go one level down in the backend:
git ls-files src | cut -d/ -f2 | sort | uniq -c | sort -rn
302 documents
131 paperless
53 locale
39 paperless_ai
37 paperless_mail
17 paperless_testing
1 manage.py
1 conftest.py
documents is the core app, paperless is the Django project (settings, URLs, parsers), and mail and AI are add-ons. locale is translations, which you can ignore on day one.
File counts include tests and migrations, so for a line count I used scc (cloc and tokei give the same kind of table):
scc --no-cocomo src src-ui docker scripts
───────────────────────────────────────────────────────────────────────────────
Language Files Lines Blanks Comments Code Complexity
───────────────────────────────────────────────────────────────────────────────
TypeScript 438 73533 7257 748 65528 4315
Python 416 147488 11326 14805 121357 6242
HTML 126 10248 308 6 9934 0
Sass 106 4058 662 67 3329 0
...
───────────────────────────────────────────────────────────────────────────────
Total 1133 237616 19760 16040 201816 10569
───────────────────────────────────────────────────────────────────────────────
About 200k lines of code. Big, but a good share of the Python is tests and migrations:
git ls-files 'src/*.py' | grep -c '/tests/' # 192
git ls-files 'src/*.py' | grep -c '/migrations/' # 55
git ls-files 'src/*.py' | grep -vE '/tests/|/migrations/' | wc -l # 166
166 Python files of real application code. That is a much less scary number than 416.
How big is a typical large codebase?
For a reference point: we analysed 195 of the most-starred public repositories indexed on repowise.dev (1,000+ GitHub stars each, 253,688 production source files, November 2026). The median repo there has 513 production source files across 7 top-level modules, with 3.0 import edges per file.
On my run, paperless-ngx has 451 production code files (167 Python, 242 TypeScript, 40 shell, 2 JavaScript) and 3.8 import edges per file. Python is 167 here and 166 above because the index skips src/conftest.py and counts two helper scripts under docker/. So paperless-ngx is a little smaller than the median popular repo and a little more connected. Both numbers mean it is readable in a week, and that a few files will be imported from almost everywhere. Step 3 finds them.
Step 2: how does it start
Every program has a small number of front doors. Find them before you read anything else, because everything else hangs off them.
For a Django project, manage.py is one. For anything shipped as a container, the Dockerfile is the best map you will get:
grep -nE '^(ENTRYPOINT|CMD|EXPOSE)' Dockerfile
250:ENTRYPOINT ["/init"]
252:EXPOSE 8000
/init is the s6-overlay process supervisor, so the real list of processes lives in its service folder:
ls docker/rootfs/etc/s6-overlay/s6-rc.d | grep svc
for s in docker/rootfs/etc/s6-overlay/s6-rc.d/svc-*/run; do echo "== $s"; grep exec "$s" | tail -1; done
svc-consumer
svc-flower
svc-scheduler
svc-webserver
svc-worker
== docker/rootfs/etc/s6-overlay/s6-rc.d/svc-consumer/run
exec s6-setuidgid paperless python3 manage.py document_consumer --skip-checks
...
== docker/rootfs/etc/s6-overlay/s6-rc.d/svc-scheduler/run
exec s6-setuidgid paperless /usr/local/bin/celery --skip-checks --app paperless beat --loglevel INFO
== docker/rootfs/etc/s6-overlay/s6-rc.d/svc-webserver/run
exec s6-setuidgid paperless granian --interface asginl --ws --loop uvloop "paperless.asgi:application"
== docker/rootfs/etc/s6-overlay/s6-rc.d/svc-worker/run
exec s6-setuidgid paperless /usr/local/bin/celery --skip-checks --app paperless worker --loglevel INFO --without-mingle --without-gossip
So paperless-ngx is four long-running processes (Flower is an optional Celery dashboard):
- a web server running
paperless.asgi - a Celery worker that does the heavy jobs
- Celery beat, which schedules recurring jobs
- a
document_consumermanagement command that watches a folder for new files
The frontend has its own front door in package.json:
python -c "import json; print(json.load(open('src-ui/package.json'))['scripts'])"
{'preinstall': 'npx only-allow pnpm', 'ng': 'ng', 'start': 'ng serve', 'build': 'ng build', 'e2e': 'playwright test', ...}
Standard Angular CLI. ng serve for development, ng build for the bundle Django serves.
If a repo has no Dockerfile, look for main functions, [project.scripts] in pyproject.toml, bin in package.json, cmd/ folders in Go, or the CI workflow that starts the app for end-to-end tests.
Step 3: find the file everything leans on
In most codebases one or two files are imported by a large share of everything else. That file defines the vocabulary of the project. Read it early and the rest of the code stops looking like a foreign language.
You can find it with grep. This counts, for each internal Python module, how many production files import it (tests and migrations excluded, each file counted once):
git ls-files 'src/*.py' | grep -vE '/tests/|/migrations/' \
| xargs grep -oE '^\s*(from|import) (documents|paperless[a-z_]*)[a-z_.]*' \
| sed -E 's/:\s*(from|import) / /' | sort -u \
| awk '{print $2}' | sort | uniq -c | sort -rn | head -6
49 documents.models
17 paperless.config
16 documents.permissions
15 documents.utils
14 documents.data_models
12 documents.tasks
documents/models.py is imported by 49 of the 166 application files, nearly three times the next one. It holds Document, Tag, Correspondent, DocumentType, StoragePath, custom fields and saved views. Read the class names and fields, skip the method bodies. That is the data model of the whole product.
Same idea for the frontend, counting project imports (relative paths and the src/ alias), spec files excluded:
git ls-files 'src-ui/src/*.ts' | grep -v '\.spec\.ts$' \
| xargs grep -oE "from '(\.|src/)[^']*'" \
| sed -E "s#:from '.*/([^/']+)'# \1#" | sort -u \
| awk '{print $2}' | sort | uniq -c | sort -rn | head -6
76 bootstrap-icon.component
51 settings.service
46 permissions.service
40 toast.service
30 ui-settings
26 document.service
Here is a lesson I did not expect. The top file is an icon component, and git log says it was added this month:
git log --diff-filter=A --format='%h %ad %s' --date=short -- \
src-ui/src/app/components/common/bootstrap-icon/bootstrap-icon.component.ts
7cdf8ec3c 2026-11-02 Chore: ditch the abandoned ngx-bootstrap-icons, roll our own (#14665)
The team replaced a third-party icon package with their own component, so every component that shows an icon now imports it. Busy, but not the thing to read first. The most imported file is not always the most important one. Look at the top few and pick the one that defines concepts, here settings.service.ts and permissions.service.ts on the frontend and models.py on the backend.
Step 4: where is work happening right now
The code people are changing this month is the code your first ticket will touch, and the code a reviewer will know best. I covered file-level git log commands in an earlier post. On day one I prefer one level up: how many commits touched each area.
# count commits per area (src/<app>, or src-ui as one area), each commit once
areas() {
awk '/^@/{delete seen; next}
NF{split($0,p,"/"); a=(p[1]=="src-ui")?"src-ui":p[1]"/"p[2];
if(!(a in seen)){seen[a]=1; c[a]++}}
END{for(k in c) print c[k], k}' | sort -rn | head -6
}
git log --since="90 days ago" --no-merges --format='@%h' --name-only -- src src-ui | areas
273 src-ui
149 src/documents
86 src/locale
68 src/paperless
29 src/paperless_ai
21 src/paperless_mail
The --format='@%h' line marks where each commit starts, so the awk can count a commit once per area even when it touched twenty files there. The frontend and documents carry most of the work. src/locale looks busy, but those are automated translation commits (144 of the 628 commits in the window have the subject "Auto translate strings"). Add --invert-grep --grep='^Auto translate' to drop them.
Same function, limited to bug fixes over six months. paperless-ngx prefixes fixes with Fix:, so -i --grep='^fix' finds them (318 commits in the window):
git log --since="180 days ago" --no-merges -i --grep='^fix' --format='@%h' --name-only -- src src-ui | areas
143 src/documents
118 src-ui
34 src/paperless_ai
34 src/paperless
17 src/paperless_mail
More fix commits land in src/documents than in the frontend, even though the frontend gets more commits overall. That tells me where to read slowly and where to ask before changing anything.
Step 5: who knows which area
You want to know who to ask, not to rank anyone, so I print counts only. This takes the last 12 months per area, drops bot accounts, and reports how concentrated the commits are:
for a in src/documents src/paperless src/paperless_mail src/paperless_ai src-ui; do
git shortlog -sn --no-merges --since="1 year ago" HEAD -- $a \
| grep -vE '\[bot\]|GitHub Actions' \
| awk -v a=$a '{t+=$1; c[NR]=$1} END{printf "%-20s %3d people, %4d commits, top 1: %2.0f%%, top 2: %2.0f%%\n",
a, NR, t, 100*c[1]/t, 100*(c[1]+c[2])/t}'
done
src/documents 22 people, 451 commits, top 1: 48%, top 2: 94%
src/paperless 19 people, 188 commits, top 1: 51%, top 2: 90%
src/paperless_mail 5 people, 67 commits, top 1: 55%, top 2: 96%
src/paperless_ai 5 people, 82 commits, top 1: 49%, top 2: 96%
src-ui 17 people, 368 commits, top 1: 91%, top 2: 94%
Two people make about nine in ten commits in every area, and the frontend has one main author. That is common for a focused open-source project, and it is useful to know on day one: backend questions go to one of two people, and one person writes most of the frontend. Drop the awk to see the names when you need them. (Pass HEAD explicitly, or git shortlog waits on standard input inside a pipe.)
Step 6: trace one real feature end to end
This is the step that turns a pile of files into a system. Pick one thing a user does and follow it from the button to the database. For paperless-ngx the obvious one is: I drop a PDF in the browser, and later it shows up searchable with OCR text.
I did it with nothing but git grep, starting from the API name and following each call:
git grep -n "post_document" -- src-ui/src src ':!*spec.ts' ':!*/tests/*'
src-ui/src/app/services/rest/document.service.ts:318: this.getResourceUrl(null, 'post_document'),
src/documents/consumer.py:879: f"Creation date from post_documents parameter: {create_date}",
src/paperless/urls.py:150: "^post_document/",
src/paperless/urls.py:152: name="post_document",
urls.py maps it to PostDocumentView in src/documents/views.py. That view writes the upload to a scratch folder and does not process it at all. It queues a job and returns the task id:
async_task = consume_file.apply_async(
kwargs={"input_doc": input_doc, "overrides": input_doc_overrides},
...
)
return Response(async_task.id)
So the work happens in the Celery worker from step 2. Who else queues that same job?
git grep -n "consume_file.apply_async\|consume_file.s(" -- src ':!*/tests/*'
src/documents/barcodes.py:215: task = tasks.consume_file.apply_async(
src/documents/bulk_edit.py:523: consume_file.apply_async(
...
src/documents/management/commands/document_consumer.py:360: consume_file.apply_async(
src/documents/views.py:2214: async_task = consume_file.apply_async(
src/documents/views.py:3539: async_task = consume_file.apply_async(
src/paperless_mail/mail.py:1097: consume_task = consume_file.s(
src/paperless_mail/mail.py:1188: consume_task = consume_file.s(
The web upload, the watched folder (the document_consumer process from step 2), the mail fetcher and bulk edits all funnel into one Celery task. Understand consume_file and you understand every way a document gets in.
Following it the rest of the way, here is the whole path with file and line:
| # | What happens | Where |
|---|---|---|
| 1 | Drop zone or upload widget hands files to a service | src-ui/src/app/components/file-drop/file-drop.component.ts:137 |
| 2 | Upload service wraps each file in form data and calls the REST service | src-ui/src/app/services/upload-documents.service.ts:44 |
| 3 | HTTP POST to /api/documents/post_document/
|
src-ui/src/app/services/rest/document.service.ts:316 |
| 4 | URL route | src/paperless/urls.py:150 |
| 5 |
PostDocumentView.post saves to scratch, queues the task |
src/documents/views.py:3482 |
| 6 |
consume_file runs a chain of plugins: preflight, ASN check, collate, barcodes, workflow triggers, then the consumer |
src/documents/tasks.py:183 |
| 7 |
ConsumerPlugin.run picks a parser by MIME type |
src/documents/consumer.py:405, :468
|
| 8 | Parser registry scores parsers, highest wins | src/paperless/parsers/registry.py:332 |
| 9 | Tesseract parser calls OCRmyPDF |
src/paperless/parsers/tesseract.py:490, :599
|
| 10 | Inside one DB transaction: store the Document, copy files into place |
src/documents/consumer.py:608, :672
|
| 11 | Signal fires, handlers auto-tag, set correspondent and type, run workflows, add to the search index |
src/documents/consumer.py:686, src/documents/apps.py:24
|
Eleven steps across ten files, from the drop zone to a searchable document. The last hop is the one people miss, because nothing calls those handlers by name. They are wired up in apps.py:
git grep -n "document_consumption_finished.connect" -- src
src/documents/apps.py:24: document_consumption_finished.connect(add_inbox_tags)
src/documents/apps.py:25: document_consumption_finished.connect(set_correspondent)
src/documents/apps.py:26: document_consumption_finished.connect(set_document_type)
src/documents/apps.py:27: document_consumption_finished.connect(set_tags)
src/documents/apps.py:28: document_consumption_finished.connect(set_storage_path)
src/documents/apps.py:29: document_consumption_finished.connect(run_workflows_added)
src/documents/apps.py:30: document_consumption_finished.connect(add_to_index)
src/documents/apps.py:31: document_consumption_finished.connect(add_or_update_document_in_llm_index)
...
Django signals, Celery tasks, plugin lists, framework routing: these are the places where "find usages" in an editor comes back empty and the code still runs. When the trail goes cold, search for the string name, the task name or the signal name.
If you can run the app, set a breakpoint in consume_file and upload something. The table above is the map. The debugger tells you whether the map is right.
A shortcut for step 3
I also indexed the clone with repowise, the tool I work on (repowise init --yes --no-prose --no-editor-setup, runs locally, no API key, 3 min 51 s here). Its context command answers the hub question with test importers split out and a layer label:
repowise context src-ui/src/app/components/common/bootstrap-icon/bootstrap-icon.component.ts
| Summary | `bootstrap-icon.component.ts` defines `BootstrapIconComponent`. It is imported by 77 files (1 of them tests).
| Layer | Utility
The 76 non-test importers match the grep count, and "Utility" is the hint I needed git log for. For open-source projects that are already indexed, repowise.dev/explore shows the same graph and history without cloning anything.
What should you write down after day one in a new codebase?
Keep it to one page, in your own words. Mine for paperless-ngx:
- What it is: a Django + Celery + Angular app that turns uploaded or scanned files into an OCRed, tagged, searchable archive.
- Front doors:
paperless.asgi(web), Celery worker, Celery beat,manage.py document_consumer(folder watcher). Frontend:ng serve. - The vocabulary file is
src/documents/models.py. On the frontend,settings.service.tsandpermissions.service.ts. - Work is happening in
src-uiandsrc/documents, and most fix commits land insrc/documents. - Who to ask: two people per backend area, one main author for the frontend.
- One traced path, the 11-step table above.
- Skipped on purpose:
locale/, migrations, tests, thedocker/composevariants, the AI and mail apps. - Open questions. How the parser registry handles a parser from a third-party package. What the ASN check does. Why the plugin chain runs
AsnCheckPlugintwice (the comment says "Re-run ASN check after barcode reading", which I want to understand).
The open questions are the most useful part. They are your reading list for day two. For the rest of the week (getting it running, sketching modules with owners, shipping a first small change), I follow this five-day plan for learning a new codebase.
Which feature would you trace first in a repo like this one, the happy path or the one that breaks most often?
How I ran this
Full clone of paperless-ngx/paperless-ngx at 936b1b3 (9 November 2026, 12,474 commits), commands run on 10 November 2026 in Git for Windows bash. scc 3.5.0, repowise 0.60.1 (init --yes --no-prose --no-editor-setup, 3 min 51 s). The production file count (451) and edges per file (3.8) come from that local index, using repowise's stored code-origin labels (tests, tooling and generated code excluded). The 513 / 7 / 3.0 medians come from a set of 195 of the most-starred public repositories indexed on repowise.dev (1,000+ GitHub stars each, 253,688 production source files, November 2026), each measured at its own latest index. Author names were looked up to remove bot accounts and are not printed anywhere above.
FAQ
What is a codebase?
A codebase is all the source code, config, build files and version history that make up one piece of software. In paperless-ngx that means a Django backend in src, an Angular frontend in src-ui, Docker setup and docs, plus 12,474 commits of history.
How do you read a large codebase as a beginner?
Do not read it top to bottom. Find the entry points, read the most imported file for its names and fields only, and trace one user action from the UI to the database with git grep. Write down what you skipped and what you still do not understand.
How do you read code you did not write?
Start from what the code does for a user, not from the folder tree. Follow one real feature through the files it touches, and when "find usages" comes back empty, search for the string name of the task, signal or route instead.
Top comments (1)
I use zread.ai 😃