complaint-system/
│
├── frontend/
│ ├── index.html ← Main webpage (complaint form)
│ ├── style.css ← Styling
│ └── script.js ← Form logic + API calls
│
├── backend/
│ ├── server.js ← Express server + MySQL connection
│ └── package.json ← Node.js dependencies
│
└── database/
└── setup.sql ← SQL to create DB and table
| Tool | Download Link |
|---|---|
| Node.js (v18+) | https://nodejs.org |
| MySQL Server | https://dev.mysql.com/downloads/mysql/ |
| MySQL Workbench (optional) | https://dev.mysql.com/downloads/workbench/ |
Option A: Using MySQL Workbench
- Open MySQL Workbench
- Click the
+to open a new SQL tab - Open and run the file:
database/setup.sql - You should see the
complaint_dbdatabase created ✅
Option B: Using Terminal/Command Prompt
mysql -u root -p
# Enter your MySQL password when prompted
# Then paste and run:
source /path/to/complaint-system/database/setup.sqlOpen backend/server.js and update these lines:
const db = mysql.createConnection({
host: 'localhost',
user: 'root', // ← your MySQL username
password: 'your_password', // ← your MySQL password (change this!)
database: 'complaint_db'
});Open a terminal and navigate to the backend folder:
cd complaint-system/backend
npm installThis installs: express, mysql2, cors, nodemon
# Inside complaint-system/backend/
node server.jsYou should see:
✅ Connected to MySQL database: complaint_db
🚀 Server running at http://localhost:3000
Keep this terminal window open while using the app.
Simply open frontend/index.html in your browser:
- Double-click the file, OR
- Right-click → Open with → Chrome / Firefox
⚠️ Make sure the backend server is running before submitting a form!
- Open
frontend/index.htmlin browser - Fill in the complaint form
- Click Submit Complaint
- You should see a green success message
- Verify in MySQL:
SELECT * FROM complaints;
- Open Tableau Desktop
- Click Connect → To a Server → MySQL
- Enter:
- Server:
localhost - Port:
3306 - Database:
complaint_db - Username:
root - Password: your password
- Server:
- Select the
complaintstable - Start building your dashboard! 🎉
| Method | Endpoint | Description |
|---|---|---|
| POST | http://localhost:3000/add-complaint |
Submit a new complaint |
| GET | http://localhost:3000/complaints |
View all complaints (bonus) |
{
"customer_name": "Ravi Kumar",
"complaint_type": "Credit Card",
"description": "Unauthorized transaction...",
"date": "2025-04-15",
"status": "Pending"
}{
"message": "Complaint submitted successfully!",
"id": 6
}| Problem | Fix |
|---|---|
Cannot connect to server |
Make sure node server.js is running |
MySQL connection failed |
Check username/password in server.js |
Access denied for user 'root' |
Run MySQL as admin or use correct credentials |
| Form submits but nothing saved | Check browser console (F12) for errors |
-- All data
SELECT * FROM complaints;
-- Complaints by month and year (Trend chart)
SELECT YEAR(date) AS Year, MONTH(date) AS Month,
complaint_type, COUNT(*) AS Total
FROM complaints
GROUP BY Year, Month, complaint_type
ORDER BY Year, Month;
-- Status breakdown
SELECT complaint_type, status, COUNT(*) AS Count
FROM complaints
GROUP BY complaint_type, status;