FastAPI News: WebSocket, Alembic, MongoDB, Extensions, Dep + Forms API in Django

Video thumbnail

Welcome to a new update. I'm here to tell you about all the content I've uploaded and that is already available to you completely free of charge.

As usual, the blog (desarrollofree.net) is the central hub. Currently, I am working on the CodeIgniter 4 update, improving existing applications and adding new examples almost daily.

Additionally, exclusive material is now available that has not yet reached YouTube, such as connecting FastAPI with MongoDB, taken directly from the course I am updating. Remember that on the blog you can access:

  • Detailed posts: With code examples.
  • Community courses: Available via the "Watch for free" button without registration.
  • Free books: Based on premium content, accessible if you register on the https://academy.desarrollolibre.net/ platform.

Android and Python (Django / FastAPI) on YouTube

On the YouTube channel, we continue the trend of previous updates:

Android Studio

We have moved past Kotlin theory to focus on direct development. We have covered essential components (Composables) for modern applications:

Snackbars, Logs, Bottom Sheets, and Navigation Drawer.

Create a Card as a container | Jetpack Compose - 05 - https://youtu.be/IA_FQRIv9J4 
From RecyclerView to: LazyColumn, LazyRow and LazyVerticalGrid in Android Studio  | Jetpack Compose -06 - https://youtu.be/1UcVM0t6sy8 
Snackbar Android Studio | Jetpack Compose - 07 - https://youtu.be/lupu0YejB44 
Logs with Logcat in Android Studio | Jetpack Compose - 08 - https://youtu.be/rEml2l3tkMI 
Bottom Sheets in Android Studio | Jetpack Compose - 09 - https://youtu.be/m_pS47Fve9Q 
Navigation Drawer (side menu) in Android Studio | Jetpack Compose - 10 - https://youtu.be/ryNLU-TSDvM 
Tabs with TabRow HorizontalPager in Android Studio | Jetpack Compose - 11 - https://youtu.be/Oo-Bi1X9-c4 

Note: This content is also available in book format at a very affordable price.

Django

We are entering the final stretch of this series with fundamental topics:

  • Migrations, Django Admin, and advanced form management (ModelForms).
  • Introduction to Django REST Framework (DRF): Serializers and ViewSets to create robust APIs with authentication.

 Introduction to migrations in Django 6 - https://youtu.be/6pPV8mLaQAQ 

Django Admin - Group management fields, fields - 58 - https://youtu.be/gcq8OONJPz4 

 Presentation of Django 6 forms, Form and ModelForm - 59 - https://youtu.be/_Bt8OD-Fbwo 

 Create your First Form in Django 6, Text Fields, Textarea and ModelChoiceField - 60 - https://youtu.be/slH1j7lyo9M 

Processing the form in Django 6 from the view - 61 - 
https://youtu.be/EgyAD_mdHi8 

Representing dynamic content of a Template in Django 6 - 62 - https://youtu.be/9e1ply0d2WU 

 Key Elements of the Django 6 Template Engine - 63 - https://youtu.be/2R3oASh2b9k 

Generating the master or base template in Django 6 - 64 - https://youtu.be/8V5RG6MUbQw 

Install and Configure Django Rest Framework - APIs - 65 - https://youtu.be/W_QXOYtoie4 

What is a REST API?, what is an API, what is Rest, Why Django REST Framework? - 65 - https://youtu.be/DXYwuORmF-s 

 Django Rest Framework in practice, Serializers and Viewsets - 66 - https://youtu.be/4ciOfc8_b0U 

Authentication: Presentation, Session and Basic in Django Rest Framework - 67 - https://youtu.be/1GFp3ss0Crw 

Token Authentication using Django Rest Framework - Login Method - 68 - https://youtu.be/rRY4U1OOOQU 

FastAPI: The "Secret" of its Greatness

I've uploaded an extensive video on the FastAPI Dependency Injection system and the Repository pattern. We also covered:

  • Application lifecycle with lifespan.
  • WebSockets in FastAPI: A complete guide consumed from a Vue.js app.

Still writing pure PHP? This is why you need a Framework today - https://youtu.be/T1cPAIQ78r8 

Reverse Relationships in Django and the N+1 Problem - https://youtu.be/cmgFNEHY5ec 

Repository Pattern: interfaces, Dependencies - The Secret of FastAPI's Greatness - https://youtu.be/J-HbHHMjTOM 

⚡ Code Execution on Start or Finish via the Lifespan event in FastAPI - https://youtu.be/a1We_SE9Pg4 

Blender 

On my other channel, we recap 3D modeling (chess) and concepts of Perspective vs. Orthogonal projection.

Day 3: Modeling a Chessboard with Blender - 03 - https://youtu.be/6fhLdT_uRcU 

Day 4: Modeling a Chess Pawn with Blender - 04 - https://youtu.be/wj8KVzqKhok 

