# Backend Module structure

### TPM module files structure

![](/files/-LMlT70lmwtLzgARpmgM)

`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>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://razortheory.gitbook.io/third-party-monitoring-module-documentation/technical-documentation/module-structure.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
