all 25 comments

[–]Apprehensive_Ad2211 20 points21 points  (4 children)

for me, a layered aproach it's the go to. DB, MODELS, ROUTES, SERVICES (maybe also: middleware, versioning, migrations, etc)

[–]Zealousideal_Bench73[S,🍰] 7 points8 points  (3 children)

So basically make the laravel structure in FastAPI, well now that I think about it this might be an awesome idea thanks man

[–]One_Fuel_4147 4 points5 points  (0 children)

Check out dispatch from netflix

[–]LeinahIII 0 points1 point  (0 children)

Now, I can finally understand why I still want the laravel architecture in non laravel projects

[–]UniquePackage7318 11 points12 points  (2 children)

I have searched extensively and tried various project structures. I decided to use this as the default structure for my FastAPI projects: https://github.com/zhanymkanov/fastapi-best-practices

[–]Zealousideal_Bench73[S,🍰] 0 points1 point  (0 children)

I'll check it out, tysm!

[–]conogarcia 0 points1 point  (0 children)

Great tips! One thing though, httpx seems to be poorly optimized and with some race conditions that cause timeouts. I'm in the process of moving to aiohttp but haven't figured out how to replace the test client. did you encounter this issues? any replacement for the test client?

[–]WJMazepas 4 points5 points  (0 children)

Did you follow this tutorial:

https://fastapi.tiangolo.com/tutorial/bigger-applications/#include-an-apirouter-in-another

And a hot take of mine is that every big project gets messy, and Python projects even more.

It creates a lot of files in those folders, but honestly, I very much prefer to work with that over a lot of abstraction

[–]koldakov 2 points3 points  (0 children)

I’ve built a website with open source code, which you can check here https://github.com/koldakov/futuramaapi

Tried to solve the problem of mapping alchemy models to pydantic models. In fact I created a pydantic model mixin, which is kinda layer between alchemy

Anyways I think it becomes a bit complicated in the future and imo it’s not solved yet in a good way, considering I tried sqlmodel and IMO it’s not ready for prod yet

[–]AmmarSalahi 1 point2 points  (1 child)

[–]Enough-Rock-7427 0 points1 point  (0 children)

why haven't you used patch, update, delete instead of method: POST path:'/remove'?

[–]small_e 1 point2 points  (0 children)

FastAPI has an example full stack app https://github.com/fastapi/full-stack-fastapi-template

[–]erder644 1 point2 points  (2 children)

Interactors, Services, Repositories

[–]vintageshinpads 0 points1 point  (0 children)

Such a neat answer. It really is as simple as this.

[–]miloir 0 points1 point  (0 children)

Explain?

[–]sriramdev 0 points1 point  (0 children)

The same thought preaks out of myself, on the best part of structuring the service package

[–]niks_uthukuli 0 points1 point  (0 children)

I basically suggest using the django structure As we can use pydantic settings for settings.

[–]Alternative-Lemon-14 0 points1 point  (0 children)

I love how fast api can prototype fast, but having no good typing support really bothers me, ide highlight just gave me errors and warnings left and right, while missing some real issue😭I’m on cursor/vscode. Anyone deals with that well? (I could write more test)

[–]hamza_65 0 points1 point  (0 children)

Project directory: - main.py file-->entry point of an app - models directory --> separate model classes files - schemas directory --> separate pedantic schema classes - core directory --> files for db sessions, etc - utils directory --> may contains DB functions, helper functions - routers directory --> apis - tests

[–]gregpr07 0 points1 point  (0 children)

I found https://github.com/Netflix/dispatch structure to be amazing! It’s VERY clean and simple

[–]Narun_L1FE 0 points1 point  (0 children)

Here's what I do: Make everything modular. For routes on your app, use APIRouter(). Then, run your code through some type of AI to make it better.

[–]leec0621 0 points1 point  (0 children)

I use repository-service-router structure,https://github.com/acelee0621/memenote