I'm building a business application which will support multiple Loan products.
for eg: Home Loan, Car Loan, Personal Loan, E-commerce Loan.
The major steps involved are :
An example of the business flow is :
Customer comes on-board, registers his mobile number, verifies it with OTP
fills his personal information (validate it)
provides the loan amount
check loan credibility
Allocate funds (after XYZ validations)
Provide Bank Account details
Verify Bank Account (only after you have abc information)
Do eKYC
Disburse
Now, I'm building the same using Django REST Framework for building Web APIs. However, there's a concern.
In another product of ours, the flow can be different. Step 4
and Step 6
can be interchanged, but Step 7
need to be done at the same position. Basically, I should have the flexibility to reshuffle the activities (nodes).
As of right now, the APIs written (although modular) is specific for only one product. How can I use DRF as a workflow approach? or use any library on top of DRF that can govern the flow.
We had a similar usecase and used a flow library which would capture the entire worflow based on a condition driven flow.
You can look into Viewflow: https://github.com/viewflow/viewflow
Basically it's like setting a flow and utilizing the condition to direct and redirect to different mechanism. Their simple quickstart page tells you how you can achive it: http://docs.viewflow.io/viewflow_quickstart.html
I just tried some sample flow in your case:
class CustomerProcessFlow(Flow):
process_class = CustomerProcess
start = (
flow.Start(
views.CustomerOnBoardView # Let's say this is your customer onboard view
fields=["customer_name", "customer_address", "customer_phone"]
).Permission(
auto_create=True
).Next(this.validate_customer)
)
validate_customer = (
flow.View(
views.ValidateCustomerDataView # Validation for customer data,
fields=["approved"]
).Permission(
auto_create=True
).Next(this.loan_amount)
)
loan_amount = (
flow.View(
views.LoanView # Provide Loan
fields=["loan_amount"]
).Permission(
auto_create=True
).Next(this.check_customer_association)
)
check_customer_association = (
flow.If(lambda customer_association: ! customer.type.normal)
.Then(this.step_4_6)
.Else(this.step_6_4)
)
step_4_6 = (
flow.Handler ( this.check_load_credibility_data )
.Next( this.provide_bank_details_data )
)
step_6_4 = (
flow.Handler( this.provide_bank_details_data )
.Next(this.check_load_credibility)
)
this.check_load_credibility = (
flow.Handler( this.check_load_credibility_data )
.Next( this.end )
)
this.provide_bank_details_data = (
flow.Handler( this.provide_bank_details_data )
.Next(this.end)
)
end = flow.End()
def check_load_credibility_data(self, customer):
# Load credibility
def provide_bank_details_data(self, customer):
# Bank Details
An example can be seen here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With