Skip to main content

On This Page

4 FastAPI Projects in 2 Weeks: The Hidden Cost of Boilerplate and 15 CI Failures

3 min read
Share

These articles are AI-generated summaries. Please check the original sources for full details.

I Built 4 FastAPI Projects in 2 Weeks — Here’s What I Wish I Knew Before Starting

A developer built four FastAPI backends over two weeks, generating 134 Python files and 38 tests. 12 of 15 CI failures had nothing to do with business logic, catching infrastructure problems instead.

Why This Matters

Real FastAPI development is dominated by repetitive plumbing—Docker Compose, migrations, Celery config—not innovative business logic. 12 of 15 CI failures were infrastructure issues, not code bugs, revealing that ideal models of clean architecture often ignore the time sink of boilerplate that costs developers 3 hours per new project.

Key Insights

  • Docker Compose boilerplate costs 3 hours per new project; templating with a _templates/ folder reduces setup to 30 seconds.
  • Alembic migrations for user, role, token tables must be written every time; a base migration script reduces 4 repeated efforts to a single alembic upgrade head.
  • Celery in Docker fails because localhost inside containers must be replaced with the service hostname (e.g., redis); two config lines prevent worker starvation and data loss: worker_prefetch_multiplier=1 and task_acks_late=True.
  • 15 CI failures: 20% were missing requirements.txt, 27% from LLM-merging gibberish, 20% from hallucinated PyPI versions, 20% from missing Redis, and only 20% were actual code bugs.
  • Templating all repeated files (Docker Compose, CI, Celery config, exception classes, logging, env loading) is the real survival strategy, not a workflow tip.

Working Examples

Minimal Docker Compose template for FastAPI, Redis, and Celery; hostname must be ‘redis’ not ‘localhost’ when inside containers.

version: '3.8'
services:
  api:
    build: .
    ports:
      - "8000:8000"
  redis:
    image: redis:7
  celery:
    build: .
    command: celery -A app worker --loglevel=info
    environment:
      - CELERY_BROKER_URL=redis://redis:6379/0

Two Celery config lines that prevent worker starvation and ensure data persistence on crash.

worker_prefetch_multiplier = 1
task_acks_late = True

Practical Applications

  • Use case: Starting a new FastAPI backend — copy Docker skeleton from _templates/ folder and rename project name to avoid 3 hours of setup. Pitfall: Writing Docker Compose from scratch each time wastes engineering effort on clerical work.
  • Use case: Setting up user auth — always include user, role, and token tables in one Alembic migration. Pitfall: Writing the same Alembic migration four times across projects repeats plumbing, not business logic.
  • Use case: Deploying Celery in Docker — replace localhost with service hostname (e.g., redis) for broker connection. Pitfall: Using localhost:6379 inside Docker containers causes hard-to-diagnose connectivity failures.

References:

Continue reading

Next article

Mastering Edge AI Performance and Power on Android: Stop Guessing, Start Profiling

Related Content