Index: view-database.js
===================================================================
--- view-database.js	(revision 2d1ec46933bbbd721e985423c96581bc0a7485ed)
+++ view-database.js	(revision 69f2a41cff81a4c7825abb68eb0f0eff6818e4e5)
@@ -3,10 +3,5 @@
 
 const dbPath = path.join(__dirname, 'database', 'handcraft.db');
-const db = new sqlite3.Database(dbPath, (err) => {
-    if (err) {
-        console.error('Error opening database:', err.message);
-        process.exit(1);
-    }
-});
+const db = new sqlite3.Database(dbPath);
 
 console.log('\n🎨 HANDCRAFT MARKETPLACE - DATABASE CONTENTS\n');
@@ -30,82 +25,43 @@
 }
 
-// Main execution chain
-function executeChecks() {
-    let currentCheck = 0;
-
-    const checks = [
-        { name: 'clients', func: checkClients },
-        { name: 'personal', func: checkPersonal },
-        { name: 'store', func: checkStore },
-        { name: 'product', func: checkProduct },
-        { name: 'category', func: checkCategory },
-        { name: 'works_in_store', func: checkWorksInStore },
-        { name: 'permissions', func: checkPermissions },
-        { name: 'employees', func: checkEmployees },
-        { name: 'boss', func: checkBoss },
-        { name: 'order', func: checkOrder },
-        { name: 'report', func: checkReport },
-        { name: 'refund', func: checkRefund },
-        { name: 'image', func: checkImage },
-        { name: 'color', func: checkColor }
-    ];
-
-    function next() {
-        currentCheck++;
-        if (currentCheck < checks.length) {
-            checks[currentCheck].func(next);
+// Display CLIENTS table
+console.log('\n👤 CLIENTS TABLE:');
+console.log('================================================================================');
+tableExists('client', (exists) => {
+    if (!exists) {
+        console.log('Table does not exist');
+        checkNext();
+        return;
+    }
+
+    db.all('SELECT * FROM client', [], (err, rows) => {
+        if (err) {
+            console.log(`Error: ${err.message}`);
+            checkNext();
+            return;
+        }
+
+        if (!rows || rows.length === 0) {
+            console.log('No clients found');
         } else {
-            finish();
-        }
-    }
-
-    // Start with first check
-    checks[0].func(next);
-}
-
-// Display CLIENTS table
-function checkClients(next) {
-    console.log('\n👤 CLIENTS TABLE:');
-    console.log('================================================================================');
-
-    tableExists('client', (exists) => {
-        if (!exists) {
-            console.log('Table does not exist\n');
-            if (next) next();
-            return;
-        }
-
-        db.all('SELECT * FROM client', [], (err, rows) => {
-            if (err) {
-                console.log(`Error: ${err.message}\n`);
-                if (next) next();
-                return;
-            }
-
-            if (!rows || rows.length === 0) {
-                console.log('No clients found\n');
-            } else {
-                console.log(`Total: ${rows.length} clients\n`);
-                rows.forEach((client, index) => {
-                    console.log(`ID: ${client.client_id} | Name: ${client.first_name || ''} ${client.last_name || ''}`);
-                    console.log(`Email: ${client.email || 'N/A'}`);
-                    if (index < rows.length - 1) console.log('-'.repeat(80));
-                });
-                console.log(); // Add blank line after table
-            }
-            if (next) next();
-        });
-    });
-}
+            console.log(`Total: ${rows.length} clients\n`);
+            rows.forEach((client, index) => {
+                console.log(`ID: ${client.client_id} | Name: ${client.first_name || ''} ${client.last_name || ''}`);
+                console.log(`Email: ${client.email || 'N/A'}`);
+                if (index < rows.length - 1) console.log('-'.repeat(80));
+            });
+        }
+        checkNext();
+    });
+});
 
 // Display PERSONAL table
