Why I'm Building SwiftPY: A Decade of Laravel Meets Async Python
SwiftPY is getting closer to its first stable release: 1.0.0. Before I show you what already works, I owe you the story of why this framework exists. A new framework that appears out of nowhere deserves suspicion. This
SwiftPY is getting closer to its first stable release: 1.0.0.
Before I show you what already works, I owe you the story of why this framework exists. A new framework that appears out of nowhere deserves suspicion. This one did not appear out of nowhere.
Ten years of Laravel, and Python the whole time
I have built backend projects with Laravel for over ten years. I have also written Python for about as long as I have written PHP. But when a new backend landed on my desk, Laravel was always the tool I reached for first.
The reason is simple. Laravel gets out of your way. One command gives you a model with its migration. Another gives you a request class, a seeder, a service provider. You open any Laravel project and you already know where everything lives. Eloquent lets you write what you mean, and the framework quietly does the rest.
That feeling is hard to describe until you lose it.
Then AI changed my default stack
Recently, most of my projects involve AI integration. Embeddings, retrieval, streaming responses, tool calling, agents. And that work lives in Python. The SDKs, the vector databases, the tooling, the community: the gravity of the AI ecosystem pulls you there.
So I started using FastAPI for almost every new project.
I have nothing bad to say about FastAPI. It is fast, async first, and beautifully typed. It earned its popularity honestly. But FastAPI is deliberately a toolkit, not a full framework, and I felt that on every single project:
- Pick an ORM.
- Pick a migration tool.
- Decide the folder structure.
- Invent your own pattern for services and repositories.
- Wire the database pool into dependency injection.
- Decide where validation lives.
- Write your own seeding scripts.
- Figure out background jobs, again.
Each project started with the same ritual, and each time the skeleton came out slightly different. I kept missing the things Laravel had made feel normal: a real project structure, an expressive ORM, a CLI that writes the boring code for me, and conventions I did not have to rediscover.
So this was not an overnight idea
It was a pattern. The same friction, project after project, until the question changed from "which libraries should I assemble this time?" to "why does the framework I want not exist?"
The answer became SwiftPY: the async first foundation that FastAPI proved works, combined with the simplicity and flexibility that Laravel taught me to expect. An Eloquent style ORM. A real CLI with code generation. A professional project structure from the first command. Validation, caching, migrations and seeding as first class citizens instead of afterthoughts.
Here is what a SwiftPY application looks like at its smallest:
from swiftpy import Application, Request
app = Application(title="My API", version="0.1.0")
@app.get("/ping")
async def ping(request: Request) -> dict[str, str]:
return {"message": "pong"}
And here is validation that runs before your handler ever executes, with an async database rule included:
from swiftpy import Response, json_response
from swiftpy.validation import FormRequest
from swiftpy.validation.rules import email, min_, required, string, unique
class RegisterRequest(FormRequest):
def rules(self) -> dict[str, object]:
return {
"name": [required(), string(), min_(3)],
"email": [required(), email(), unique("users", "email")],
}
@app.post("/register")
async def register(form: RegisterRequest) -> Response:
data = form.validated() # invalid input never reaches here: HTTP 422
return json_response({"ok": True, "email": data["email"]}, status_code=201)
Built in the open, tested on real projects
Over the past few weeks, I have been publishing experimental and beta versions of SwiftPY to PyPI.
SwiftPY is a Python web framework I am building with one clear ambition: to give developers a powerful, developer friendly framework and a rich ecosystem of built in capabilities.
I do not want to build something that only looks impressive in demos. I want developers to confidently use it in real world applications.
That is why I am dogfooding SwiftPY on actual projects, including its official documentation website: Next.js on the frontend, SwiftPY powering the backend.
Real world testing keeps revealing things to improve: unexpected behaviour, implementation weaknesses and security gaps. I fix them, test the changes, and publish improved versions. That loop is the whole point.
What is already working
✅ Docker execution
✅ Routing and request handling
✅ CLI and project scaffolding
✅ ORM and database migrations
✅ Validation and application caching
✅ Code generation and other core features
SwiftPY in action
1. CLI and code generation
The generators are my favourite part. They bring back the Laravel habit of letting the framework write the boring code:
swiftpy make:repository admin/admin_repository
swiftpy make:service admin/account_service
swiftpy make:provider PaymentServiceProvider
swiftpy make:request CreateOrderRequest
swiftpy make:model Post -m
swiftpy make:seeder UserSeeder
2. Async ORM and relationships
post = await Post.find_or_fail(1)
post = await Post.with_('user').where('id', 1).first()
Models are declared with plain Python type hints, and relationships load through explicit eager loading so you never trigger a silent N+1 query:
from swiftpy.database.orm import HasMany, Model
class Post(Model):
__table__ = "posts"
__fillable__ = ["title", "user_id"]
id: int
title: str
user_id: int
class User(Model):
__table__ = "users"
__fillable__ = ["name", "email"]
id: int
name: str
email: str
posts = HasMany(Post, foreign_key="user_id")
users = await User.with_("posts").where("name", "Alice").get()
3. Database migrations
swiftpy migrate
swiftpy migrate:rollback
swiftpy migrate:status
4. Seeding
swiftpy db:seed
AI integrations, tested with real credentials
SwiftPY was born from AI projects, so AI cannot be an afterthought. I am testing the AI integrations with real OpenAI and Anthropic API credentials, not just mocked responses. Because mocks only prove that your code agrees with your assumptions.
The goal is that switching providers is a configuration change, not a rewrite. Streaming a response looks like this:
async for chunk in (
AI.chat("claude-sonnet-4-6")
.system("You are a helpful assistant.")
.user(body.message)
.stream()
):
... # forward each token to the client
Why am I taking my time?
I do not want to rush into publishing 1.0.0 just to have a stable version number.
I want to release it when I am confident the framework is stable, secure, reliable and ready for production use. A version number is a promise, and I want to keep it.
The first official production ready release will be SwiftPY 1.0.0, and the documentation site will be available at https://swiftpy.net.
Help shape SwiftPY before 1.0.0
I am looking for Python developers willing to get hands on with the beta releases.
You can help by:
- Building a small application with SwiftPY.
- Testing its ORM, migrations, routing, validation and CLI.
- Identifying bugs and potential security issues.
- Contributing code, tests, examples or documentation.
You do not need prior open source experience. If you are comfortable with Python and interested in helping improve a growing framework, I would love to hear from you.
Reach me directly via [email protected]
Where this is going
Building a framework is one thing. Building one other developers can trust is another.
That is what I am working towards.
SwiftPY: Building towards 1.0.0.
Originally published by Dev.to AI. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.