The cleaned backend removes the weakest parts of the original exercises.

The main improvements are configuration separation, centralized database access, validation before insert, and prepared statements for database writes.

Configuration

01

Database settings are isolated in one file so credentials are not repeated across handlers.

return [
    'db_host' => '127.0.0.1',
    'db_port' => 3306,
    'db_name' => 'flowledger',
    'db_user' => 'root',
    'db_password' => '',
];

Insert path

02

The create handler builds a normalized payload, validates it, prepares the SQL statement, then binds values in the expected column order.

$statement = $connection->prepare(
    'INSERT INTO customers
    (customer_id, first_name, last_name, gender, email, phone, address)
    VALUES (?, ?, ?, ?, ?, ?, ?)'
);

Read path

03

The listing page keeps the read query simple and focuses on returning a complete view of each customer record.

$result = $connection->query(
    'SELECT customer_id, first_name, last_name, gender, email, phone, address, created_at
     FROM customers
     ORDER BY created_at DESC'
);
Removed problems
  • Hard-coded credentials inside action files.
  • Duplicate PHP variants that did the same job inconsistently.
  • Malformed or incomplete exercise files in the main project root.
Current state
  • One cleaned create flow.
  • One cleaned list flow.
  • One schema file and one connection helper.