technical case study

SaaS • Technical system / Simulator

MotionCalc

Technical system for calculating, simulating and validating elevator traffic, with dynamic recommendations for speed, number of cars and capacity.

Product, architecture, business rules and development Mature MVP Evolving technical product
PHP JavaScript MySQL Dompdf Docker
executive summary

Problem

Elevator traffic validation relied on spreadsheets and manual tests, making it hard to compare scenarios quickly and see what had to change for approval.

Solution

A web system was built to simulate scenarios, apply technical rules and recommend speed, number of elevators and commercial capacity/load.

Result

MotionCalc turned a technical calculation into a faster, more visual and traceable workflow, laying the base for history, reports and recurring validations.

Current stage

Mature MVP with working calculations, history, dynamic feedback and a base ready for PDF reports.

context

From a technical spreadsheet to a decision tool

MotionCalc was created to replace a spreadsheet-based technical process with a clearer web application. It lets different combinations of building type, population, speed, number of elevators and capacity be tested quickly, showing not only whether a scenario passes or fails, but which technical adjustment brings the project closer to approval.

goals and constraints

Goals

  • Turn elevator traffic rules into a usable web workflow
  • Allow quick simulation of different scenarios before saving a calculation
  • Return objective recommendations for speed, number of elevators and capacity
  • Separate validation feedback, confirmed history and future report generation

Constraints

  • Keep the system from becoming just a visual copy of the original spreadsheet
  • Keep technical parameters editable and easy to test
  • Use commercial capacity/load options instead of loose averages
  • Distinguish a simulated calculation from one confirmed in the history
solution architecture

Front-end

Interface in PHP, custom CSS and JavaScript, with a calculation form, live feedback and a results area designed for quick reading of the technical recommendations.

Back-end

PHP layer organized into controllers, services and repositories, separating user input, business rules, calculation, persistence and history.

Database

MySQL schema for technical parameters, commercial options, confirmed calculations, history, validation status and forced-save flags.

security and safeguards

Parameter validation

Calculation inputs are processed before simulation to avoid inconsistent scenarios and keep results technically sound.

Simulate vs. save

Users can test freely before confirming, so incomplete calculations don't pollute the official history.

Traceable exceptions

Scenarios saved by force can be flagged and justified, keeping the technical context for later review.

process
01

Mapping the rules

Gathering the variables and technical criteria used to validate elevator traffic.

02

First working calculation

Initial flow to receive parameters, calculate indicators and return approval or the need for revision.

03

Dynamic feedback

Results evolved to show which speed, quantity and capacity adjustments are needed to pass validation.

04

History and reports

Separating simulation from confirmation, creating the base for calculation history and PDF generation.

behind the scenes
app/Services/ElevatorTrafficCalculator.php PHP lines 7–61
public function calculate(array $input): array
{
    $populationTotal = $this->calculatePopulationTotal($input['population_items']);

    $probableStops = $this->calculateProbableStops(
        (int) $input['stops'],
        (int) $input['cabin_capacity']
    );

    $travelMeters = (float) $input['travel_meters'];
    $speedMs = (float) $input['speed_ms'];

    $t1 = $speedMs > 0
        ? (2 * $travelMeters) / $speedMs
        : 0;

    $t2 = $probableStops * (float) $input['acceleration_time'];

    $t3 = $probableStops * (float) $input['door_time'];

    $t4 = 2 * (float) $input['cabin_capacity'] * (float) $input['passenger_time'];

    $subtotal = $t1 + $t2 + $t3 + $t4;

    $additional = ((float) $input['additional_percent'] / 100) * ($t3 + $t4);

    $totalTripTime = $subtotal + $additional;

    $groupUnits = max((int) $input['group_units'], 1);

    $trafficInterval = $totalTripTime / $groupUnits;

    $capacity5min = $totalTripTime > 0
        ? ($groupUnits * (float) $input['cabin_capacity'] * 300) / $totalTripTime
        : 0;

    $capacityPercent = $populationTotal > 0
        ? ($capacity5min / $populationTotal) * 100
        : 0;

    return [
        'population_total' => $populationTotal,
        'probable_stops' => $probableStops,
        't1_total_travel' => $t1,
        't2_acceleration' => $t2,
        't3_doors' => $t3,
        't4_passengers' => $t4,
        'subtotal' => $subtotal,
        'additional_time' => $additional,
        'total_trip_time' => $totalTripTime,
        'traffic_interval' => $trafficInterval,
        'capacity_5min' => $capacity5min,
        'capacity_percent' => $capacityPercent,
    ];
}
Service with the traffic calculation: times T1 to T4, total round-trip time, interval between departures and 5-minute handling capacity.
public/assets/js/main.js JavaScript lines 121–185
function initLiveCalculation() {
    const form = document.querySelector('[data-live-calculation-form]');

    if (!form) {
        return;
    }

    form.querySelectorAll('input, select, textarea').forEach((field) => {
        field.addEventListener('input', () => scheduleLiveSimulation(form));
        field.addEventListener('change', () => scheduleLiveSimulation(form));
    });

    form.addEventListener('input', () => scheduleLiveSimulation(form));
    form.addEventListener('change', () => scheduleLiveSimulation(form));

    simulateCalculation(form);
}

