How I Structure a FastAPI Backend with LLM Features (From a Real Project)
I Don’t Start With Endpoints Anymore
When I used to start backend projects, I’d jump straight into writing routes.
That worked… until the project grew.
Now, I start with something else:
“How will this project fall apart in 3 months?”
Because it will — especially if you’re using LLMs.
You’ll start seeing:
prompts copied across files
random LLM calls inside endpoints
parsing logic that no one wants to touch
“temporary” hacks that become permanent
So these days, I focus heavily on structure first , features second.
This post is how I structured a FastAPI backend with LLM integration for a real estate consultant system — and what actually held up.
FastAPI vs Express — Different Problems
Coming from Node.js + Express, I was used to this:
routes/ controllers/ services/ models/
Enter fullscreen mode
Exit fullscreen mode
Flexible, simple… and easy to mess up.
Over time:
controllers get bloated
services become dumping…