Skip to content
tezvyn:

Python & FastAPI

Python, Django, FastAPI, Flask, async Python

48 bites

Test yourself: Top 30 intermediate Python & FastAPI concepts questionsMultiple choice, with the correct answer and why it is correct on every question. Free, no sign-in.

Intermediate concepts in Python & FastAPI, page 3

Layered Architecture: Separating API from Business Logic
intermediate2 min read

Layered Architecture: Separating API from Business Logic

A layered architecture separates your API into distinct jobs: routing, controlling, and serving. This keeps code maintainable, like an organized toolbox. It's crucial for growing FastAPI apps.

asyncio Streams: High-Level Async Network I/O
intermediate2 min read

asyncio Streams: High-Level Async Network I/O

asyncio Streams are like async file handles for the network. You get a reader/writer pair to await data, simplifying TCP clients and servers for basic protocols. The footgun: the default buffer limit is small; reading large data will fail unexpectedly.

intermediate2 min read

ARQ for FastAPI: Async Background Tasks

ARQ lets your FastAPI app offload heavy work to background workers, keeping the API responsive. It's a task queue built for asyncio. Use it for slow tasks like sending emails or processing data. The footgun is using blocking task libraries with async code.

intermediate2 min read

Serialize Pydantic Models with model_dump

model_dump turns a Pydantic model into a plain Python dict, bridging typed objects and JSON serializers in FastAPI endpoints. Call it when you need raw data before returning a response. Do not confuse it with model_dump_json, which emits a string, not a dict.

intermediate2 min read

Per-Field Validation with @field_validator

@field_validator scrubs a single Pydantic field before it enters the model. Use it for rules like 'password must contain a digit' or 'port must exceed 1024'. It only sees one field at a time, so cross-field checks belong in a model validator instead.

intermediate3 min read

Custom Field Serialization with @field_serializer

@field_serializer is an exit-only adapter for one field: it reshapes data leaving the Pydantic model without changing internals. Use it to format decimals, mask secrets, or tweak datetimes for FastAPI JSON. Never use it for validation; it only runs on output.

intermediate2 min read

Docker Compose for Local FastAPI Stacks

Docker Compose turns your laptop into a one-command datacenter. Define Postgres, Redis, and your FastAPI app in one YAML file and they boot as a networked stack.

Async SQLAlchemy 2.0: the mental model that clicks
intermediate2 min read

Async SQLAlchemy 2.0: the mental model that clicks

SQLAlchemy's async layer bridges its synchronous ORM internals to asyncio. Use AsyncSession and AsyncEngine with an async driver, and await database work. Prerequisites: Python asyncio and basic SQLAlchemy ORM; lazy relationships must be loaded explicitly to avoid implicit I/O errors.

We are hiring for this. Every open role lists the topics its interview covers, so you can prepare for the real thing rather than guessing.

See open roles