Phoenix contexts are simpler than you think · Arrowsmith Labs
2025-06-30
Phoenix contexts are simply Elixir modules that group conceptually related functions together, serving as the primary organizational pattern for core business logic in the lib/<app_name> directory. Phoenix codebases split functionality into two directories—lib/<app_name> for app-agnostic business logic (database queries, permissions, notifications) and lib/<app_name>_web for web-specific concerns (HTTP handling, routing, HTML rendering)—and contexts define the boundaries between these layers by providing a clean interface through which the web layer communicates with the application layer.
Was this useful?