HomeBlog

Posts tagged with: #Python

A Practical Guide to Rendering Markdown to HTML in Reflex

October 3, 2025

A Practical Guide to Rendering Markdown to HTML in Reflex

How to Use `rx.markdown` and `component_map` for Custom Content Styling.

Learn how to render Markdown to HTML in Reflex using `rx.markdown`. Covers basic usage, custom styling with `component_map`, and advanced pre-processing techniques.

Read More...

Building Resilient Task Queues in FastAPI with ARQ Retries

October 1, 2025

Building Resilient Task Queues in FastAPI with ARQ Retries

How to Handle Failures and Implement Robust Retry Logic in FastAPI Background Jobs with ARQ.

Learn how to make your FastAPI background tasks resilient using ARQ's retry mechanisms. This guide covers automatic retries, manual retry logic, and best practices for handling failures in production.

Read More...

A Guide to Authentication in FastAPI with JWT

September 21, 2025

A Guide to Authentication in FastAPI with JWT

From Basic Auth to OAuth2 with Password Flow and JWT Tokens.

Learn to secure your FastAPI API. This guide covers password hashing, OAuth2 password flow, and using JWT for a robust, production-ready authentication system.

Read More...

Reusable Model Fields in SQLModel with Mixins

September 20, 2025

Reusable Model Fields in SQLModel with Mixins

A Guide to Creating DRY Database Models with Timestamps and Base Models.

Stop repeating id and timestamp fields in your SQLModel models. Learn to use mixins and a base model to write cleaner, more maintainable code for your FastAPI application.

Read More...

Advanced Performance Tuning for FastAPI on Google Cloud Run

September 4, 2025

Advanced Performance Tuning for FastAPI on Google Cloud Run

From Cold Starts to Concurrency: A Deep Dive into FastAPI Performance on Cloud Run.

Optimize your FastAPI application on Google Cloud Run. This guide covers advanced performance tuning, from Gunicorn worker configuration to minimizing cold starts.

Read More...

Secure FastAPI Environment Variables on Cloud Run with Secret Manager

September 3, 2025

Secure FastAPI Environment Variables on Cloud Run with Secret Manager

A Step-by-Step Guide to Managing Production Secrets on Google Cloud.

Learn how to secure your FastAPI application on Google Cloud Run by managing secrets like API keys and database passwords with Google Secret Manager. This guide covers setup, permissions, and CI/CD integration.

Read More...

Connecting FastAPI to a Database with SQLModel

August 26, 2025

Connecting FastAPI to a Database with SQLModel

A practical guide to building CRUD APIs with FastAPI and SQLModel.

Learn to connect FastAPI to SQL databases using SQLModel. This guide covers creating models, managing sessions, and building a complete CRUD API with practical examples.

Read More...

FastAPI Tutorial: A Complete Guide for Beginners

August 25, 2025

FastAPI Tutorial: A Complete Guide for Beginners

A step-by-step guide to building your first API with Python and FastAPI, from installation to production-ready concepts.

Learn to build fast and reliable APIs with this complete FastAPI tutorial. Covers installation, endpoints, data validation, and links to advanced topics.

Read More...

Managing Background Tasks in FastAPI: BackgroundTasks vs ARQ + Redis

August 18, 2025

Managing Background Tasks in FastAPI: BackgroundTasks vs ARQ + Redis

A practical guide to background processing in FastAPI, comparing built-in BackgroundTasks with ARQ and Redis for scalable async job queues.

Learn how to handle background tasks in FastAPI using both the built-in BackgroundTasks and ARQ with Redis. This guide compares both approaches and shows how to build scalable async job queues and track task status.

Read More...

How to Set Up Logging in FastAPI

August 17, 2025

How to Set Up Logging in FastAPI

A clear, practical guide to logging in FastAPI, covering log levels, configuration, and best practices for real-world applications.

Learn how to set up robust logging in FastAPI. This article explains why logging matters, compares it to print statements, covers log levels, and shows how to configure logging for development and production.

Read More...

Building a Flexible Memcached Client for FastAPI

August 11, 2025

Building a Flexible Memcached Client for FastAPI

Flexible, Safe, and Efficient Caching for FastAPI with Memcached and aiomcache

Learn how to build a flexible async Memcached client for your FastAPI application. This guide covers key generation, namespace invalidation, and integrating the client into your FastAPI routes.

Read More...

Serving a React Frontend Application with FastAPI

July 30, 2025

Serving a React Frontend Application with FastAPI

A Guide to Serving Your Frontend and Backend from a Single Application

Learn how to serve a single page application (like React or Vue) directly from your FastAPI backend. This guide covers handling client-side routing, middleware order, CORS, and using a multi-stage Dockerfile for a unified deployment.

Read More...

Running Database Migrations with Alembic in Google Cloud Build

June 30, 2025

Running Database Migrations with Alembic in Google Cloud Build

How to Organize and Load FastAPI Settings from a .env File Using Pydantic v2

Learn how to centralize your FastAPI configuration using Pydantic Settings and a .env file. This post covers setup, usage, and best practices for managing environment variables and secrets in a maintainable way.

