I have some questions on my mind that I would like to ask all Backend Engineers, and the Applied AI engineers who currently work in the EU/US market:
The sector is evolving, as all of us know, and the interviewing process is changing every day, so it's becoming quite complex to decide what to study because some of the companies ask questions and want you to solve them using AI, while others still ask about algorithms. I understand that most of them for sure ask for the system design. 3 years ago, it was quite common to ask programming language-specific questions, for example, generators and context managers in Python. Do they ask similar questions now? How do they proceed in the interviews? How do we get prepared for the interviews? I'm quite confused, actually, because of the industry's undeterministic interview styles.
Should we be ready for Python and FastAPI questions or skip them?
Should we work on databases? Queries, optimisation, etc., or just skip them?
What should we study? 😃 Any help is appreciated. Keen to discuss with you all.
Also, I shouldn't be the only one who feels like this. The sector is bullshitting; they don't know what to do with the interviews. 😃 They're quite confused, as well as we are.
Any kind of resource for interview preparation would be amazing! Appreciate those legends!
I wanted high speed communication between multiple scripts of mine.
Long ago i had started to use fastapi for that purpose and then i just got into modular monolithic architecture for web UIs.
but then as i kept doing things i didnt feel like that is satisfactory recently i was kinda intrested to build native applications and wanted IPC and i googled it first didnt find anything simple enough for me to just use out of the box.
like grpc too complex i tried using it once but was complex for my use case and added unnecessary friction.
and then to go for simpler microservice architecture rather than multiple fastapi servers/workers in future for my web uis i thought wont this be simpler and have come out with a simpler library for making a more microservices kinda architecture and just wrap the calls in fastapi for distributed.
With regular setups it kinda gets more complex to implement IPC this library abstracts a lot of that and makes it feel almost like fastapi on provider side and on consumer side it somewhat like requests.
With my current system i believe it is simpler to build Fully distributed mircoservices and then use them through a single fastapi server.
Like i can have 10 seperate services which all do different things and then u can have a fastapi server which send requests to differnt process on same device or distributed and just use them without worrying about how to communicate and you can restart any microservice and it wont matter to the fastapi server, if you use load balanced events then you can even have 0 downtime updates to code.
I have added support for:
- events (RPC like)
- streaming (streaming RPC calls)
- pub/sub (1->many)
- groups (load balanced events)
- full pydantic integration
- IPC to HTTP using fastapi
I tried some benchmarking and have got like sub ms latencies
A lot of FastAPI developers end up with Celery not because they need a distributed task queue, but because BackgroundTasks stopped being enough and Celery was the first thing that came up when they searched for a solution.
This is about that gap, and a library that fills it without the overhead.
What BackgroundTasks does not give you
FastAPI's built-in BackgroundTasks is straightforward. You attach a function to the response and Starlette calls it after the response is sent.
That covers fire-and-forget. But in a real application you quickly hit walls:
No retries. If send_welcome_email fails because the SMTP server returned a 503, the task is gone. There is no retry, no backoff, no record of what happened.
No persistence. If the app restarts during a deploy, every queued task disappears. Tasks that were waiting to run simply never run.
No visibility. You cannot see what is running, what has run, what failed, or how long things took. The only way to know a task failed is to catch it in your logs, if you are logging at all.
No scheduling.BackgroundTasks runs things once, after the current request. There is no built-in way to run something on a schedule.
These are not edge cases. They are the baseline requirements for any background job in production.
Why Celery is the wrong answer for most of these
When developers hit these limitations, the standard advice is: add Celery. And Celery does solve all four problems. But it solves them by giving you a distributed task queue, which comes with the full infrastructure that entails.
To use Celery with FastAPI you need:
A message broker. Usually Redis or RabbitMQ. A separate service to run, configure, monitor, and back up.
A worker process. A separate process that consumes from the broker. Needs to be deployed, restarted on failure, and kept in sync with the app on every deploy.
Celery Beat for scheduling. Another separate process.
Flower or similar if you want visibility. Yet another service.
Celery was built for teams running tasks on dedicated workers across multiple machines at high volume. If that describes your situation, it is the right tool. But most FastAPI apps sending emails, processing uploads, running nightly reports, and syncing data are not in that category. They just needed BackgroundTasks to grow up a little.
What actually fills the gap
fastapi-taskflow is built specifically for this problem: FastAPI apps that have outgrown BackgroundTasks but do not need a distributed task queue.
It runs inside your FastAPI process. No broker. No separate worker. Tasks execute the same way they do today, after the response, but now with retries, persistence, scheduling, and a live dashboard.
Setup:
from fastapi import BackgroundTasks, FastAPI
from fastapi_taskflow import TaskAdmin, TaskManager
task_manager = TaskManager(snapshot_db="tasks.db", requeue_pending=True)
app = FastAPI()
TaskAdmin(app, task_manager, auto_install=True)
Retries:
@task_manager.task(retries=3, delay=60.0, backoff=2.0)
def send_welcome_email(email: str):
_send(email) # raise any exception — the retry handles it
The function stays a plain function. Raise an exception on failure and it retries automatically with exponential backoff.
The task starts via asyncio.create_task the moment add_task() is called. It is still tracked, still retried on failure, still visible in the dashboard. You can also set it per call:
/tasks/dashboard is a live dashboard that shows every task, its current status, duration, logs, and the full stack trace on failure. It updates over SSE in real time. No Flower setup, no external monitoring service.
The honest trade-offs
This is not a Celery replacement. If your tasks are CPU-intensive and need isolation from request handlers, if you need to route different task types to dedicated worker machines, or if you are processing thousands of tasks per minute, you need a proper task queue.
What fastapi-taskflow covers is the case where you reached for Celery because BackgroundTasks gave you nothing, not because you genuinely needed distributed workers.
For a single-host deployment, multiple instances on the same host share a SQLite file. For multiple hosts, swap to Redis or PostgreSQL as the backend and idempotency, requeue claiming, and task history all work across instances without any coordination overhead.
What you skip entirely
No broker to run or monitor. No worker process to deploy or restart. No Celery app instance or separate tasks module. No Beat process for scheduling. No Flower for visibility.
Local development stays at uvicorn app.main:app. New developers on the project do not need to learn a separate system.
The four things that pushed you toward Celery in the first place, retries, persistence, scheduling, and visibility, are covered.
I'm building a FastAPI application where users can create flashcards, comments etc. this content then is stored in the db and displayed to other users. So as every good developer i need to sanitize the content to prevent xss atacks, but i am wondering which approach is best.
I have two approaches in mind:
Approach one:
Utilize pydantic to perform bleaching of data, f.e:
from pydantic import BaseModel
from typing import Any
import bleach
class HTMLString(str):
# perform bleaching here
class FlashCard(BaseModel):
front_content: HTMLString
back_content: HTMLString
Approach two:
Create a sanitization middleware that is going to bleach all content that i get from the users:
class SanitizationMiddleware:
async def __call__(self, scope, receive, send):
request = Request(scope, receive)
body = await request.body()
# perform bleaching here on all fields that are in the json
await self.app(scope, receive, send)
So my questions is are there any other approaches to this problem (excluding bleaching right before saving to db) and what is the golden standard?
So my company is starting a new microservice and they've decided on FastAPI (something about better performance and async support). I've been doing Django for the past few years and pretty comfortable with it, but now I need to get up to speed with FastAPI FAST - like I need to start building actual production stuff in 3-4 weeks.
I'm not starting from zero - I know Python well, understand REST APIs, have worked with DRF, know my way around databases (MYSQL mainly), and I get the general web dev concepts. But FastAPI seems quite different from Django's "batteries included" approach.
For those who've made this jump:
What are the biggest differences I should watch out for?
Any good resources that specifically help Django devs transition? Most tutorials I'm finding assume you're new to everything
What's the FastAPI equivalent of Django's ORM? I see people mentioning SQLAlchemy but also Tortoise-ORM?
How do you handle stuff like auth, migrations, admin panel that Django just gives you?
Should I bother learning Pydantic separately first or just pick it up as I go?
Also worried about the "blank canvas" problem - Django tells you where to put things, but FastAPI seems more like "do whatever you want" which is kinda overwhelming when you're on a deadline.
My plan so far is to rebuild one of our smaller Django services in FastAPI this weekend as practice. Good idea or should I just follow tutorials first?
Would really appreciate any tips, especially from people who use both frameworks. Thanks!
I recently built a full stack GraphRAG application to extract complex legal contract relationships into a Knowledge Graph. Since I wanted this to be a production ready SaaS MVP rather than just a local script, I chose FastAPI as the core engine.
The Architecture choices:
Used FastAPI's async endpoints to handle heavy LLM inference (Llama-3 via Groq) without blocking the server.
Neo4j Python driver integrated for complex graph traversals.
Everything is fully isolated using Docker Compose (FastAPI backend, Next.js frontend, Postgres) and deployed on a DigitalOcean VPS.
My Question for the backend veterans: Managing the Neo4j driver lifecycle in FastAPI was a bit tricky. Right now, I initialize the driver on app startup and close it on shutdown. Is this the absolute best practice for a production environment, or should I be doing connection pooling differently to handle concurrent LLM requests?
(If you want to inspect the docker-compose setup and the async routing, the full source code is here:github.com/leventtcaan/graphrag-contract-ai*)*
I recently built an app using Flask without realizing it’s a synchronous framework. Because I’m a beginner, I didn’t anticipate the issues I’d face when interacting with multiple external APIs (OpenAI, web crawlers, etc.). Locally, everything worked just fine, but once I deployed to a production server, the asynchronous functions failed since Flask only supports WSGI servers.
Now I need to pivot to a new framework—most likely FastAPI or Next.js. I want to avoid any future blockers and make the right decision for the long term. Which framework would you recommend?
Here are the app’s key features:
Integration with Twilio
Continuous web crawling, then sending data to an LLM for personalized news
Daily asynchronous website crawling
Google and Twitter login
Access to Twitter and LinkedIn APIs
Stripe payments
I’d love to hear your thoughts on which solution (FastAPI or Next.js) offers the best path forward. Thank you in advance!
Sharing a project that might interest this community — it's a FastAPI application at its core, and it follows patterns I think many of you would recognize (and hopefully critique).
What it does: Trello boards become the message bus between AI agents. You talk to an orchestrator via Telegram, it creates Trello cards, worker agents pick them up and execute autonomously — writing code, reviewing PRs, running research pipelines. Webhooks drive everything, no polling.
The FastAPI side:
- Domain-driven app structure — each bounded context (trello, agent, bot, hook, git_manager) is its own app under app/apps/
- Async everywhere — httpx for Trello/Telegram/GitHub APIs, subprocess for git ops
- Pydantic-settings for config (env + JSON), strict Pydantic models with Annotated types for all inputs/outputs
- Webhook routes for both Trello (HMAC-SHA1 verified) and Telegram (secret path auth)
- Shared httpx clients as singletons with custom rate-limiting transport (sliding window + 429 backoff)
- Lifespan context manager starts agent run loops and registers webhooks on startup
- Health endpoint exposes per-agent status, queue depth, and cost tracking
The agent side:
Workers are composable through config — three axes (repo_access, output_mode, allowed_tools) define what each agent does. Same WorkerAgent class handles coders that open PRs, reviewers that post analysis, and researchers that chain findings through multi-stage pipelines. No subclassing, just config.
A coding board can run: scout → coder → tester → elegance → reviewer. A research board can run: triage → deep → factory → validation → verdict. Different boards, same framework.
Built with Python 3.12+, FastAPI, Claude Agent SDK, httpx. MIT licensed.
Happy to discuss the architecture choices — especially the "Trello as the only state store" decision and the webhook-driven design. Would do some things differently in hindsight.
Is it just me who dislikes the way dependencies are declared in FastAPI? Why does dependency injection have to be tied to type definitions?
It feels ironic that the primary reason for moving external dependencies into function arguments is to decouple them, yet declaring dependencies in the function's type signature ends up coupling them again in another way.
Has anyone made a blogging site with FastAPI as backend, what was your approach? Did you use any content management system? Best hosting for it? As blogs doesn't need to be fetched every time a user visits, that would be costly plus static content ranks on Google, is generating static pages during build time good approach? Rebuild again after updating a blog, only that one not the whole site. What was your choice for frontend? Thanks!
I recently worked on fetch hiring challenge and had built APIs using FastAPI. I usually work on Django but recently got excited to use fastapi. Since I’m still new to FastAPI, I ended up vibe coding the backend for this challenge.
I’m looking for the feedback to know if what I vibe coded is correct or not and were you guys able to run it by following the documentation or not?
PS: I got rejected but idc, I wanna build better back ends and open source projects and want feedback to follow the right direction and best practices.
I build Fixor, an LLM-based security reviewer that reads the changed code in a pull request and flags authorization bugs. This was its CLI run against a public repo, and I'm posting the complete output rather than a claim, because the last time someone showed up here with "my AI scanner finds bugs," the right response was "stop talking and show me a real run." So here is one you can reproduce in five minutes.
I scanned the route layer of the official full-stack-fastapi-template (commit cd83fc1), `backend/app/api/routes/` only. Full raw report here:
And here is the honest part, up front: that is a false positive. The `private` router is mounted only when `ENVIRONMENT == "local"` (`api/main.py`:13), so it does not exist in staging or production. Fixor reads the route file in isolation and cannot see that cross-file conditional mount, so it flags a dev-only route as if it were always live. The two findings are also one route drawing both "no auth" and "no admin gate," not two separate bugs. And "critical / high" is the model's own self-reported confidence, not a measured severity.
So if you opened the gist and saw "critical auth bypass in the FastAPI template," that is the wrong read, and I would rather tell you that myself than have you find it.
## What it cleared (the part I actually care about)
By my count, 22 of the 23 route handlers were cleared, and the clears are the interesting result:
The `items.py` routes (read, update, delete by id) all have the exact IDOR shape, a request-derived id going into `session.get(Item, id)`. A pattern scanner flags every one of those. Fixor cleared them, because it read the inline ownership check (`if not current_user.is_superuser and item.owner_id != current_user.id: raise 403`) sitting in the same file.
The `users.py` admin routes are gated by `dependencies=[Depends(get_current_active_superuser)]` in the decorator, not the signature. It parsed that and did not false-positive them. And the by-design public endpoints, signup, login, password reset, were not flagged either.
## Where it's blind, so you can judge it fairly
The same reason it cleared those item routes is the reason it has a hard limit: it reasons in-file. The ownership check or auth dependency has to be in the file it reads. If your guard lives in a base repository, tenant middleware, or a router-level dependency in another file, Fixor can miss it or false-positive it, exactly like the `private.py` conditional mount it got wrong here. A clean result from it means "no in-file problem found," never "this code is secure."
That is the whole thing, output and blind spot. Clone the template, run it yourself, and tell me where the reasoning breaks. I would rather hear it here than learn it later.
But I get the error, of course, since that's giving an instance, not a model. So I figure I can create another model built from ErrorResponse and have AuthFailed as the value for error, but that would get really verbose, lead to a lot of permutations as I build more errors, as ever error model would need a ErrorResponse model. Plus, naming schemas would become a mess.
Is there an easier way to handle this? Something more modular/constructable? Or do I just have to have multiple near identical models, with just different child models going down the chain? And if so, any suggestions on naming schemas?
I'm trying to limit Fastapi to process 1 request at a time. And while that request is being executed, other requests gets response of 503(Server busy).
I'm Sanjin, and I've been using FastAPI for two years to build backends for a statewide coding competition in Melbourne, Australia. 🇦🇺 So far, over 5,000 students have used it, and the backend has held up great! 💪
🚀 This Year's Ambitious Setup
We're running an exciting project with these features:
🤖 Students submit code agents that compete in games like Prisoner's Dilemma
🐳 Code runs safely in Docker containers
🗃️ Database is in SQLModel and running smoothly
🔌 Modular game engine design for super easy addition of new game types
⚛️ Front-end is React (not pretty, but functional)
I'd love any feedback on the project! The full-stack app takes just 10 minutes to set up locally. There are usually a dozen issues you can take on if you're interested in collaborating as well as an opportunity to create much cooler games than we came up with so far!