-function checkPersonal(next) {
+function checkPersonal() {
     console.log('\n👔 PERSONAL TABLE (STORE OWNERS/EMPLOYEES):');
     console.log('================================================================================');
-
     tableExists('personal', (exists) => {
         if (!exists) {
-            console.log('Table does not exist\n');
-            if (next) next();
+            console.log('Table does not exist');
+            checkStore();
             return;
         }
@@ -121,11 +77,11 @@
         `, [], (err, rows) => {
             if (err) {
-                console.log(`Error: ${err.message}\n`);
-                if (next) next();
-                return;
-            }
-
-            if (!rows || rows.length === 0) {
-                console.log('No personal records found\n');
+                console.log(`Error: ${err.message}`);
+                checkStore();
+                return;
+            }
+
+            if (!rows || rows.length === 0) {
+                console.log('No personal records found');
             } else {
                 console.log(`Total: ${rows.length} personal records\n`);
@@ -135,7 +91,6 @@
                     if (index < rows.length - 1) console.log('-'.repeat(80));
                 });
-                console.log();
-            }
-            if (next) next();
+            }
+            checkStore();
         });
     });
@@ -143,12 +98,11 @@
 
 // Display STORE table
-function checkStore(next) {
+function checkStore() {
     console.log('\n🏪 STORE TABLE:');
     console.log('================================================================================');
-
     tableExists('store', (exists) => {
         if (!exists) {
-            console.log('Table does not exist\n');
-            if (next) next();
+            console.log('Table does not exist');
+            checkProduct();
             return;
         }
@@ -156,11 +110,11 @@
         db.all('SELECT * FROM store', [], (err, rows) => {
             if (err) {
-                console.log(`Error: ${err.message}\n`);
-                if (next) next();
-                return;
-            }
-
-            if (!rows || rows.length === 0) {
-                console.log('No stores found\n');
+                console.log(`Error: ${err.message}`);
+                checkProduct();
+                return;
+            }
+
+            if (!rows || rows.length === 0) {
+                console.log('No stores found');
             } else {
                 console.log(`Total: ${rows.length} stores\n`);
@@ -172,7 +126,6 @@
                     if (index < rows.length - 1) console.log('-'.repeat(80));
                 });
-                console.log();
-            }
-            if (next) next();
+            }
+            checkProduct();
         });
     });
@@ -180,12 +133,11 @@
 
 // Display PRODUCT table
-function checkProduct(next) {
+function checkProduct() {
     console.log('\n🛍️ PRODUCT TABLE:');
     console.log('================================================================================');
-
     tableExists('product', (exists) => {
         if (!exists) {
-            console.log('Table does not exist\n');
-            if (next) next();
+            console.log('Table does not exist');
+            checkCategory();
             return;
         }
@@ -197,11 +149,11 @@
         `, [], (err, rows) => {
             if (err) {
-                console.log(`Error: ${err.message}\n`);
-                if (next) next();
-                return;
-            }
-
-            if (!rows || rows.length === 0) {
-                console.log('No products found\n');
+                console.log(`Error: ${err.message}`);
+                checkCategory();
+                return;
+            }
+
+            if (!rows || rows.length === 0) {
+                console.log('No products found');
             } else {
                 console.log(`Total: ${rows.length} products\n`);
@@ -213,7 +165,6 @@
                     if (index < rows.length - 1) console.log('-'.repeat(80));
                 });
-                console.log();
-            }
-            if (next) next();
+            }
+            checkCategory();
         });
     });
@@ -221,12 +172,11 @@
 
 // Display CATEGORY table
