
Learn FastAPI by building a production-grade app with user registration, login, and CRUD posts secured by JWT authentication. Establish user–post relationships, schemas, models, and service functions across supported databases.
Download the latest python version 3.10.1 from the official site and add python to your system path. Download the Bijan editor and choose the community version, which is free.
Install and set up PyCharm community edition for Python development, create a new project with automatic Python interpreter detection, trust the installer, and start coding.
Learn to set up your first Python program in PyCharm, configure virtual environments and interpreters, create a main .py file, and run it.
Learn to run python code from the command prompt or python shell by executing scripts, printing hello world, and using VS Code or PowerShell.
Explore fastapi, a high-performance, easy to learn Python framework for building and deploying production-ready APIs with built-in open API documentation and swagger support.
Create a Python project in PyCharm, configure a virtual environment, create a main file, run a simple hello world API, and prepare to install the required Python libraries for development.
Install and verify essential libraries for the project, including jwt and sqlalchemy, using both the IDE package manager and a virtual environment terminal to prepare for fastapi jwt authentication.
Set up a database configuration in a Python FastAPI project using SQLAlchemy, including creating an engine, session, and a declarative base for models.
Create a user model in a new models file using SQLAlchemy, defining id as primary key and indexed, a unique email, password_hash, created_at, plus optional name and phone.
Create a post model extending the database base with id, user_id foreign key, post_title, post_body, and created; prepare to relate it to the user model.
Establish a bidirectional relationship between the user and post models using SQLAlchemy's relationship and back_populates, enabling related posts and user data to be fetched together.
Create a password_verification method in the user model to compare a provided password with the stored hashed password using the verify method, enabling secure authentication in a fastapi sqlalchemy API.
Create a service layer to manage database creation with a create_db method that calls Base.metadata.create_all and binds the engine.
Install a database explorer tool and use it to open a simple database file, then view data inserted or updated and monitor changes as you work.
Create the main FastAPI app by importing modules, aliasing first_api, importing security, and instantiating the app, then discuss explicit data types versus automatic data on the fly.
Create user schemas as the application programming interface facing layer, mapping models to data, including user base, user request, and user response while omitting the password.
Build a base post schema with shared fields (title, description, image), then extend it to create request and response schemas including id, user, and created at, while disabling lazy loading.
Create a reusable database session by defining get_db in the services file, yielding the session from session local, and ensuring the session closes after use.
Import models, run the create command, and see the database tables for post and users appear after refreshing. Install decrypter for authentication and view data in the browser table.
Create a FastAPI post endpoint for user registration under v1 /users, using an async function with a user schema and a database session, and prevent duplicate emails.
Create an async method that checks the database for a user by email, using a db session and the user model, returning the first match.
Check if a user exists by email using an asynchronous call; raise a 400 'Email already exist' error when found, otherwise create the user and return a token.
Explore how JSON web tokens enable secure, self-contained authentication and authorization across technologies, using a header, payload, and signature, created with a secret key and sent in requests.
Implement an async create user method in FastAPI that validates emails, hashes the password, saves the user with SQLAlchemy, commits, and returns the created user.
Create a jwt token for a user by converting a user model to a schema, cleaning memory, and returning a token response with access token and token type.
Start the fastapi server, run the app, and test user registration end-to-end; fix model mapping errors, validate email, hash passwords, and generate access tokens stored in the database.
Implement and validate user login by checking the database for a matching email, verifying the password, and returning the user or false, while preparing a login API endpoint.
Create a login rest api endpoint in fastapi that handles form data, validates credentials via a database session, returns a jwt token on success, and raises unauthorized errors on failure.
Test the login functionality through swagger, install the required form-data library, and validate that correct credentials yield an access token while incorrect ones return an error.
Build a service method to decode JWT to obtain the current user's id, fetch the user from the database, and return a user response for a secure current user endpoint.
Create a get endpoint to fetch the current logged-in user's information, returning a user response model via the current user service and enforcing authorization with a token.
Create a post in the service layer by building a post model from the request data, populating the user id, saving to the database, and returning the created post.
Implement a create post api endpoint under slas api v1. Use post request schemas and a current user dependency to secure post creation, wired to a service method.
Test the create post endpoint with an authenticated user by supplying title, content, and image; log in as a user and verify the post is created by the current user.
Implement an async endpoint to fetch all posts by a specific user, filtering by user_id and mapping each post model to the post response schema for API output.
Develop an asynchronous REST API endpoint to get posts by user, returning a list of posts via the post response schema, wired through the service to the database.
Test the API by sending a get request to retrieve all posts for the authenticated user, authorize John with the secret password, and observe the returned post list.
Implement an async get_post_detail endpoint in FastAPI to fetch a post by id, convert it to a post response schema, and return 404 if not found.
Implement a delete post API with a service function and endpoint that accepts a post id, enforces authorization, deletes the post, and commits the transaction with no content.
Diagnose and fix the delete post error by aligning data flow, returning the database model instead of the schema, and validating authentication for delete operations.
Implement and test the update post endpoint in a secure FastAPI app, updating post fields via a service function and returning the updated post response.
Learn how to fetch all posts from all users with an open api endpoint, test it in the service, and verify posts across multiple users via user creation and login.
Implement a post detail view that fetches the post creator's user detail via a get user data method, exposing open information for visitors while hiding sensitive password fields.
learn to connect the same application to postgres or mysql by adjusting the database connection string, changing database type, host, user, password, and database name.
Learn how cross-origin resource sharing works between frontend and backend across different domains, and how to enable CORS on your backend to allow specific origins or all origins.
Enable cross-origin requests in a FastAPI backend by adding CORSMiddleware. Configure allowed origins, methods, and headers to permit frontend apps to securely access the API.
Create a new GitHub repository, commit and push the code using git, and generate a personal access token to authenticate the push.
Add deployment configuration to publish a fast api app on the public cloud via heroku by installing unicorn, generating requirements.txt, and creating a root-level web process file.
Deploy a Python web app to Heroku using the official CLI, authenticate, push code to the app's git remote, install requirements, and monitor logs while testing endpoints.
In this course you will learn about Python, Fast API, SQLAlchemy, JWT, Heroku and using different databases like SQL Lite, MySQL, PostgresQL with SQLAlchemy. We will commit the code to Github and will then deploy the API to cloud server.
Along the way we will also learn the basics of Python which is needed for this course.
We will build a complete real world application use case by developing the all the API's using FAST API python framework, along the way we will learn the details of Fast API framework and also compare it with other API development Frameworks.
We will learn to handle errors and exceptions and how to perform validation.
We learn then learn the basics of Authentication, Authorization and concept of JWT and then go ahead to secure our API's with JWT(Json Web Token) and OAuth2.
We will build multiple database entities and learn to develop relationships between different models using multiple databases like SQL Lite, MySQL, PostgreSQL and SQLAlchemy library.
We will also learn how to setup the database configuration and also how to use the database explorer to visualize our data inside the database.
Next we will move on to defining different schemas with the help of Pydantic library. We will see how to convert data between models and schemas.
We will learn how to secure an API endpoint behind JWT authentication.
We will learn to use OpenAPI/Swagger docs with FastAPI to test our application.
We will then go ahead and enable CORS on our APIs.
We will learn to commit our code to Github.
Finally we will deploy our Application on cloud server.