SeeRepo with Python
SeeRepo reads Python with cables: it follows which file uses which, like it does for TypeScript and JavaScript.
What SeeRepo reads
FastAPI and Flask
- Every route decorator (
@app.get,@app.post,@app.route,@router.api_route,@app.websocket…) is a part, with its full path: the prefix of itsAPIRouterorBlueprintincluded. - A route that renders a page (
render_template,TemplateResponse…) is a screen; one that answers data is an action; a webhook, a sitemap or a feed is an API door for machines. - The file that starts the app (
FastAPI(),Flask(__name__),app.run(), orapp = create_app()) is where your routes start.
Django
- A
views.pythat renders a page is a screen; one that answers JSON or uses Django REST framework is an action. - Your
urls.pyfiles are doors, and yourtemplates/are pieces of the interface.
Celery
@shared_taskand@app.taskare things that run on their own.
Your models
- Django models (
models.Model,AbstractUser), SQLAlchemy (declarative classes, Flask-SQLAlchemy'sdb.Model, CoreTable("…")) and SQLModel (table=True) become data models. A pydanticBaseModelisn't a table, so it doesn't.
Who comes in
A route behind @login_required (and its cousins), LoginRequiredMixin, Depends(get_current_user) or Django REST framework's IsAuthenticated is for Signed-in people. The rest is for Visitors.
An example from our test bank
miguelgrinberg/microblog(Flask): 2 screens and 1 action, 6 data models with SQLAlchemy (Message, Notification, Post, Task, User, followers), Redis and Postgres as services. Every route ofapp/main/routes.pyrequires a session (@login_required).testdrivenio/django-celery(Django): 1 screen and 1 task that runs on its own, with Redis.wsvincent/lithium(Django): 1 data model, CustomUser, with Postgres.
Good to know
- Your packages are read from every list Python uses:
requirements.txtand the files of arequirements/folder (with the files they include),pyproject.toml,Pipfileandsetup.cfg. A package you list but never import doesn't show up as a service; a database still does, because your code often reaches it without importing it.