-function checkCategory(next) {
+function checkCategory() {
     console.log('\n📁 CATEGORY TABLE:');
     console.log('================================================================================');
-
     tableExists('category', (exists) => {
         if (!exists) {
-            console.log('Table does not exist\n');
-            if (next) next();
+            console.log('Table does not exist');
+            checkWorksInStore();
             return;
         }
@@ -238,11 +188,11 @@
         `, [], (err, rows) => {
             if (err) {
-                console.log(`Error: ${err.message}\n`);
-                if (next) next();
-                return;
-            }
-
-            if (!rows || rows.length === 0) {
-                console.log('No categories found\n');
+                console.log(`Error: ${err.message}`);
+                checkWorksInStore();
+                return;
+            }
+
+            if (!rows || rows.length === 0) {
+                console.log('No categories found');
             } else {
                 console.log(`Total: ${rows.length} categories\n`);
@@ -253,7 +203,6 @@
                     if (index < rows.length - 1) console.log('-'.repeat(80));
                 });
-                console.log();
-            }
-            if (next) next();
+            }
+            checkWorksInStore();
         });
     });
@@ -261,12 +210,11 @@
 
 // Display WORKS_IN_STORE table
-function checkWorksInStore(next) {
+function checkWorksInStore() {
     console.log('\n🔗 WORKS_IN_STORE TABLE:');
     console.log('================================================================================');
-
     tableExists('works_in_store', (exists) => {
         if (!exists) {
-            console.log('Table does not exist\n');
-            if (next) next();
+            console.log('Table does not exist');
+            checkPermissions();
             return;
         }
@@ -279,11 +227,11 @@
         `, [], (err, rows) => {
             if (err) {
-                console.log(`Error: ${err.message}\n`);
-                if (next) next();
-                return;
-            }
-
-            if (!rows || rows.length === 0) {
-                console.log('No assignments found\n');
+                console.log(`Error: ${err.message}`);
+                checkPermissions();
+                return;
+            }
+
+            if (!rows || rows.length === 0) {
+                console.log('No assignments found');
             } else {
                 console.log(`Total: ${rows.length} assignments\n`);
@@ -293,7 +241,6 @@
                     if (index < rows.length - 1) console.log('-'.repeat(80));
                 });
-                console.log();
-            }
-            if (next) next();
+            }
+            checkPermissions();
         });
     });
@@ -301,12 +248,11 @@
 
 // Display PERMISSIONS table
-function checkPermissions(next) {
+function checkPermissions() {
     console.log('\n🔐 PERMISSIONS TABLE:');
     console.log('================================================================================');
-
     tableExists('permissions', (exists) => {
         if (!exists) {
-            console.log('Table does not exist\n');
-            if (next) next();
+            console.log('Table does not exist');
+            checkEmployees();
             return;
         }
@@ -318,11 +264,11 @@
         `, [], (err, rows) => {
             if (err) {
-                console.log(`Error: ${err.message}\n`);
-                if (next) next();
-                return;
-            }
-
-            if (!rows || rows.length === 0) {
-                console.log('No permissions found\n');
+                console.log(`Error: ${err.message}`);
+                checkEmployees();
+                return;
+            }
+
+            if (!rows || rows.length === 0) {
+                console.log('No permissions found');
             } else {
                 console.log(`Total: ${rows.length} permissions\n`);
@@ -332,7 +278,6 @@
                     if (index < rows.length - 1) console.log('-'.repeat(80));
                 });
-                console.log();
-            }
-            if (next) next();
+            }
+            checkEmployees();
         });
     });
@@ -340,12 +285,11 @@
 
 // Display EMPLOYEES table
-function checkEmployees(next) {
+function checkEmployees() {
     console.log('\n👷 EMPLOYEES TABLE:');
     console.log('================================================================================');
-
     tableExists('employees', (exists) => {
         if (!exists) {
-            console.log('Table does not exist\n');
-            if (next) next();
+            console.log('Table does not exist');
+            checkBoss();
             return;
         }
@@ -357,11 +301,11 @@
         `, [], (err, rows) => {
             if (err) {
-                console.log(`Error: ${err.message}\n`);
-                if (next) next();
-                return;
-            }
-
-            if (!rows || rows.length === 0) {
-                console.log('No employees found\n');
+                console.log(`Error: ${err.message}`);
+                checkBoss();
+                return;
+            }
+
+            if (!rows || rows.length === 0) {
+                console.log('No employees found');
             } else {
                 console.log(`Total: ${rows.length} employees\n`);
@@ -371,7 +315,6 @@
                     if (index < rows.length - 1) console.log('-'.repeat(80));
                 });
-                console.log();
-            }
-            if (next) next();
+            }
+            checkBoss();
         });
     });
