Skip to content

Note Template

Every subtopic page in this vault uses this exact structure. Don't rearrange sections — the consistency is what makes recall fast (you'll always know section 3 is the diagram, section 7 is the cheatsheet, etc.).

To start a new note: copy everything below the horizontal rule into a new file (e.g. docs/fastapi/04-dependency-injection.md) and fill in each section.


{{ Topic Name }}

1. Why this matters

What real problem does this solve? Where would you actually use it? Be concrete — name a use case, not "it's important."

2. Mental model

The whiteboard explanation. Use a plain-English analogy. If you can't explain it without code, you don't understand it yet.

3. Architecture / Flow

flowchart LR
    A[Input] --> B[Process]
    B --> C[Output]

Replace the placeholder with a real diagram — request lifecycle, data flow, state machine, class relationship, whatever fits.

4. Core concepts

  • Concept A — one-line definition. Mini example.
  • Concept B — one-line definition. Mini example.
  • Concept C — one-line definition. Mini example.

5. Code — minimal working example

The smallest snippet that runs end-to-end and demonstrates the concept. No error handling, no boilerplate — just the idea.

# Minimal example

6. Code — real-world pattern

How this is actually used in production. Includes validation, error handling, edge cases, and the kind of stuff you'd see in a real repo.

# Real-world pattern

7. Common pitfalls

  • Pitfall 1 — what goes wrong, why, how to avoid.
  • Pitfall 2 — …
  • Pitfall 3 — …

8. When to use vs not use

Use when Don't use when
Concrete scenario A Concrete scenario X
Concrete scenario B Concrete scenario Y

9. Cheatsheet

A tight, scannable reference. Tables work great here.

API / Syntax What it does Example
do_thing() One-line description do_thing(42)
other_thing

10. Q&A — recall test

Write 3–5 questions you should be able to answer cold after reading this page. Test yourself before moving on.

  • Q: What happens if X? A:
  • Q: What's the difference between X and Y? A:
  • Q: When would you choose X over Y? A:

11. Predict the output

A short challenge — the reader guesses what the code will print, then checks.

What does this snippet print?

Expected: [1, 4, 9]

nums = [1, 2, 3]
print([n ** 2 for n in nums])

12. Fix the bug

Drop in a snippet that's almost right. The reader edits it until the output matches expected.

Square the numbers

Expected: [1, 4, 9]

nums = [1, 2, 3]
print([n * 2 for n in nums])   # bug: should be n ** 2

13. Quiz — Quick check

3–5 multiple-choice questions to lock the chapter in. Mark the correct answer with [x]. The > **Why:** … blockquote right after each question is the explanation shown after submit.

Quick check

Q1. What does print(2 ** 3) output?

  • 6
  • 8
  • 9
  • error

Why: ** is exponentiation. 2 to the power of 3 is 8.

Q2. Replace this with the next question…

  • Option A
  • Option B
  • Option C (the correct one)
  • Option D

Why: Explanation goes here.

14. Common doubts

Three to ten real questions students ask, with answers. Curated by hand — these answer the questions readers will actually google.

But what if I do X instead of Y?

Answer in plain language. Show a tiny example if it helps.

When would I ever use this in real code?

Concrete scenario.