due to its stability and its robust permission management features.
1. Basic folder structure
To ensure that we still have the current API working whilst developing v2, we’d create a v2 sub folder - in each app - where most of the work would be done. The models.py file would maintain its current location in the app’s package.
Views would be a module that would contain different view files for each package. e.g for the fund app, there’s are a lot of views so we’d break them down in such a way that we can have similar views in a file. Then in the __init__py file of the views module, we import all views. For smaller apps e.g badges We can have just a single
If the PlanService has to interact with models from the card app, it would be done via the CardService *(We may need to consider using DI here)
Serializers.py would contain the serializers of the models in their respective app. The serializers would handle validation for things like data type checking, text length check etc. We can have a number of serializers per model. e.g we can have a UserSerializer for update and retrieve and a UserCreationSerializer for create.
Tasks.py would contain app specific background tasks (via celery)
Urls.pywould contain the router for the package. We would then import the router url in the project level router.py.
Utils.py would contain specific functions that are re-used in the app services. We would rarely have to create this file as most of the work would be done by the Services already. We would most likely use the project level utils file for shared utility code used in multiple services.
Another advantage of using Django Rest Framework is the vast amount of libraries one has available to work with.
It requires little configuration as drf is able to read metadata from serializers and use the model structure create the documentation. It is also customizable.
We would be handling permission with DRF’s default permission handler. We’d create custom permission classes for different types of users, we would also be considering creating permissions on an app basis e.g