Issues in simple flask development
- All types of logic(db access, processing, ml logic) inside routes
- No proper segregation of logics
- Hard to debug
- Hard to maintain in production environment
Solution : Follow MVC
red lines means no direct communication between the layers.
In this series i will try to explain steps to productionize simple flask application with MVC architecture to separate logic between different layers. This helps to track issues and maintain code in production environment.
In this repo you can find a boiler plate code with proper layer segregation.
very simple flask application
flask application with database initialization and migration
flask application with proper MVC architecture/layer separation
Step 3 is a simple application with 4 NLP apis.
- Process text to get NER, POS and tokenization results. (POST
/api/process_doc, api params:
task (ner, pos, tokens))
- Get all results stored in database. (GET
- Get result by result id. (GET
- Delete any result by result id. (DELETE
Things to learn/check:
- How to use
yamlfor application configuration.
- How to load ML models once rather then loading it again and again.
- Proper segregation of layers and logics.
- Simple application level logging using
- Database (SQLite)