Skip to content

backend code layout: maybe group by resources #39

@mgfinch

Description

@mgfinch

IMHO, the current layout is not very practical for adding new / removing resources, therefore I would like to suggest differently pivoted organization of code.

I think most people will continue from this cookiecutter by adding / removing resources like Items and Users.

Example usecase

Lets say that apart from Users and Items you want to add Ideas to your app.
Currently you need to visit each directory: api, crud, db, db_models, tests/* and add the file named idea(s).py.

Maybe you start to think that the Ideas are better and you want to get rid of Items now...

Suggested layout

  • /users/

    • __init__.py
    • model.py
    • db.py
    • api.py
    • crud.py
    • utils.py
  • /items/

    • __init__.py
    • model.py
    • db.py
    • api.py
    • crud.py
  • /tokens/

    • ...
  • tests should be structured analogically

I am not yet sure how other parts should be layed out, but I would try to squash remaining files in now almost empty subpackages to core.

What do you think?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions