← All Learning Paths

Python Backend Developer

Ship Python APIs with FastAPI and Pydantic: request validation, async pitfalls, SQLAlchemy data access, JWT auth, and the import bugs that bite in production.

roleintermediate9 nodes13.08h total

Path overview

Python 后端的分水岭在于把“能跑的脚本”变成“可运维的服务”。本路径沿 FastAPI 与 Pydantic 的校验链路推进,直面同步端点阻塞事件循环、gather 取消兄弟任务等高频事故,再接入 SQLAlchemy 与 JWT,收尾于可运行项目与启动模板。

This path turns runnable scripts into operable services: FastAPI request validation with Pydantic, the async pitfalls that stall an event loop, SQLAlchemy data access, JWT auth, and a deployable starter.

  1. Read "How to Validate Forms with Pydantic in Python" for the "Install Pydantic with email support" argument, then name the decision in python work it would change.

    Completion criteria: Attach a decision log for "How to Validate Forms with Pydantic in Python": the "Install Pydantic with email support" section, one rejected alternative, and the diff of the file you changed.

    Next step: FastAPI

    ⏱ 1h

  2. Read "FastAPI"'s documented surface around "Modern, fast Python web framework for building APIs with automatic OpenAPI docs and type", then build a minimal endpoint and log the response.

    Prerequisites: How to Validate Forms with Pydantic in Python

    Completion criteria: Attach one successful call and one invalid call against "FastAPI", citing "data-fetching" as the documented surface.

    Next step: FastAPI Form Validation with Pydantic

    ⏱ 1h

  3. Run the python snippet "FastAPI Form Validation with Pydantic", capture stdout, and show which line demonstrates the documented behavior: "Validate form data in FastAPI using Pydantic models with custom validators, field".

    Prerequisites: FastAPI

    Completion criteria: Paste the command, the exit code, and the output line matching "the UserForm entry point"; then show a second run with a changed parameter.

    Next step: Pydantic

    ⏱ 0.75h

  4. Wire "Pydantic" into a scratch python project, following "model_json_schema Model.model_json_schema(): dict", and record one working request/response pair.

    Prerequisites: FastAPI Form Validation with Pydantic

    Completion criteria: Attach one successful call and one invalid call against "Pydantic", citing "Python data validation using type annotations with parsing, serialization, and JSON schema" as the documented surface.

    Next step: How to Implement JWT Authentication in FastAPI

    ⏱ 1h

  5. Read "How to Implement JWT Authentication in FastAPI" for the "Configure secrets and password hashing" argument, then name the decision in python work it would change.

    Completion criteria: Write a five-line decision note citing "Configure secrets and password hashing" from "How to Implement JWT Authentication in FastAPI", name the option you rejected, and attach the before/after diff of one file you changed.

    Next step: SQLAlchemy

    ⏱ 1h

  6. Read "SQLAlchemy"'s documented surface around "create_engine create_engine(url, **kwargs): Engine", then build a minimal endpoint and log the response.

    Prerequisites: How to Implement JWT Authentication in FastAPI

    Completion criteria: Run a request against "SQLAlchemy", paste the response, and add one deliberately invalid call with its error.

    Next step: FastAPI Hello API — Runnable Python Project

    ⏱ 1h

  7. Run "uvicorn main:app --reload" in "FastAPI Hello API — Runnable Python Project" and compare the output with "Uvicorn running on http://127.0.0.1:8000. Swagger docs at /docs.".

    Completion criteria: Paste the command, the exit code, and the output line matching "uvicorn main:app --reload"; then show a second run with a changed parameter.

    Next step: FastAPI SQLAlchemy Starter

    ⏱ 2h

  8. Stand up "FastAPI + SQLAlchemy REST API" from its CLI, then modify "FastAPI, SQLAlchemy, Pydantic, Alembic" and show the documented behavior still holds.

    Prerequisites: FastAPI Hello API — Runnable Python Project

    Completion criteria: Run "pip install fastapi[all] && fastapi new my-project", replace one module, and show the entry point still returns the documented output; include the diff.

    Next step: Compute an Exponential Backoff Schedule

    ⏱ 1.5h

  9. In the "Python Backend Developer" path, implement "Compute an Exponential Backoff Schedule" so JSON object: { attempts, baseMs, factor, maxMs } yields {delays:[100,200,400,800],totalMs:1500}, including the second sample's edge case.

    Prerequisites: FastAPI SQLAlchemy Starter

    Completion criteria: Show the test run for "Compute an Exponential Backoff Schedule" with two passing samples and one deliberately failing input, with the expected error.

    Next step: Run the exercise test command and commit the working solution.

    ⏱ 0.33h