@@ -379,12 +322,11 @@
 
 // Display BOSS table
-function checkBoss(next) {
+function checkBoss() {
     console.log('\n👑 BOSS TABLE:');
     console.log('================================================================================');
-
     tableExists('boss', (exists) => {
         if (!exists) {
-            console.log('Table does not exist\n');
-            if (next) next();
+            console.log('Table does not exist');
+            checkOrder();
             return;
         }
@@ -396,11 +338,11 @@
         `, [], (err, rows) => {
             if (err) {
-                console.log(`Error: ${err.message}\n`);
-                if (next) next();
-                return;
-            }
-
-            if (!rows || rows.length === 0) {
-                console.log('No bosses found\n');
+                console.log(`Error: ${err.message}`);
+                checkOrder();
+                return;
+            }
+
+            if (!rows || rows.length === 0) {
+                console.log('No bosses found');
             } else {
                 console.log(`Total: ${rows.length} bosses\n`);
@@ -410,7 +352,6 @@
                     if (index < rows.length - 1) console.log('-'.repeat(80));
                 });
-                console.log();
-            }
-            if (next) next();
+            }
+            checkOrder();
         });
     });
@@ -418,12 +359,11 @@
 
 // Display ORDER table
-function checkOrder(next) {
+function checkOrder() {
     console.log('\n📦 ORDERS TABLE:');
     console.log('================================================================================');
-
     tableExists('order', (exists) => {
         if (!exists) {
-            console.log('Table does not exist\n');
-            if (next) next();
+            console.log('Table does not exist');
+            checkReport();
             return;
         }
@@ -436,11 +376,11 @@
         `, [], (err, rows) => {
             if (err) {
-                console.log(`Error: ${err.message}\n`);
-                if (next) next();
-                return;
-            }
-
-            if (!rows || rows.length === 0) {
-                console.log('No orders found\n');
+                console.log(`Error: ${err.message}`);
+                checkReport();
+                return;
+            }
+
+            if (!rows || rows.length === 0) {
+                console.log('No orders found');
             } else {
                 console.log(`Total: ${rows.length} orders\n`);
@@ -452,7 +392,6 @@
                     if (index < rows.length - 1) console.log('-'.repeat(80));
                 });
-                console.log();
-            }
-            if (next) next();
+            }
+            checkReport();
         });
     });
@@ -460,12 +399,11 @@
 
 // Display REPORT table
-function checkReport(next) {
+function checkReport() {
     console.log('\n📊 REPORTS TABLE:');
     console.log('================================================================================');
-
     tableExists('report', (exists) => {
         if (!exists) {
-            console.log('Table does not exist\n');
-            if (next) next();
+            console.log('Table does not exist');
+            checkRefund();
             return;
         }
@@ -473,11 +411,11 @@
         db.all('SELECT * FROM report', [], (err, rows) => {
             if (err) {
-                console.log(`Error: ${err.message}\n`);
-                if (next) next();
-                return;
-            }
-
-            if (!rows || rows.length === 0) {
-                console.log('No reports found\n');
+                console.log(`Error: ${err.message}`);
+                checkRefund();
+                return;
+            }
+
+            if (!rows || rows.length === 0) {
+                console.log('No reports found');
             } else {
                 console.log(`Total: ${rows.length} reports\n`);
@@ -487,7 +425,6 @@
                     if (index < rows.length - 1) console.log('-'.repeat(80));
                 });
-                console.log();
-            }
-            if (next) next();
+            }
+            checkRefund();
         });
     });
@@ -495,12 +432,11 @@
 
 // Display REFUND table
-function checkRefund(next) {
+function checkRefund() {
     console.log('\n💰 REFUND TABLE:');
     console.log('================================================================================');
-
     tableExists('refund', (exists) => {
         if (!exists) {
-            console.log('Table does not exist\n');
-            if (next) next();
+            console.log('Table does not exist');
+            checkImage();
             return;
         }
@@ -508,11 +444,11 @@
         db.all('SELECT * FROM refund', [], (err, rows) => {
             if (err) {
-                console.log(`Error: ${err.message}\n`);
-                if (next) next();
-                return;
-            }
-
-            if (!rows || rows.length === 0) {
-                console.log('No refunds found\n');
+                console.log(`Error: ${err.message}`);
+                checkImage();
+                return;
+            }
+
+            if (!rows || rows.length === 0) {
+                console.log('No refunds found');
             } else {
                 console.log(`Total: ${rows.length} refunds\n`);
@@ -523,7 +459,6 @@
                     if (index < rows.length - 1) console.log('-'.repeat(80));
                 });
-                console.log();
-            }
-            if (next) next();
+            }
+            checkImage();
         });
     });
@@ -531,12 +466,11 @@
 
 // Display IMAGE table
-function checkImage(next) {
+function checkImage() {
     console.log('\n🖼️ IMAGE TABLE:');
     console.log('================================================================================');
-
     tableExists('image', (exists) => {
         if (!exists) {
-            console.log('Table does not exist\n');
-            if (next) next();
+            console.log('Table does not exist');
+            checkColor();
             return;
         }
@@ -544,11 +478,11 @@
         db.all('SELECT * FROM image', [], (err, rows) => {
             if (err) {
-                console.log(`Error: ${err.message}\n`);
-                if (next) next();
-                return;
-            }
-
-            if (!rows || rows.length === 0) {
-                console.log('No images found\n');
+                console.log(`Error: ${err.message}`);
+                checkColor();
+                return;
+            }
+
+            if (!rows || rows.length === 0) {
+                console.log('No images found');
             } else {
                 console.log(`Total: ${rows.length} images\n`);
@@ -557,7 +491,6 @@
                     if (index < rows.length - 1) console.log('-'.repeat(80));
                 });
-                console.log();
-            }
-            if (next) next();
+            }
+            checkColor();
         });
     });
@@ -565,12 +498,11 @@
 
 // Display COLOR table
-function checkColor(next) {
+function checkColor() {
     console.log('\n🎨 COLOR TABLE:');
     console.log('================================================================================');
-
     tableExists('color', (exists) => {
         if (!exists) {
-            console.log('Table does not exist\n');
-            if (next) next();
+            console.log('Table does not exist');
+            finish();
             return;
         }
@@ -578,11 +510,11 @@
         db.all('SELECT * FROM color', [], (err, rows) => {
             if (err) {
-                console.log(`Error: ${err.message}\n`);
-                if (next) next();
-                return;
-            }
-
-            if (!rows || rows.length === 0) {
-                console.log('No colors found\n');
+                console.log(`Error: ${err.message}`);
+                finish();
+                return;
+            }
+
+            if (!rows || rows.length === 0) {
+                console.log('No colors found');
             } else {
                 console.log(`Total: ${rows.length} colors\n`);
@@ -591,24 +523,23 @@
                     if (index < rows.length - 1) console.log('-'.repeat(80));
                 });
-                console.log();
-            }
-            if (next) next();
-        });
-    });
-}
-
-// Finish and close database
+            }
+            finish();
+        });
+    });
+}
+
+// Start the chain of checks
+function checkNext() {
+    checkPersonal();
+}
+
 function finish() {
-    console.log('='.repeat(80));
+    console.log('\n' + '='.repeat(80));
     console.log('✅ Database inspection complete');
     console.log('='.repeat(80) + '\n');
 
-    db.close((err) => {
-        if (err) {
-            console.error('Error closing database:', err.message);
-        }
-    });
-}
-
-// Start the execution chain
-executeChecks();
+    db.close();
+}
+
+// Start with CLIENTS
+checkNext();
