> For the complete documentation index, see [llms.txt](https://razortheory.gitbook.io/third-party-monitoring-module-documentation/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://razortheory.gitbook.io/third-party-monitoring-module-documentation/technical-documentation/module-structure.md).

# Backend Module structure

### TPM module files structure

![](https://3736791516-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2F-LJxGPxbbRc1mv-_gOuP%2F-LMlDkdkDFkNn5hs3Zq0%2F-LMlT70lmwtLzgARpmgM%2Fimage.png?alt=media\&token=63d4683c-d99c-440a-8c3e-695462324428)

`export` - everything that is related to csv & pdf exports\
`management` - specific management commands (in our case there is only one command for updating permissions)\
`migrations` - database migrations\
`notifications` - templates for email notifications\
`serializers`- rest framework serializers\
&#x20;   \- `attachments.py` - visit attachments serializers\
&#x20;   \- `partner.py` - tpm partner serializers\
&#x20;   \- `visit.py` - serializers for visit, activity, \
\- `templates` - templates to be used in various exports. visit letter & activities pdf export\
\- `tests` - tests for models, views, serializers, transitions flow\
\-  `tpmpartners` - nested global application to keep shared across the countries information about tpm firm\
\- `transitions` - everything that is related to fsm transitions\
&#x20;   \- `conditions.py` - custom checks for transitions (for example in case of submitting report we need to be assured that report attachments exist)\
&#x20;   \- `serializers.py` - transitions serializers to validate their input arguments (see more in [permissions framework section](/third-party-monitoring-module-documentation/technical-documentation/permissions-framework.md#views))\
\- `admin.py` - admin site definitions for models\
\- `apps.py` - python app configuration\
\- `conditions.py` - conditions for permissions framework. [see more details here](/third-party-monitoring-module-documentation/technical-documentation/permissions-framework.md)\
\- `filters.py` - rest framework views filters\
\- `metadata.py` - base metadata class to be used in viewsets. more in [API Metadata section](/third-party-monitoring-module-documentation/technical-documentation/api-metadata.md)\
\- `models.py` -  country-related tpm models\
\- `signals.py` - app signals. custom logic for user deletion; sending notifications in case of assigning action points\
\- `urls.py` - app urls\
\- `views.py` - just set of views to work with models

### tpm.tpmpartners app

To store the global data that is related to TPM,  nested application named `tpmpartners` was implemented.\
Views and serializers are still located in the parent application to keep the consistant place for all module logic.

The App consists of the following parts:\
\- `migrations` - database migrations\
\- `models.py` - partner with their staff members\
\- `synchronizer.py` - VISION partner synchronizer\
\- `tasks.py` - periodic tasks, which are responsible for keeping the partners synced with the VISION<br>
