Bart DorseyProgramming tutorials, cheatsheets, and guides.

FastAPI architecture

FastAPI architecture

Photo by GuerrillaBuzz on Unsplash

Simple GET /items request without a database

Sequence diagram: the user opens the website, the frontend sends a GET /items request to the FastAPI backend, which validates the request, reads items from an in-memory list, and returns the data back through the backend to the frontend.

Simple POST /items request without a database

Sequence diagram: the user submits a form, the frontend sends a POST /items request with a JSON payload to the FastAPI backend, which validates the data, appends the new item to an in-memory list, and returns a success response that the frontend shows as a confirmation.

Simple GET /items request with a database

Sequence diagram: the user opens the website, the frontend sends a GET /items request to the FastAPI backend, which validates the request and queries a PostgreSQL database with a SELECT statement, then returns the query result back through the backend to the frontend.

Simple POST /items request with a database

Sequence diagram: the user submits a form, the frontend sends a POST /items request with a JSON payload to the FastAPI backend, which validates the data and runs an INSERT statement against a PostgreSQL database, then returns a success or error response that the frontend shows to the user.