Modular design
🚧 Sprout is still in active development and evolving quickly, so the documentation and functionality may not work as described and could undergo substantial changes 🚧
While we describe how we implement aspects of modular design across all Seedcase products in our design documentation, this document explains this split between Python code, CLI, web app, and web API in the context of Sprout.
Python modules
In order to achieve our aims, the main functionality is designed and implemented as a Python package and can be used as a Python package. This code is stored in the Python module (folder location) seedcase_sprout/core/
and is accessible via the Python code import seedcase_sprout.core as sp
statement. Only external-facing functions would be exposed to the user and to other programs.
The core
functions and classes aim to have as few external assumptions and dependencies as possible. For instance, input and output don’t depend on the state of any other function. This way, we can have a highly flexible, modular, and easily testable core
that other developers (and potentially users) can easily configure and customize to their own needs. This modular and flexible “lower level” design allows us to create a variety of interfaces and extensions to Sprout.
Any extensions would then only need to incorporate and depend on the seedcase_sprout.core
package to get Sprout’s functionality. Each extension would be its own module within Sprout, with modules named like seedcase_sprout/extension_name/
, for instance, seedcase_sprout/cli/
. That way, within the extension’s module, the logic that we implement is only specific to creating the CLI and not to the actual functionality of Sprout.
Other potential extensions would follow the same or similar pattern. This allows other developers to create their own extensions and interfaces to Sprout that suit their particular needs.
Our Guide has examples and tutorials on how each split is used.
A higher-level, opinionated Python abstraction of
core
, namedlib
and stored inseedcase_sprout/lib/
. This module abstracts away and simplifies many of the steps and functions available incore
, with the consequence of being less flexible and less customizable. This module is intended for users who want to use Sprout without having to worry about the finer details of the exact implementation. The internals of thelib
functions would be strict and opinionated steps for how we envision a data package to be created, structured, and managed.The CLI is placed in the module
seedcase_sprout/cli/
. Each command imports the relevant functions fromseedcase_sprout.core
, along with decorators (from other Python packages) to convert the Python code into a CLI.The web app is in
seedcase_sprout/app/
. Each page of the web app imports the required functions fromseedcase_sprout.core
, with functions from other Python packages that convert that code into a web app.