djangodatabase-designweb-applicationsweb-application-design

Structuring Django application


I am currently working on designing a web application to be used by researchers to conduct reviews. In this application there are two groups of users - participants and administrators.

Only administrators can start a review and can assign any user or administrator to participate in the review as an admin or a screener. The general workflow for each review will be:

  1. Search medical databases and import thousands of references.
  2. Screen references based on title (number of reviewers/admins Screening can be 1 or multiple). Each reviewer will screen all references. Mark each reference as included or excluded.
  3. Screen included references based on abstract. Same as above applies.
  4. Source full-text as PDF and store for included references.
  5. Screen included references based on full text. Same as above applies.
  6. Create custom forms.
  7. Extract data from included references.
  8. Export data

Throughout the progress of the review machine learning on all of the references will be done. We will also require comprehensive logging throughout the review.

My question is this, how can I best split these sections into django apps and how should I structure the required databases.

Provisionally, I've thought about having these databases:

I don't know how to deal with the logging. How can I do this?

Is this a sensible split and if so how should I accordingly split the steps into apps.


Solution

  • The best thing about Django is apps that you create with manage.py startapp <myapp> . Apps gives good control of modularising the code. You are on the right track in modularising the code.

    Regarding your tables users, projects and references sounds reasonable from your explanation.

    If I were you, I would structure apps into something like this.

    apps/ 
        userprofile/ (users table )
        project/ (projects and references tables)
        activity/ (activity and notifications tables)
    

    Regarding logging Each activity like user edits , project edits or deletes can be captured via a post_ or pre_ signals https://docs.djangoproject.com/en/1.10/topics/signals/. User them to create an activity and based on the activity you can publish the single activity to multiple users as notifications ie., a single activity will trigger each notification to multiple users who are participants in the event.

    In each app

    I prefer to use following structure inside each app :

    userprofile/         
        __init__
        views.py
        tests.py
        signals.py # write the post_save pre_save post_delete pre_delete logics here
        managers.py  # take full leverage of managers, and custom querysets
        forms.py
        models.py
        urls.py
        admin.py
        tasks.py # for celery or tasks which will be used by queuing systems
        apps.py 
    

    Regarding version the data

    Try the one which suites your requirement from here https://djangopackages.org/grids/g/model-audit/