Sunday, February 24, 2019

Fuzzy Django Flask App : Django Like Project Structure


While I was going through some legacy system which had 75,000 lines of code written in python/flask. I was wondering why it's not borken up into applications.

After discussion with other developers I came to know about that those codes were written by ex-developers 2 yrs back.

It seems those legends only knew about hello-world-in-flask from documentation because everything is written in myflaskapplication.py file ( 75,000 lines ).
Because, models, controller, blueprints, admin, forms and etc etc were written in myflaskapplication.py file.

Now big pain is to break this system into small application and then into microservices.
Since I've spend so much time working with python/django it wasn't difficult to break system's structure into small application and divide task between other developers.


Sample app can be found at, https://github.com/codetarsier/fuzzy-django-flask
Here is the sample structure.

Project Folders
- common : models and serializer for other application
- <application_structure> : contains, models, views, helpers, serializer, urls and views.
- static : contains all css, js, images
- templates : contains html files and broken into application structure like, templates/portal_setup and templates/common
- config : database, packages, secret settings
Project Structure
├── common
│   ├── __init__.py
│   ├── models.py
│   └── serializers.py
├── config
│   ├── constants.py
│   ├── __init__.py
│   ├── sample_secrets.json
│   └── settings.py
├── config.py
├── manage.py
├── portal_setup
│   ├── admin.py
│   ├── forms.py
│   ├── helpers.py
│   ├── __init__.py
│   ├── models.py
│   ├── serializers.py
│   ├── urls.py
│   └── views.py
├── README.md
├── reports.json
├── requirements.txt
├── static
│   └── portal_setup
│       ├── css
│       └── js
└── templates
    └── portal_setup
        ├── add_portal.html
        ├── base.html
        ├── edit_portal.html
        ├── index.html
        └── portal_details.html













Share: