
This course includes our updated coding exercises so you can practice your skills as you learn.
See a demo
Understanding the course structure and setting up our system.
Set up a backend with fastapi to build a hello world api, install requirements.txt, and run with uvicorn for live reload, then view the open api docs at /docs.
Master the core http verbs for create, read, update, delete: get to retrieve data, post to create records, put for full updates, patch for partial updates, delete to remove records.
Refactor project configuration variables by centralizing them in a settings class inside a code/config module. Manage environment-specific values for title and version across staging and production, and verify with uvicorn.
Create a GitHub repository and push your FastAPI project using git: initialize, add, commit, rename to main, add origin, and push, with a readme to guide collaboration.
Explore how type hints in Python boost IDE autocompletion, readability, and bug prevention in production-grade projects, with examples using a total price function and the mypy static type checker.
Explore intermediate to advanced Python type hints, from lists, tuples, and dictionaries to unions and custom types. Learn modern typing with Python 3.9 and 3.10, including callable annotations and decorators.
Explore inheritance and multiple inheritance in Python with Pydantic models for data validation in FastAPI, and grasp method resolution order and mixins.
Learn to use Pydantic for robust data validation in FastAPI apps, leveraging type hints, optional fields, enums, default factories, and custom validators, with nested models.
Leverage dependency injection to override dependencies in tests, swapping in a dedicated testing database to keep the development db clean while validating unit tests for FastAPI routes.
Connect to Postgres and SQLite databases, create the user and block tables, and establish a single database session for querying. Hash passwords to securely store user data.
Connect to the database using PostgreSQL with SQLAlchemy and psycopg2. Configure environment secrets with a dot env file and python-dotenv; assemble database url from host, port, user, password, and db.
Configure a FastAPI app to connect to a Postgres database with a SQLAlchemy engine and session, auto-create tables on startup, and manage database users and credentials.
Connect to SQLite by updating SQLAlchemy database URL and engine with connect_args to set check_same_thread to false, verify the database file appears, and prepare for Alembic migrations and model creation.
Set up Alembic for database migrations in a FastAPI project and manage schema changes with auto-generated revisions. Configure alembic.ini and env.py, connect to PostgreSQL, and protect credentials from GitHub.
Create a Pydantic user create schema that validates email and password before storage, using pedantic for email validation, and shows models reflect input/output rather than database structures.
Learn to use dependency injection to obtain a database session via a generator, yielding a single session and querying the user table to fetch records.
Understand why encryption isn't enough and how hashing securely stores passwords as a one-way process, verified by comparing hashes with bcrypt.
Implement password hashing with bcrypt by creating a hasher class using a password context, providing static methods to get password hash and verify passwords, and test with sample inputs.
Build routers for blogs and users, implement create, read, update, and delete operations, and apply rest api design principles in section 3 intro of FastAPI full stack web development course.
Use a response model with orm_mode to expose id and email, hide hashed password, and return 201 created for user creation.
Build a blog update route with an inherited update schema from create blog, a put router at blogs/{id}, a response model, and repository logic to update title, content, and slug.
implement delete blog by id in a fastapi app by querying the blog, validating author, deleting from the database, committing, and returning success or error messages.
Define unit testing principles: fast, isolated, repeatable, self validating, and timely. Automate tests with docker compose and a ci/cd pipeline to run on every commit.
Configure pytest with fixtures and a sqlite test database, and write a first unit test for the FastAPI /users endpoint using a test client, expecting 201.
Learn how json web tokens enable authentication by signing a token with a secret key, including header, payload, and signature, and validating expiry without storing session data on the backend.
Implement authentication with JSON web token by validating email and password submitted as form data, retrieving the user by email, verifying the password, and returning a bearer access token.
Learn to enforce blog authorization in FastAPI with OAuth2 and JWT, validating the current user and ensuring only the post's author can update or delete.
Extend the project by building a blog web application that reads blogs from the crud api endpoints, aiming to resemble a medium-like reading experience.
Create a blog list view by fetching active blocks with a repository pattern, passing them to templates, and rendering cards with title, formatted date, truncated content, and a detail view.
Demonstrates building a blog detail view in a FastAPI app by retrieving a blog by id using a db session and rendering it with a detail.html template.
This course is a guide to learn FastAPI. The FastAPI documentation is one of the best documentation. This course is for students who love videos as a medium to learn. We will be learning FastAPI with best practices. The Test-Driven Development goat ? will guide our development process. TDD is the way to think of the code before we actually write a piece of code. In this course we will be learning the following core concepts:
Creating APIs : We will implement the below endpoints:
Create
Retrieve
Update
Delete
List Blogs
User Authentication with basic security
Password will be hashed to provide additional security
We will use JSON Web Tokens to authenticate
Tokens won't be stored in LocalStorage or Cookies
Token will be stored in HttpOnly cookie
Version Control System
We will use GIT as our Version Control
Github will be used to host our code
Creating web apps
We will use Jinja Templating Language
We will be working with several forms
Unit Testing
Tests will be written in Pytest
After each testing cycle, the Test database will be cleaned
Test Coverage
How not to write unit tests?
Permissions: A user who has not created the blog, won't be able to delete it.
We will work with Postgres and monitor it using PgAdmin.
Fastapi provides us with built-in OpenAPI docs, we will use the documentation to the fullest. The docs help backend and frontend developers collaborate easily with each other.