To read a legacy Python codebase on day one, do not try to understand everything. Pick one real request, follow it from the URL route to the database query and back, and write down each file you touch. Repeat that with two or three requests and you will have a working map of the project, which is exactly what a mentor wants to see by the end of week one.
This guide gives you a step-by-step code-exploration worksheet, a table of what to look for in each layer, a worked illustrative trace, and a module-map template you can share with your mentor. It is built for a 14-day internship, so the plan is paced across two weeks.
Why a single request trace beats reading files top to bottom
Legacy projects rarely have tidy documentation. Folders are named after features that no longer exist, some helpers are copied in three places, and the original authors have moved on. Reading alphabetically through folders gives you hundreds of facts and no picture.
A request trace gives you a spine. Every web backend, whether Flask, Django, FastAPI, Bottle or a hand-rolled WSGI app, does roughly the same thing: it receives an HTTP request, matches a route, runs some handler code, talks to a data store, and returns a response. If you follow one path through that chain, each file you open has a reason to be open, and you learn the project’s conventions along the way.
The trace also produces something concrete. At the end of a day you can say, “I traced POST /orders and here are the seven files involved,” which is far more useful to a mentor than “I read a lot of code.”
Before you open the code: setup checklist for the first two hours
Spend the first two hours gathering context rather than reading source. Work through this list in order.
- Find the entry point. Look for
manage.py,wsgi.py,asgi.py,app.py,main.pyor aProcfile. These tell you how the app is launched. - Read the dependency file. Open
requirements.txt,Pipfile,pyproject.tomlorsetup.py. The framework and its version tell you which conventions to expect. A very old pinned version may mean old syntax such as Python 2 style print statements orurllib2. - Check the Python version. Look for a
.python-versionfile, a Dockerfile, atox.inior a CI config. Running modern Python against old code is a common source of confusing errors. - Read the README and any docs folder, even if outdated. Note what is stale; that is useful information for your mentor.
- Look at the tests folder. Test names are often the best available description of intended behaviour.
- Skim the git log if history exists.
git log --oneline -20shows what the team changed recently, andgit log --stat -5shows which files change together. - Ask for a working environment. Ask your mentor for the settings file or environment variables needed to run the project locally, and for a safe test database. Never point a learning exercise at production data.
Free 2-Week CareerSwami Internship
Online, 14 days, with a free offer letter and a free completion certificate once you finish the work. Check with your college that it fits your requirement before you enrol.
The route-to-database code-exploration worksheet
Use this worksheet for each request you trace. Copy it into a notes file, one copy per request. The steps are deliberately ordered from the outside of the system inward.
Step-by-step trace procedure
- Choose the request. Pick something small and real, such as “log in”, “list items” or “create a record”. Avoid payment or reporting flows on day one.
- Find the route. Search for the URL fragment. In Django look in
urls.py; in Flask search for@app.routeoradd_url_rule; in FastAPI search for@router.getor@app.post. A command likegrep -rn "orders" --include=*.py .is a reasonable start. - Identify the handler. Note the function or class that receives the request. Record file name, function name and line number.
- List the inputs. What does the handler read: query parameters, JSON body, form data, headers, cookies, session? Write each one down.
- Find middleware and decorators. Check for authentication, permission checks, rate limits, logging or request transformation that runs before the handler body.
- Follow each function call one level at a time. Write down every call that leaves the handler file. Do not go deeper than two levels until you have the whole outline.
- Find the data access layer. Look for ORM models, raw SQL strings, a repository or DAO class, or a database cursor. Note whether the project uses SQLAlchemy, Django ORM, psycopg2, PyMySQL or something custom.
- Record the actual query. For ORM code, work out what SQL it produces. In Django,
str(queryset.query)helps; in SQLAlchemy, enable echo logging in a local environment. - Identify the tables and columns touched, and whether the operation reads or writes. Writes deserve extra attention: look for transactions, commits and rollbacks.
- Follow the return path. How is the result turned into a response: a serializer, a template, a
jsonifycall, a manual dictionary? Note status codes and error handling. - Note side effects. Look for emails, queue messages, cache writes, file writes, signals or calls to other services.
- Run it and confirm. In a local environment, send the request with a tool such as curl or a REST client, then compare real behaviour against your notes. Fix the notes, not the code.
- Write three open questions for your mentor, for example why a field is stored as a string or why a helper is duplicated.
What to look for in each layer
| Layer | Typical files or markers | What to record | Question to ask yourself |
|---|---|---|---|
| Route | urls.py, routes.py, decorators, blueprints |
URL pattern, HTTP method, handler name | Is there more than one route that reaches the same handler? |
| Middleware and auth | middleware.py, decorators, dependency injection |
Order of execution, who is allowed in | What runs before my handler that I did not write down? |
| Handler or view | views.py, handlers.py, controllers |
Inputs, validation, calls out | Does it contain business logic, or does it delegate? |
| Service or helper | services/, utils.py, helpers/ |
Function signatures, shared state | Is this logic reused elsewhere? |
| Data access | models.py, db.py, dao/, SQL strings |
Tables, columns, query type, transactions | Is user input ever concatenated into SQL? |
| Response | serializers, templates, jsonify |
Shape of output, status codes, error paths | What does the caller see when something fails? |
| Side effects | signals, tasks, Celery, cache calls | What else changes beyond the database | Would a retry cause duplicate effects? |
A worked trace of one request (illustrative)
The following example is illustrative only. The project, file names and line numbers are invented to show how notes should look, and no code was run for this article.
Suppose your mentor gives you an old Flask inventory app and asks you to understand “add a product”. Your notes after one hour might read like this:
Request: POST /products
Route: app/routes/products.py : add_product() (decorator: @bp.route("/products", methods=["POST"]))
Auth: @login_required from app/auth.py (checks session["user_id"])
Inputs: JSON body -> name, sku, price, quantity
Validation: manual if-statements in add_product(); no schema library
Calls out:
1. utils/pricing.py : normalise_price(price)
2. models/product.py : Product.create(name, sku, price, quantity)
Data access: Product.create() builds a raw INSERT string using % formatting
Table: products (name, sku, price, quantity, created_at)
Write: yes; commit inside Product.create(), no explicit rollback
Response: jsonify({"id": new_id}), status 200 (not 201)
Side effects: writes a line to logs/audit.txt via utils/audit.py
Open questions:
- Is SKU uniqueness enforced by the database or only by convention?
- Why does Product.create() build SQL by string formatting?
- Is the 200 status relied on by any client?
Notice what this trace achieves. In an hour you have identified a possible SQL-injection risk, a missing rollback, a status-code oddity and a file-based audit log, without changing a line. You also have three good questions. Raise them politely as questions; the team may already know about them and may have reasons you cannot see yet.
Module-map template to share with your mentor
A personal module map is a one-page summary of what you believe each part of the project does. Update it daily and send it to your mentor so they can correct misunderstandings early. Mark every entry with a confidence level so the mentor knows where to spend their time.
Template table
| Module or folder | My understanding of its job | Key files | Depends on | Used by | Confidence (high / medium / low) | Open question |
|---|---|---|---|---|---|---|
(example) app/auth.py |
Session login check used as a decorator | auth.py |
Flask session, users table | All routes in routes/ |
Medium | Is there a token-based path too? |
| (your row) | ||||||
| (your row) |
Header block to paste above the table
Project:
Python version:
Framework + version:
Database:
How to run locally:
Requests traced so far:
Biggest unknown today:
What I will trace next:
Tips for sharing the map
- Keep it to one page. A mentor will read a short map; they will skim a long one.
- Use plain text or a shared document the mentor already uses.
- Separate facts you confirmed by running code from guesses made by reading.
- Send it at the end of each day, with no more than three questions.
Reading techniques that save time in old Python code
- Search before you scroll. Use
grep, your editor’s project search, orgit grepto find every use of a function name. - Use the debugger rather than print guesses. Put a breakpoint in the handler and step through.
pdbworks everywhere: addimport pdb; pdb.set_trace()in a local copy, or usebreakpoint()on Python 3.7 and later. - Read tests as examples. A test that calls a function shows valid inputs and expected outputs.
- Watch for dynamic behaviour. Decorators,
getattr, monkey patching, signals and metaclasses hide the call path. When a function seems never to be called, search for its name as a string. - Check configuration files. Behaviour often changes between
settings_dev.pyandsettings_prod.py. - Mind the dead code. Not every file in the repository is live. Confirm a file is imported somewhere before investing time in it.
- Record, do not refactor. Your first fortnight is for understanding. Tidy-ups can come later, with the team’s agreement.
A 14-day plan for getting comfortable with an unfamiliar backend
The free two-week online internship from CareerSwami runs for 14 days, so pace your reading to fit. Treat this as a suggested schedule, not an official syllabus, and adjust it to the tasks your mentor sets.
| Days | Focus | Output to share |
|---|---|---|
| 1 | Setup checklist, entry point, dependencies, run locally | Header block of the module map |
| 2-3 | Trace one read-only request end to end | First completed worksheet |
| 4-5 | Trace one write request, including transactions and side effects | Second worksheet; first draft of the module map |
| 6-7 | Read tests for the traced areas; note gaps | List of untested behaviours |
| 8-9 | Trace an error path and an authentication path | Notes on failure handling |
| 10-11 | Pick a small mentor-approved task, such as a log line, a test or a docstring | Small change proposed for review |
| 12-13 | Revise the module map using what you learned | Final map with confidence levels |
| 14 | Summarise: what you traced, what you still do not know, what you would read next | One-page handover note |
On completion, CareerSwami provides a free offer letter at the start and a free completion certificate after successful completion. The internship carries no stipend, and nothing here should be read as a promise of academic credit, placement or a job.
Mewar University B.Tech students: fitting code-reading practice around your scheme and placement cell
If you study at Mewar University, it helps to know how internship-style work is described in the official documents you can actually read. The university’s 2017-18 B.Tech CSE scheme and syllabus lists Industrial Training/Project (CSE-421/422) in the combined seventh and eighth semester block, with 16 credits and 400 marks split across internal, external and viva-voce components. The same block carries a 4-credit Comprehensive Viva-Voce. That document is from 2017, so your own batch may follow a different scheme; check the current version before assuming anything applies to you.
In practice, a viva-voce component rewards students who can explain what they built or studied. A request-trace worksheet and a module map are good raw material for that: they show you can read unfamiliar code and describe how its parts connect. Whether a short online internship can count toward any university requirement is not something the available documents settle, so treat this as skill-building unless your department says otherwise in writing.
The university’s Training and Placement Cell page says the cell was established in 2011 and that it has brought industry recruiters to campus. The page is brief, so use the cell as a source of current guidance rather than assuming particular recruiters or outcomes. Separately, the T&P site hosts yearly lists of a Six Months Industrial Internship Program, for example 2016-17, which suggests a longer internship model existed for some programmes in earlier years. Excerpts of the university’s Self Study Report also mention internships, but treat those details as unconfirmed until you read the report itself.
Verification steps for Mewar University students
- Ask your department office which scheme and syllabus year applies to your batch, and request the current PDF.
- Email your department coordinator asking, in writing, whether a CareerSwami-style online internship can be recorded in your internship or project documentation, and which proof they require.
- Ask the Training and Placement Cell which documents (offer letter, certificate, report format) they expect for any external internship.
- Confirm the semester in which industrial training or project work falls for your programme, and its evaluation split.
- Keep copies of your module map, worksheets and any mentor feedback so you can speak about them in a viva or interview.
Frequently Asked Questions
How long should I spend tracing one request?
Plan on one to three hours for a simple read request and longer for a write that triggers side effects. If you are stuck for more than 30 minutes on one step, write down the question and move on; ask your mentor in your daily message.
What if the project has no tests and no documentation?
Then your traces become the documentation. Rely on the route table, the git history and running the app locally. Record what you confirmed by execution separately from what you inferred, and ask your mentor which flows matter most.
Should I fix bugs I notice while reading?
Note them first and mention them to your mentor. Legacy code often has hidden dependencies, and an obvious fix can break something elsewhere. Make changes only when asked, in a branch, with the team’s review.
How do I trace a request when the framework uses a lot of magic?
Use a debugger breakpoint in the handler and inspect the call stack to see which framework layers ran before it. For ORMs, enable query logging in a local environment to see the exact SQL instead of guessing from model methods.
Is it safe to run the legacy app on my laptop?
Only with a local or dedicated test database and dummy credentials. Ask your mentor for a sanitised configuration, never use production secrets, and check the code for jobs that send emails or call external services before you start it.
What if the code is in Python 2?
Ask your mentor which interpreter the project actually runs on. Python 2 reached end of life years ago, so use an isolated environment such as a virtual environment or container for it. Do not install old packages into your main system Python.
How detailed should my module map be?
One line per module or folder is enough at first. Add detail only where you have traced a request. A map that is honest about low confidence areas is more useful than a confident but wrong one.
Can this internship replace my college’s industrial training requirement?
Do not assume so. The CareerSwami internship is free, two weeks long and comes with an offer letter and completion certificate, but it does not carry academic credit. Ask your department in writing whether and how it can be recorded for your scheme.
Related Python & Backend Engineering guides
- Pandit Deendayal Upadhyaya Shekhawati University Students: Building a Backend Internship Project Around Local Business Needs
- Chitkara University Students: Writing API Documentation Recruiters Actually Open
- Central University of Gujarat Students: Asking Better Questions of Your Backend Mentor
- All Python & Backend Engineering internship guides
Ready to put this into practice?
Join the free two-week CareerSwami online internship in Python & Backend Engineering. The internship, the offer letter and the completion certificate are free.




















