- 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
Here 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:text
&task (ner, pos, tokens)
) - Get all results stored in database. (GET
/api/all_results
) - Get result by result id. (GET
/api/result/<id>
) - Delete any result by result id. (DELETE
/api/result/<id>
)
Things to learn/check:
- How to use
yaml
for 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
TimedRotatingFileHandler
. - Database (SQLite)