Search FlexiRule docs

Recent
Pinned

Press Esc to close. Use arrow keys and Enter inside results. Searches are remembered locally.

FlexiRule Docs

Why is FlexiRule better than hard-coded customizations?

A separation-of-concerns approach showing how FlexiRule complements custom development by isolating business policies from application code.

Improve this page

Separation of Concerns in Frappe Systems#

FlexiRule is not an alternative to custom development. It is an alternative to embedding evolving business policies inside application code.

In Frappe and ERPNext systems, custom development and FlexiRule are not competing approaches. They operate at different layers of the system:

  • Custom development builds capabilities
  • FlexiRule defines and manages evolving business policies on top of those capabilities

This separation is the foundation of scalable and maintainable business automation.


Technical Logic vs Business Logic#

A healthy system clearly distinguishes between what the system does and how business decisions are made.

Technical Logic (Custom Code)Business Logic (FlexiRule)
API integrationsApproval policies
Database access & schema designDiscount & pricing rules
Framework extensionsValidation policies
Background workersEscalation rules
Custom DocTypesCross-process automation
System hooks/eventsBusiness workflows

Core principle#

Technical logic belongs in custom development. Business logic belongs in configurable rules.

FlexiRule focuses exclusively on the second category.


Choosing the Right Approach#

Different requirements naturally belong to different layers of the system:

RequirementRecommended Approach
Build a new DocTypeCustom App
Extend Frappe framework behaviorCustom Code
Build reusable framework componentsCustom Code
Integrate external servicesCustom Code (optionally exposed as FlexiRule Process)
Implement dynamic approval policiesFlexiRule
Define validation policiesFlexiRule
Define pricing/discount rulesFlexiRule
Automate cross-document workflowsFlexiRule
Combine system capabilities with business rulesBoth together

FlexiRule is most valuable when logic is policy-driven, frequently changing, and business-owned.


What Happens Over Time?#

In many real systems, business rules start simple but gradually spread across multiple layers:

  • Python hooks
  • Server scripts
  • Custom app overrides
  • Background jobs
  • Patch scripts
  • Edge-case fixes across modules

Initial implementation
Server Script added
Hook introduced
Custom method in app
Background worker added
Patch script for edge case
Logic scattered across multiple layers

At this point, understanding a single business rule requires tracing logic across the entire codebase.

The problem#

Business intent becomes fragmented across implementation details.

The FlexiRule approach#

FlexiRule centralizes this category of logic into a single, structured, and inspectable rule layer, making business behavior explicit rather than implicit in code paths.


Maintainability & Ownership#

The real cost of embedded business logic is not implementation—it is long-term evolution.

1. Discoverability#

Instead of searching across files and modules, all business rules are visible in one place.

2. Ownership clarity#

It becomes clear whether a change is:

  • Technical responsibility → custom code
  • Business policy change → FlexiRule

3. Change history & governance#

Rules evolve with:

  • version tracking
  • lifecycle states
  • audit-friendly change history

instead of being hidden inside distributed Git commits.

4. Debugging simplicity#

Rather than tracing execution across code paths, you inspect:

  • rule definition
  • execution trace
  • decision flow

5. Faster onboarding#

New developers and functional consultants can understand system behavior without reading the entire codebase.


FlexiRule and Developers: A Collaborative Model#

FlexiRule does not reduce the need for developers—it redefines how their work is reused.

Developers remain responsible for building system capabilities, including:

  • Action Types → reusable executable blocks
  • Value Resolvers → dynamic data evaluation logic
  • Processes → structured execution workflows
  • Integrations → external system connectors

Once defined, these components become reusable building blocks inside FlexiRule.

Key principle#

Developers build capabilities. FlexiRule assembles those capabilities into business behavior.

This creates a clean separation between engineering effort and business configuration.


Comprehensive Comparison#

AspectCustom CodeFlexiRule
Primary purposeSystem capability implementationBusiness policy definition
Change frequencyLower, stable logicHigher, evolving rules
Primary usersDevelopersDevelopers + Business users
Logic locationDistributed across codebaseCentralized rule registry
Governance modelGit + code reviewRule lifecycle + optional Git
TraceabilityCode navigationVisual rule inspection
DebuggingCode tracingExecution flow & rule debugger
ReusabilityCode-level reuseConfigurable reusable components
Upgrade impactDepends on couplingReduced business logic coupling

Real-World Example: Discount Policy#

Without FlexiRule#

A discount policy is typically scattered across:

  • sales_order.py
  • pricing modules
  • server scripts
  • hooks
  • background jobs

Business intent is fragmented and difficult to audit.

With FlexiRule#

The same logic becomes a single structured rule:


Discount Policy Rule
├── Customer Type Check
├── Order Value Threshold
├── Credit Status Validation
└── Manager Approval Condition

Everything is:

  • visible
  • editable
  • traceable
  • centralized

When to Use What#

Use Custom Development when:#

  • Building core system capabilities
  • Extending Frappe framework behavior
  • Designing data models (DocTypes)
  • Integrating external systems or APIs
  • Creating reusable technical infrastructure

Use FlexiRule when:#

  • Business policies change frequently
  • Non-developers need visibility or control
  • Logic spans multiple processes or modules
  • You need centralized governance of decision-making logic

Use Both when:#

  • Technical capabilities must be exposed as configurable behavior
  • Business logic depends on system-level integrations
  • You want collaboration between developers and business teams

Final Thought#

FlexiRule is not designed to reduce the role of custom development.

It is designed to separate concerns within it.

By moving business policies out of application code and into a structured rule layer, systems become:

  • easier to understand
  • easier to evolve
  • easier to govern
  • more transparent in behavior

while preserving the full power of custom development where it belongs.

Last updated Jun 26, 2026