refactoring: transform main.py messy file into an App class to avoid duplication