Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrite the app in Python Django 🚀 #355

Closed
raphodn opened this issue Jul 14, 2024 · 5 comments · Fixed by #366
Closed

Rewrite the app in Python Django 🚀 #355

raphodn opened this issue Jul 14, 2024 · 5 comments · Fixed by #366
Labels
✨ enhancement New feature or request ⭐ top issue Top issue.

Comments

@raphodn
Copy link
Member

raphodn commented Jul 14, 2024

I've been thinking lately...

Why ?

Having a couple of years of experience in Python Django, but only a few months now with Python FastAPI, I'm struggling to develop the backend as fast and solid as I wish..

Advantages of moving from FastAPI to Django

  • a shell !
  • ORM much better than sqlalchemy (joins, prefetch)
  • API : use DRF : better serialization, better filtering (instead of https://github.com/arthurio/fastapi-filter)
  • an admin interface 😍
  • faster development, more solid backend, better manage the app's growth (my feeling is that FastAPI is good for prototyping/small projects, but harder to manage for bigger projects, with many dependencies (alembic, sqlalchemy, filter...) that are far from on-par with Django)

Disadvantages

  • time to rewrite the app
  • no typing
  • API slower ? how slower ?
  • cron managed by the server ? or django-q !

Extra info

@raphodn raphodn added the ✨ enhancement New feature or request label Jul 14, 2024
@raphodn raphodn linked a pull request Jul 20, 2024 that will close this issue
@raphodn
Copy link
Member Author

raphodn commented Jul 22, 2024

Todo

Questions

  • Django Admin : generate a superuser ? (as we don't really manage users, nor store passwords)
  • migrate lat & lon DecimalField to PointField ? PostGIS ?

@raphodn
Copy link
Member Author

raphodn commented Jul 22, 2024

Which folder architecture ?

Existing

Repo Config Apps api web deps README Choice
django tutorial mysite/mysite mysite/<apps>
MTES-MCT/envergo envergo/config envergo/envergo/<apps> envergo/requirements.txt envergo/README.md
MTES-MCT/aides-territoires aides-territoires/src/core aides-territoires/src/<apps> inside each app inside each app aides-territoires/Pipfile aides-territoires/README.md
quiz-anthropocene/admin-backend admin-backend/core admin-backend/<apps> admin-backend/api admin-backend/pyproject.toml admin-backend/README.md
betagouv/Aidants_Connect Aidants_Connect/aidants_connect Aidants_Connect/<apps> Aidants_Connect/api Aidants_Connect/www Aidants_Connect/pyproject.toml Aidants_Connect/README.md
gip-inclusion/le-marche le-marche/config le-marche/lemarche/<apps> le-marche/lemarche/api le-marche/lemarche/www le-marche/pyproject.toml le-marche/README.md looks good!
gip-inclusion/les-emplois les-emplois/config les-emplois/itou/<apps> les-emplois/itou/api les-emplois/itou/www les-emplois/pyproject.toml les-emplois/README.md looks good!
betagouv/ma-cantine ma-cantine/macantine ma-cantine/data (models, ...) ma-cantine/api ma-cantine/web ma-cantine/requirements.txt ma-cantine/README.md
raphodn/open-prices-poc open-prices-poc/config open-prices-poc/<apps> open-prices-poc/api open-prices-poc/www open-prices-poc/pyproject.toml open-prices-poc/README.md

Todo

(closest to le-marche & les-emplois)

open-prices/config
open-prices/open_prices/<apps>
open-prices/open_prices/api
open-prices/open_prices/www
open-prices/pyproject.toml
open-prices/README.md

@raphodn
Copy link
Member Author

raphodn commented Jul 31, 2024

Which tool to manage crons ?

Need

  • cron : fetch & update all products from OFF every day
  • async tasks : fetch new location details from OSM, new product details from OFF

Tools comparison

Name Pros Cons Stars Choice
django-crontab - simple - only manages crons
- no admin integration
~800
django-celery - Celery is famous - cannot use DB as broker (since v4.2 ?) --> need to install Redis dependency ~1500
django-q - manage tasks, cron...
- can use DB as broker
- admin integration
- not maintainted anymore !! ~1800
django-q2 - replaces django-q ~300 yes !

@raphodn raphodn changed the title Rewrite the app in Python Django ? Rewrite the app in Python Django 🚀 Aug 12, 2024
@github-project-automation github-project-automation bot moved this from Backlog to Done in 💸 Open Prices Aug 28, 2024
@raphodn
Copy link
Member Author

raphodn commented Sep 4, 2024

@monsieurtanuki deployed in prod !

@raphodn
Copy link
Member Author

raphodn commented Sep 4, 2024

created a discussion here with a quick todo of next/upcoming issues : #421

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or request ⭐ top issue Top issue.
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

1 participant