Differences between Perspective and Orthogonal (Orthographic) projection in Blender - 05 - https://youtu.be/kVY8G5MyT-8 

 

Full Courses and Compilations

I've released several comprehensive materials you can't miss:

  • Local AI with Python: Mini course to create a Chatbot application connected to a local LLM (available in video and book).
  • Laravel Livewire (Dashboard): Based on the online store project.
  • Laravel 12 + Inertia 2: Fresh update of the community course.
  •  

Upcoming Launch: Second Edition of FastAPI

I am in the final stretch of updating the FastAPI Course and Book. If you already know Flask or Django, I highly recommend giving this framework a try.

What's New in the 2nd Edition:

  • Clean Architecture (Clean Code): Implementation of best practices and professional organization.
  • Database with Alembic: Migration management.
  • Essential Extensions: fastapi-mail, fastapi-users for authentication, pydantic-settings for environment variables, traffic control (Rate Limiting), autocrud and fastapi-cache.

Use and consumption of Websockets in FastAPI and a Vue app:

  1. Select Room
    1. We present the scheme for selecting the room.
  2. Filter Implementation to get messages by Room
    1. We are going to implement an optional GET parameter applied to the messages/alerts endpoint using the room_id.
  3. Message update without full reload
    1. We adapt the app so that for the event received from the WS, which is the Message/alert, we push that message into the message array instead of doing a full reload.
  4. Clean Architecture and Clean Code
    1. We will adapt Clean Code principles to a FastAPI application.

Database with Alembic:

  1. First steps with Alembic
    1. We are going to learn how to create migrations using Python's Alembic.
  2. Alembic parameters and configurations and first migration
    1. We are going to configure Alembic to be able to use it and create the first migration.
  3. Apply migrations
    1. We are going to apply database migrations.
  4. Revert changes
    1. Let's see the 3 types of schemes with which we can revert changes: with numbers, by migration ID, and by base.

Dependencies:

  1. Nested Dependencies or Subdependencies
    1. We talk about how we can create Sub-dependencies and their utility.
  2. Repository Pattern in KEY use with Depends and Annotations
    1. We are going to explain a design pattern and the KEY use of dependencies in FastAPI in all of this.
  3. Advanced Dependencies with yield
    1. We talk about the use of advanced dependencies using yields.
  4. Connection Pool, keys in dependencies
    1. We talk about the use of pools, which is CRUCIAL for FastAPI to resolve requests efficiently.

MongoDB:

  1. Install MongoDB on MacOS with Homebrew or Windows + Compass GUI
    1. Learn how to install MongoDB on macOS with Homebrew step by step, we talk about NoSQL Databases and installing the Compass GUI.
  2. Motor: The Asynchronous Driver for MongoDB
    1. We install and talk about Motor to be able to make connections to MongoDB.
  3. First connection to MongoDB with Motor
    1. We create a method to connect to MongoDB and ping it when starting the project in FastAPI.
  4. Example of Relational Schema in MongoDB
    1. We will show how to handle the relational schema in a non-normalized many-to-many relationship.
  5. Relationships
    1. Let's talk about the rest of the relationships in MongoDB.

Extensions for FastAPI:

  1. FastAPI Mail
    1. Async email sending
  2. FastAPI User (Under Maintenance)
    1. To create a complete backend for Auth with JWT, registration, login, validations, schemas... with 100 lines of code
  3. Environment Variables Management with Pydantic Settings
    1. Let's see how we can create environment variables and read them from a .env, cache them, and recommendations.
  4. Traffic Control in FastAPI: Implementing Rate Limiting
    1. We are going to learn how we can limit the number of requests to an endpoint.
  5. Logs with Loguru
    1. We configure and show an example of how to use Loguru.
  6. Creating an AutoCRUD in FastAPI + SQLAlchemy
    1. We create an AutoCRUD in FastAPI for our Pydantic models and with SQLAlchemy.
  7. FastAPI Cache 2: Optimization with Cache
    1. We will see how we can use a cache system to store caches of endpoint responses.

In the Django course I also updated a couple of classes:

  1. WS: Inject Message from the WS and named parameter when connecting to the WS
    1. Let's do a couple of optimizations, one of them is to avoid reloading all messages when sending a message (we inject the WS response) and we provide a parameter to the token when connecting to the WS.
  2. Redesign of the Vue app with Google Antigravity

Special Offer

The book is already on pre-sale in the academy for $8 USD (final price $10 USD). The update will be free for those who already have it. The final PDF will be ready in one or two weeks.

https://academy.desarrollolibre.net/libro/primeros-pasos-con-fastapi/ 

Massive update of courses and books: What's new in FastAPI, Django, Android Studio, and Laravel. Access free content, WebSockets guides, and clean architecture.

I agree to receive announcements of interest about this Blog.

Andrés Cruz

ES En español