function scheduleLiveSimulation(form) {
    clearTimeout(liveSimulationTimer);

    liveSimulationTimer = setTimeout(() => {
        simulateCalculation(form);
    }, 250);
}

async function simulateCalculation(form) {
    const els = getLiveCalculationElements();

    if (!els.status || !els.saveButton) {
        return;
    }

    try {
        const formData = new FormData(form);

        const response = await fetch('/calculos/simular', {
            method: 'POST',
            body: formData,
            headers: {
                'X-Requested-With': 'XMLHttpRequest',
            },
        });

        const data = await response.json();

        if (!response.ok || !data.ok) {
            throw new Error(data.message || 'Erro ao simular cálculo.');
        }

        renderLiveCalculation(data, els);
    } catch (error) {
        console.error('Erro ao simular cálculo:', error);

        els.status.textContent = 'Erro';
        els.status.className = 'status-badge status-review';

        if (els.message) {
            els.message.textContent = 'Não foi possível calcular em tempo real. Verifique a rota /calculos/simular ou os dados preenchidos.';
        }

        els.saveButton.disabled = true;
        els.saveButton.textContent = 'Salvar indisponível';
    }
}
Every form change schedules a simulation (250 ms wait) and the validation panel updates without reloading the page.
app/controllers/CalculationController.php PHP lines 112–188
public function store(): void
{
    $payload = $this->buildCalculationPayload($_POST);

    $projectData = $payload['project'];
    $elevatorData = $payload['elevator'];
    $populationItems = $payload['population'];
    $calculatorInput = $payload['input'];

    if ($projectData['project_name'] === '') {
        $_SESSION['flash_error'] = 'Informe o nome do projeto.';
        redirect('/calculos/novo');
    }

    if (empty($populationItems)) {
        $_SESSION['flash_error'] = 'Informe pelo menos uma linha de população.';
        redirect('/calculos/novo');
    }

    $forceSave = !empty($_POST['force_save']);
    $forcedReason = trim($_POST['forced_reason'] ?? '');

    $overrides = [
        'ignore_interval_rule' => !empty($_POST['ignore_interval_rule']),
        'ignore_capacity_rule' => !empty($_POST['ignore_capacity_rule']),
    ];

    $usageParameterRepo = new UsageParameterRepo();
    $usageParams = $usageParameterRepo->findByUsageType($projectData['usage_type']);

    $calculator = new ElevatorTrafficCalculator();
    $validator = new CalculationValidator();

    $result = $calculator->calculate($calculatorInput);
    $validation = $validator->validate($result, $usageParams, $overrides);

    $finalResult = array_merge($result, $validation);

    if ($finalResult['final_status'] !== 'approved' && !$forceSave) {
        $_SESSION['flash_error'] = 'Este cálculo ainda não atende aos critérios técnicos. Ajuste os dados ou use o salvamento forçado.';
        redirect('/calculos/novo');
    }

    if ($finalResult['final_status'] !== 'approved' && $forceSave) {
        $finalResult['is_forced_save'] = 1;
        $finalResult['forced_reason'] = $forcedReason !== ''
            ? $forcedReason
            : 'Salvamento forçado pelo negociador.';

        $finalResult['final_status'] = 'forced';
        $projectData['final_status'] = 'forced';
    } else {
        $finalResult['is_forced_save'] = 0;
        $finalResult['forced_reason'] = null;

        $projectData['final_status'] = 'approved';
    }

    $projectRepo = new ProjectRepo();
    $populationRepo = new PopulationRepo();
    $elevatorDataRepo = new ElevatorDataRepo();
    $calculationRepo = new CalculationRepo();

    $projectId = $projectRepo->create($projectData);

    $populationRepo->createMany($projectId, $populationItems);
    $elevatorDataRepo->create($projectId, $elevatorData);
    $calculationRepo->create($projectId, $finalResult);

    $projectRepo->updateStatus($projectId, $finalResult['final_status']);

    $_SESSION['flash_success'] = $finalResult['final_status'] === 'forced'
        ? 'Cálculo salvo no histórico por confirmação forçada.'
        : 'Cálculo aprovado e salvo no histórico.';

    redirect('/calculos/' . $projectId);
}
On save, the calculation is redone on the server: it only enters the history if approved or if the salesperson forces the save with a justification.
impact

Results

MotionCalc reduced the reliance on manual spreadsheet analysis, made scenario testing faster and created a consistent base for technical decisions, history and reports.

Learnings

The project reinforced the importance of turning complex rules into actionable feedback: a good technical system doesn't just calculate, it points to the next adjustment.