r/FastAPI • • May 03 '22

feedback request FastyAPI.. a fastapi stack boilerplate for scaling.

Hello reddit! im currently working on FastyAPI a stack boilerplate for FastAPI.

stack boilerplate?

Exactly!, the idea is to provide boilerplate code and a backend stack architecture that scales!

the stack :

  • Nginx

  • Gunicorn with uvicorn workers

  • FastAPI

  • Motor

  • MongoDB with sharding

  • Redis

  • Celery (optional.)

  • Flower (optional.)

  • Docker

the boilerplate (no subfolders. a naming convention to organise folders.) :

crud

  • dependencies

  • helpers

  • models

  • routers

aswell as a CLI to configure the boilerplate with premade repetitive code.

FastyAPI should be Clone to go with absolutely no bloat.

the project still needs to mature but your feedback is very much appreciated

if you find this somewhat interesting, please consider giving us a star on github

13 Upvotes

15 comments sorted by

3

u/ArchonHalliday May 03 '22

Nice! You should consider making it a cookie-cutter for even easier customization when cloning the repo

1

u/[deleted] May 03 '22

Hello! thanks for your feedback, a cookie-cutter has been added to the TODO list.

2

u/andrewthetechie May 03 '22 edited Oct 01 '26

The original post content no longer exists here. The author used Redact to remove it, exercising their right to control their data & privacy.

Mitten person longing steer angle reply steer sophisticated

1

u/[deleted] May 03 '22

Hello, thanks for your feedback. a detailed document with each decision will be released, a cookiecutter is also great for this project!, as in example apps, as said in the README file, once the base structure and boilerplate is done, we'll fork the repo and build a project on it aswell as stress test it then archive it as a reference. thanks again for your great feedback!

1

u/Trinkes May 03 '22

Hello OP, great initiative, good job! How does it scale in terms of code organization? Why did you choose to group files/classes by "type" and not by feature?

Keep up the good work! 👍

1

u/[deleted] May 03 '22

different files related to a route will have that route's name. sub routes will have the following naming mainroute_subroute

this way every route has its own "container" and its easy for files to share utilities with eachother

this is easier to scale, need a model used in the users route ? simply openup users in the models directory

1

u/ironman_gujju Jun 12 '24

Why I can't find this repo

0

u/[deleted] May 03 '22

[removed] — view removed comment

2

u/[deleted] May 03 '22

this stack scales extremely well. FastAPI is minimalistic, celery helps with offloading CPU bound operations outside FastAPI wich is optimised for IO bound operations, mongo has proven to be superior than SQL, plus it offers great horisontal scaling with sharding. we've also chosen to implement JWT authentication to minimise database queries. and a redis config incase of normal authentication aswell as sharing data between instences running fasty.

3

u/ShotgunPayDay May 03 '22

I've always heard that that SQLAlchemy + asyncpg + PostgreSQL runs rings around MongoDB. I'll have to find an article on MongoDB being faster and what db driver makes it faster.

2

u/[deleted] May 28 '22

We tried postgre in production, mongo just outmatches it in large sums of fast written data, due to master slave inner structure

1

u/ShotgunPayDay Jun 01 '22

I believe you on that. I just wish I had something more concrete to show my boss(s). Right now we use PostgreSQL for our centralized structure. Users, orders, employment, etc etc which is perfect. I'd like to use mongo for satellite apps such as forums and tickets. I just can't find any benchmark that shows mongo outrunning PostgreSQL I'm terms of that kind of ingestion especially against asyncpg with uvicorn[standard].

1

u/[deleted] Jun 06 '22

just gotta setup mongo with sharding+ masterslave vs postgre and bombard fill them with data and bombard with reads and writes and ull see :)

1

u/[deleted] May 03 '22

[removed] — view removed comment

1

u/[deleted] May 03 '22

Great approach, using aws microservices is a great scaling solution, the problem with aws is the more services you use the more you pay, we're trying to keep the services used at a minimum, allowing larger scaling possibilities. your suggestions are very much needed! thanks