r/FastAPI • • May 21 '26

Question ORMs to Pydantic models conversion

I'm developing a side project and trying to follow DDD principles as closely as possible. My current structure is router -> service -> repository. I'm using SQLAlchemy for ORM models, which are created and handled in the repository layer.

Right now, I convert those ORM objects into Pydantic models inside the service layer, and then pass those models to the router, which returns them in the response. I'm wondering whether this is the right approach or if there’s a better pattern for handling the conversion and data flow between layers.

23 Upvotes

42 comments sorted by

View all comments

4

u/[deleted] May 21 '26

[removed] — view removed comment

2

u/omry8880 May 22 '26

I haven't tried it yet, but I heard that by using it you're basically mixing the business and database layers?

2

u/Lazy-Librarian6753 May 27 '26

I checked the repo and I’m really impressed. Is there a Go version coming? 😅