This article discusses the strategic decision of choosing a framework for production-ready Python services, arguing that a single framework choice can eliminate the need for many individual libraries. It highlights how frameworks bundle solutions for common concerns like CLI, ORM, validation, and scheduling, emphasizing the importance of understanding a framework's capabilities and its inherent trade-offs.
Read original on Dev.to #architectureWhen building production-ready Python applications, the initial choice of a framework profoundly impacts the entire technology stack. The author contrasts a list of 12 common libraries for making scripts production-ready with their own experience using Django for a self-hosted AWS drift detector. Their key insight is that by selecting a comprehensive framework like Django, they implicitly adopted solutions for 10 out of the 12 suggested libraries, avoiding redundant dependencies and potential integration issues.
A robust framework provides a cohesive set of tools and conventions that cover many aspects typically handled by individual libraries. For instance, Django's `manage.py` commands obviate the need for a separate CLI library like `click`. Similarly, its powerful ORM (Object-Relational Mapper) eliminates the necessity for SQLAlchemy, and its built-in forms and model validation address concerns typically handled by `marshmallow`.
Avoid Redundancy: The 'Two ORM' Trap
Adding a library for a function already provided by your framework can lead to significant architectural debt. This includes managing two distinct sets of configurations, migrations, and mental models, which can introduce bugs and increase complexity. The "two ORM" scenario is a prime example of this anti-pattern.
While frameworks cover a lot, they don't cover everything. It's crucial to identify the "seams" or areas where the framework's scope ends. The author found two genuine gaps:
The overarching lesson is that system design starts not with accumulating individual pieces, but with making a foundational choice (like a framework) that pre-answers many architectural questions. Subsequently, disciplined auditing helps identify remaining gaps that require targeted, minimal library additions, matching the complexity of the solution to the actual problem at hand.