Dev Log - Week 2: Database Consistency, MVC, Dynamic Form System

Back   Posted on 5 october 2025
Reading time 3 minutes

This week's work has been dense, technical, and foundational. My focus has been on three major pillars that are now shaping the internal structure of the new module: data consistency, a custom MVC engine and a fully dynamic Form system.

Enforcing Data Integrity: Constraints and Triggers

A significant portion of this week's effort has gone into improving data reliability at the database level.

I introduced a consistent system of foreign key constraints and SQL triggers to guarantee uniformity and correctness across all tables. This ensures that every operation, whether it comes from WHMCS itself or from the custom side of the module, remains coherent, synchronized and automatically validated at the lowest possible layer.

It's a high-level design choice that prevents inconsistencies before they even reach the application logic and it's now an integral part of the module's foundation. Simply put, deleting an invoice now automatically removes not only the data stored in WHMCS' standard tables, but also any related data stored in the Katamaze module. No more orphaned records and scripts coded to deal with them.

MVC Structure

Alongside that, I've built the engine that governs how all data and logic are transmitted to the frontend (Smarty templates and beyond).

In simpler terms, I've created the internal architecture that allows me to develop module pages and interfaces using a proper Model-View-Controller (MVC) approach. This gives me:

  • A clear separation between logic and presentation
  • Automatic and predictable data flow
  • Uniform handling of variables, translations and rendering
  • A structured environment to scale future interfaces efficiently

It's a completely custom engine (lightweight, automatic and technically precise) that makes every part of the module both robust and easy to evolve. To clarify, MVC is already implemented in my current modules, but back when I first built them, during the WHMCS v5 era, there wasn't an easy or clean way to achieve it, so I had to rely on a few hackish workarounds.

The Dynamic Form Class

The other major milestone of the week is the creation of the Form class, which dynamically generates every input element used within the module's interfaces. This system can automatically build:

  • Text, password, and hidden inputs
  • Textareas and file uploaders
  • Checkboxes and radio buttons
  • Color pickers and date/time selectors

Everything is fully dynamic and multilingual all inside Smarty templates, where I can generate any input simply by calling the Form class and passing the relevant parameters (type, name, value, options etc.).

No manual HTML is required. The class handles consistency, structure and attributes, allowing me to write less code and develop much faster.

One of the best examples of this flexibility is the date picker. By specifying the input type and a few attributes, the Form class automatically produces a complete, interactive date selector, with optional predefined ranges (eg. Last 7 days, This week / last week, This year / last year)

The same applies to datetime pickers, where users can select not just a date but also hours, minutes and seconds. Here too, I can quickly define time-based presets (eg. Last 5 minutes, Last 3 hours, Last 12 hours).

All presets, ranges and constraints are entirely configurable, making the UI both powerful and intuitive while maintaining strict internal consistency.

Why This Matters

These advancements are not just about convenience, they represent a deep architectural improvement.

Every interface, from configuration screens to data visualization panels, will now be built on top of this clean, modular, and multilingual framework. This ensures the same reliability, uniformity and maintainability across the entire system.

Of course, a similar class already exists in my current modules, but just like with MVC, it was originally built for WHMCS 5 and still relies on hackish code to get the job done in the old environment.

What's Next

Next week, I'll focus on completing the final refinements of the Form class, ensuring every input type and edge case is fully covered.

Once that's complete, I'll move to the data representation layer, starting with table structures and integrating them with (probably) advanced DataTables integration for dynamic, sortable and searchable datasets.

Comments (0)

Speak Your Mind Cancel Reply