ysskrishna logoysskrishna
Fastapi Sync Async Starter Template

Fastapi Sync Async Starter Template

Video thumbnail 1
Gallery image 2
Gallery image 3
Gallery image 4

One FastAPI codebase showing SQLAlchemy 2.0 sync and async Postgres access patterns

This Poetry-managed template (fastapi-sync-async-starter on GitHub) demonstrates both psycopg2-backed sync and asyncpg-backed async sessions with SQLAlchemy 2.0, plus Pydantic v2, CORS, OpenAPI docs, and Redis-backed rate limiting (with simpler in-memory behavior for tests). Docker Compose brings up Postgres, Redis, and the API with multi-stage images; pytest, pytest-asyncio, coverage, and HTML reports are part of the documented workflow.

When it is useful

You are learning when to use sync vs async DB calls in FastAPI, you need a test-heavy skeleton with coverage reports, or you want a containerized baseline to extend. Configure .env and Poetry per the README.

What you can do

  • Call parallel sync and async route examples and compare patterns in the router and session layers.
  • Exercise rate-limit behaviors wired to Redis in production-like settings and memory in tests.
  • Run poetry run pytest or the Docker path that generates pytest and coverage HTML under report/.

Limits

  • Starter defaults are for education and bootstrapping; harden authz, secrets, and observability before customer traffic.
  • Redis and Postgres operations still need your backup, migration, and sizing strategy.
  • Performance depends on queries and infrastructure, not on the template name alone.

Frequently asked questions

What does this FastAPI template demonstrate?

One Poetry-managed codebase shows SQLAlchemy 2.0 sync sessions with psycopg2 and async sessions with asyncpg against Postgres. It also includes Pydantic v2, CORS, OpenAPI docs, and Redis-backed rate limiting (memory-backed in tests).

How do I run and test it?

Docker Compose brings up Postgres, Redis, and the API with multi-stage images. Locally you can run poetry run pytest (or Docker) and get pytest and coverage HTML under report/.

What rate-limit behavior is included?

The README documents Redis rate limiting for production-like settings and in-memory limiting for tests, including basic, shared, burst, and slow-endpoint examples with environment-based configuration.

Is it ready for customer traffic as-is?

Defaults are for education and bootstrapping. Harden authz, secrets, and observability before customer traffic, and bring your own backup, migration, and sizing strategy for Redis and Postgres.

Continue exploring

ProductExpress FastAPI Protobuf

Express FastAPI Protobuf

Reference architecture for Vue.js, Express, and FastAPI using Protocol Buffers for efficient binary serialization
Backend & APIs
Starter Kits & Boilerplates
Vue
Express
ProductFastAPI RabbitMQ Celery Flower Starter

FastAPI RabbitMQ Celery Flower Starter

FastAPI + Celery + RabbitMQ sample that queues SMS (Twilio) and email (Brevo) with Flower monitoring.
Backend & APIs
Starter Kits & Boilerplates
FastAPI
RabbitMQ
BlogCover image for How Microservices Verify JWTs Without Calling the Auth Service

How Microservices Verify JWTs Without Calling the Auth Service

Auth & Security
Backend & APIs
+1
8 min read
ProductFastAPI Clerk Starter

FastAPI Clerk Starter

FastAPI starter with Clerk auth. Secure & scalable!
Auth & Security
Backend & APIs
Starter Kits & Boilerplates
FastAPI
ProductFastAPI Supabase Starter

FastAPI Supabase Starter

FastAPI backend starter that validates Supabase JWTs and exposes protected user routes.
Auth & Security
Backend & APIs
Starter Kits & Boilerplates
FastAPI
ProductFastAPI UV vs Requirements File

FastAPI UV vs Requirements File

FastAPI Docker: UV vs Requirements for speed
DevOps & Infrastructure
Backend & APIs
Starter Kits & Boilerplates
FastAPI