⚡
Challenges
1-Implementing Dynamic Form Builder While Maintaining Data Integrity: Converting template forms into running instances without creating destructive dependencies, and properly managing the copying of fields, options, and permissions at runtime.
2-Multi step Workflow Management with Deadline Control: Designing a system where each step has its own independent deadline, records delays, and displays user progress in real time; also allowing rejection and correction at various levels (field, step, entire form) without data loss.
3-Authentication System and Tiered Access Control (RBAC) at Various Layers: Applying granular permissions on forms, steps, and even fields so that each user only sees and fills the data they are authorized for; along with simultaneous management of multiple roles per user.
4-Performance Optimization and Notifications: Reducing server requests using caching (LocMemCache) and intelligent notification management (only when there is a new task) without sending unnecessary notifications, along with Service Worker support for browser notifications.
💡
Solutions
Dynamic Form Builder: Direct storage of input_type in InstanceField and full copying of metadata when creating a copied form to eliminate dependency on the master form.
Workflow & Deadlines: Using JSONField to store the deadline for each step and the step history; start_step and complete_step methods for precise scheduling and delay logging.
Tiered RBAC: Implementation of access_type with options all, specific_role, and specific_user in the field model, and permission checking via the is_accessible_by method at runtime.
Optimized Notification: Caching the number of tasks (LocMemCache) and comparing notified_task_ids to send notifications only when a new task exists; client‑side isFetching management to prevent concurrent requests.
Legacy Data Integration: The fix_instance_field_input_type script with a --dry-run option to recover input_type in previously copied forms without the risk of unintended changes.
📚
Outcomes
Empowering non-technical users: Creating a platform for defining complex forms and organizational workflows without needing even a single line of code, which has minimized dependence on the technical team.
Transparency and full control over processes: Implementation of an intelligent approval/rejection system at three levels (field, step, and entire form), along with complete history logging and real-time progress display, which has made organizational management more transparent.
Security and access management at the most granular level: Successful implementation of a role-based authentication system (RBAC) that controls user access even down to a specific field level, ensuring data security.
Increased productivity through performance optimization: Significant reduction in server requests through smart caching and sending real-time notifications only when a new task exists, which has made the user experience smoother.
Compatibility with Iran's infrastructure and organizational culture: Full support for Jalali (Persian) dates, professional outputs (PDF, Excel), and the ability to connect to MySQL, making it fully practical for Iranian organizations.
Upgradability to full organizational integration: Modular system design that allows the addition of financial, inventory, and sales modules, establishing the infrastructure for a comprehensive ERP.
🔧
Technical Highlights
Modular architecture and complete layer separation: Separation of applications into dynamicform (form definition), form_flow (execution and workflow), form_review (approval/rejection), reports (reporting), and account (user and role management), which has greatly simplified development and maintenance.
Elimination of destructive dependencies through direct metadata storage: Storing input_type and step_title directly in InstanceField instead of referencing FormInput, ensuring that copied forms remain completely independent and stable after changes or deletion of the master form.
Workflow management using JSONField and atomic transactions: Using JSONField to store step history (step_history) and deadlines for each step (step_deadlines); along with using transaction.atomic() in key views to guarantee data integrity.
Dynamic authentication and access system at three levels: Implementation of access_type with options all, specific_role, and specific_user in the field model, and the is_accessible_by method for runtime permission checking; along with support for multiple roles per user.
Performance optimization through smart caching and request management: Using LocMemCache to cache the task count for each user (timeout=5) and implementing isFetching on the client side to prevent concurrent requests and reduce server load.
Advanced notification system with Service Worker: Registering sw.js and using the Push API to send browser notifications even when the browser is closed; along with notified_task_ids management to prevent duplicate notifications.
Management scripts for data integration: The fix_instance_field_input_type script with --dry-run and --instance-id options to recover legacy data without the risk of unintended changes.
Support for Persian (Jalali) dates and various outputs: Using persiantools to convert dates to Jalali in templates and views; along with professional output generation (PDF with reportlab, Excel with openpyxl and xlsxwriter).
Responsive UI with dark mode: Implementing custom styles to support dark theme ([data-bs-theme="dark"]) across all templates; along with sticky buttons at the bottom of pages to improve mobile user experience.
🏗️
Architecture
The project architecture is designed based on Django with a modular and layered approach. Independent applications including dynamicform (template form definition), form_flow (execution and workflow), form_review (approval/rejection), reports (reporting), and account (user management and RBAC) are completely separated to facilitate development and maintenance. The core of the project achieves high stability and flexibility by eliminating metadata dependencies (direct storage of input_type and step_title in copied forms) and using JSONField to manage step history and deadlines. Additionally, the authentication and access control system is implemented at three levels (form, step, and field) and, utilizing caching (LocMemCache) and Service Worker, delivers optimal performance and user experience.
📐
Project Scale
The project includes 9 separate applications, over 30 models, approximately 50 views, and 40+ templates, totaling over 10,000 lines of code (including backend, frontend, and management scripts). This system, with support for 18 field types, management of multi‑step forms with separate deadlines, an approval/rejection system at three levels, and role‑based access control, is designed for medium to large organizations (100 to 500+ concurrent users) and has the capability to be upgraded into a full ERP with financial, inventory, and sales modules.