Read More...

Centralizing Your FastAPI Configuration Settings with Pydantic Settings

June 15, 2025

Centralizing Your FastAPI Configuration Settings with Pydantic Settings

How to Organize and Load FastAPI Configuration Settings from a .env File Using Pydantic Settings

Learn how to centralize your FastAPI configuration using Pydantic Settings and a .env file. This post covers setup, usage, and best practices for managing environment variables and secrets in a maintainable way.

Read More...

Connecting FastAPI to a Serverless Database with pool_pre_ping

June 10, 2025

Connecting FastAPI to a Serverless Database with pool_pre_ping

How to Keep FastAPI Connected to Serverless Databases Like Neon

Learn how to keep your FastAPI app connected to serverless databases like Neon, even when they scale down to zero. This post explains how to use SQLAlchemy's pool_pre_ping=True to automatically reconnect and avoid broken connections, with practical code examples and .env setup.

Read More...

Slimmer FastAPI Docker Images with Multi-Stage Builds

June 01, 2025

Slimmer FastAPI Docker Images with Multi-Stage Builds

Understanding Multi-Stage Builds in Docker

Learn how to use multi-stage builds in Docker to create smaller, more efficient images for your FastAPI applications.

Read More...

Function Calling in Google Gemma3

May 01, 2025

Function Calling in Google Gemma3

Understanding Function Calling in Google Gemma3

Explore how Gemma3's function calling feature, powered by Python, enables developers to create interactive AI applications that go beyond text generation

Read More...

Full-Text Search: Using the Trigram Tokenizer Algorithm to Match Peoples Names

April 24, 2025

Full-Text Search: Using the Trigram Tokenizer Algorithm to Match Peoples Names

Leveraging Full Text Search and Trigram Tokenization for Efficient Name Matching

This article explains how to use SQLite's FTS5 module with the trigram tokenizer to perform efficient full-text searches, particularly for matching similar names in a large database. It covers setting up the virtual table, normalizing names, bulk inserting data, and executing searches that handle close but not exact matches

Read More...

How to Get a Structured JSON Response from a Web Page Using AI

April 21, 2025

How to Get a Structured JSON Response from a Web Page Using AI

Using AI to Extract Structured Data from Web Pages: A Kenyan Invoice Verification Case Study

This article demonstrates how to leverage Google Gemini AI to extract structured JSON data from a web page. It includes a detailed guide with code examples for defining data structures, and implementing a parsing function

Read More...

Reflex Makes SEO Easier: Automatic robots.txt and sitemap.xml Generation

April 6, 2025

Reflex Makes SEO Easier: Automatic robots.txt and sitemap.xml Generation

Discover how adding your deploy URL in Reflex automatically generates robots.txt and sitemap.xml for easier SEO.

Reflex simplifies SEO by automatically generating robots.txt and sitemap.xml files when you include the deploy_url in your application's configuration.

Read More...

Deploying Reflex Front-End with Caddy in Docker

March 28, 2025

Deploying Reflex Front-End with Caddy in Docker

A step-by-step guide to building and serving Reflex static front-end files using Caddy in a Docker container

This blog post explains how to use Reflex to generate static front-end files and serve them using Caddy in a Docker container. It covers the Dockerfile setup, and Caddy configuration.

Read More...

Optimizing Reflex Performance on Google Cloud Run

March 27, 2025

Optimizing Reflex Performance on Google Cloud Run

A Comparison of Gunicorn, Uvicorn, and Granian for Running Reflex Apps

In this article, I tested various methods to run a Reflex 0.7.4 app on Google Cloud. After experimenting with Gunicorn, Uvicorn, Granian, and Reflex's built-in command, I found that Gunicorn with Uvicorn workers delivered the best performance.

Read More...

6 Essential FastAPI Middlewares for Production-Ready Apps

February 4, 2025

6 Essential FastAPI Middlewares for Production-Ready Apps

A guide to the 6 key middlewares for building secure, performant, and resilient FastAPI applications.

Learn how to build a production-ready FastAPI applications by implementing 6 essential middlewares. This guide covers security headers, CORS, trusted hosts, Gzip compression, process time tracking, and custom exception handling, including why their order is critical.

Read More...

Adding Google Authentication to Your FastAPI Application

January 27, 2025

Adding Google Authentication to Your FastAPI Application

A guide to adding Google Authentication to your FastAPI app.

Learn how to add Google Authentication to your FastAPI app, making it easier to use and more secure.

Read More...

Simple CI/CD for Your FastAPI App with Google Cloud Build and Cloud Run

January 26, 2025

Simple CI/CD for Your FastAPI App with Google Cloud Build and Cloud Run

Push code, deploy automatically: A simple CI/CD guide for your web app.

Learn how to connect GitHub, Google Cloud Build, and Google Cloud Run to automatically build and deploy your FastAPI application every time you push code changes.

Read More...

Contact Me

Have a project in mind? Send me an email at hello@davidmuraya.com and let's bring your ideas to life. I am always available for exciting discussions.

© 2025 David Muraya. All rights reserved.