Introduction
This online mortgage platform project I’ve been involved in undoubtedly represents the pinnacle of my professional career, it took 6 years from my very first job as a freelance developer to the realization of this mortgage platform, which by the way was recently highlighted by a renowned news report, the ICT Journal.
Solicited by the Crédit Agricole Next Bank (CA next bank), we were mandated to carry out a large-scale project that had been relegated to oblivion for some time. The reason why the bank did not want to entrust this task to its internal team of IT experts was their lack of flexibility and speed, two characteristics that are essential for the banking sector, but not very well adapted to web development.
Preliminary analysis
First, our mission was to design a POC (proof-of-concept) to identify and anticipate all the problems we could face during the actual development phase. This allowed us to make preliminary corrections, thus guaranteeing the optimal progress of the project. Without going into detail, we identified several major risks and developed appropriate solutions.
Once we had clearly identified the risks and planned corresponding solutions, we started the development with a good momentum. However, we did not anticipate one major risk, which turned out to be more complex than expected and for which we did not have a clear solution: the complexity of the possible choices and options!
Complexity
Indeed, our goal was to design a platform where each answer would influence the following questions. Although this may seem easy to achieve with Symfony, I had already implemented such a system for online account opening for another bank, it was clear that we were facing a completely different scale this time. It was no longer just a matter of proposing a few variations of a common pathway, but of interconnecting each answer with the other 400 questions. To give you an idea of the absurd complexity we were faced with, the display rules looked like this:
# | Question | Display | Choices | Specificities |
---|---|---|---|---|
1 | Type of projcet | Always | Buy, Transferring, Construction, Renovation, Other | - |
2 | Already found | If #1 = Buy | Yes, No | - |
3 | Renovation | If #1 = Transferring or if #2 = Yes | Yes, No | If #1 = Transferring, change label |
4 | Country | If #1 = Construction ou Renovation or if #2 = No or #3 is filled | Countries | If #2 = No, change label |
5 | Usage | After #4 | Types of residence | - |
6 | Swiss resident | After #5 or directly after #1 if #1 = Other | Yes, No | - |
With over 400 questions and such complex rules, our initial approach of using Symfony’s form events to dynamically generate the questions proved inefficient. Even after integrating only the first ten questions, we found ourselves overwhelmed by if
conditions nested to abysmal depths, which prevented us from moving forward.
We had to quickly find a solution that met several criteria:
- Not to be confronted with an exponential complexity as we progressed in the questions.
- To respect all the specified rules.
- Avoid incomplete paths.
- Be easily understandable, scalable and maintainable.
- Allow the modification of a question in the middle of the path without having to redo the entire site code.
GPS
So I decided to take the problem the other way around, to rethink the rules and questions grid from a different angle, and to simultaneously develop a control engine for the Symfony form generation system, as well as a generator that would produce the rules for the engine.
My idea was the following: rather than considering the user journey as a succession of pages and questions, I tried to assimilate it to a somewhat simplistic GPS navigation system. Each question is a road, each possible answer is a crossroads, and the role of the GPS is to memorize the roads already taken to anticipate future possibilities and identify the roads that are no longer accessible.
This meant that we had to think of the questions not as a question = several options, but as a user path = a list of answers. For example, here are some possible paths:
# | Journey type | Question 1 | Question 2 | Question 3 | Question 4 |
---|---|---|---|---|---|
1 | Buy in Switerland | Buy | Yes | No | Switerland |
2 | Simulation | Buy | No | - | Switerland |
3 | Transferring in Switerland | Transferring | - | No | Switerland |
By isolating each individual path, I was able to provide them to the engine I had developed earlier, allowing to create a considerable logical tree including each question, the possible choices, and the next questions according to the selected answers, etc. This system allowed the Symfony form engine to follow this tree, question by question, answer by answer, in order to display the questions already answered by the user, the next question and the available options.
From this seemingly insurmountable situation in front of the mountain, or rather the planet of if
conditions we had to integrate, we switched to the simple individual management of the paths by the “mapper” engine, which was able to identify and group the common branches, create a tree and store it as PHP files ready to be loaded by Symfony. Afterwards, the form engine only had to play the role of a simplistic GPS, not knowing what the final destination is, but knowing the previous steps and the next junction to reach.
Conclusion
To give you an idea of the efficiency of the system, during the very first sprint, the one where we were confronted with the complexity of the rules to implement, the progress diagram did not evolve, and no ticket was really solved. However, after implementing this GPS and mapping system, we were able to fully complete each sprint, with the time now spent isolating each individual path instead of coding the rules directly into the code. In addition, the final tree allowed us to traverse over 650 million different paths…
In the end, the project went extremely well, and was the most exciting experience I’ve had the chance to work on so far, a real favorite! This recognition was reinforced when the platform was featured in the ICT Journal.
Since then, I continue to maintain the online mortgage platform and add new paths when the client wants to make evolutions.