The system is now running with a persistent SQL database backend. All data is stored permanently in college_complaints.db.
| File | Size | Purpose |
|---|---|---|
index.html |
12K | Main UI - Student/Official dashboards and modals |
script.js |
30K | Main application logic (now uses API) |
styles.css |
12K | All styling for the application |
| File | Size | Purpose |
|---|---|---|
server.js |
15K | Express.js server with REST API endpoints |
api-client.js |
9.6K | Frontend API client for HTTP requests |
college_complaints.db |
56K | SQLite database file (persistent storage) |
package.json |
482B | Node.js dependencies configuration |
| File | Size | Purpose |
|---|---|---|
SQL_SETUP_GUIDE.md |
4.6K | Complete setup & usage guide |
MIGRATION_COMPLETE.md |
6.5K | Summary of changes from IndexedDB to SQL |
README.md |
This file | Project structure overview |
| File | Size | Purpose |
|---|---|---|
start-server.sh |
902B | Bash script to start server |
database.js |
15K | Old IndexedDB code (deprecated, not used) |
package-lock.json |
81K | npm dependency lock file |
node_modules/ |
~200MB | Installed npm packages |
# 1. Navigate to project
cd /Users/ntggamer1/Desktop/Project
# 2. Install dependencies (first time only)
npm install
# 3. Start the server
npm start
# 4. Open in browser
# file:///Users/ntggamer1/Desktop/Project/index.htmlServer runs on: http://localhost:3001
- id: student_username or official_username
- username: Unique login name
- password: User password (plain text - for demo only)
- name: Full name
- email: Email address
- type: 'student' or 'official'
- student_id: Student ID (optional)
- registered_date: Registration timestamp
- id: Unique complaint ID
- student_id: Student who filed complaint
- student_name: Student's name
- title: Complaint title
- category: Category (Gender, Academic, Maintenance, etc.)
- description: Detailed description
- status: Pending/Resolved/Student Confirmed/Student Rejected
- timestamp: When filed
- id: Unique message ID
- complaint_id: Related complaint
- sender_name: Who sent message
- sender_id: Sender's username
- sender_role: student or official
- text: Message content
- timestamp: When sent
┌─────────────────────────────────────────────────────────┐
│ BROWSER │
├─────────────────────────────────────────────────────────┤
│ index.html (UI) │
│ script.js (Application Logic) │
│ styles.css (Styling) │
│ api-client.js (API Calls) │
└────────────────────┬────────────────────────────────────┘
│ HTTP Requests/Responses
│ (REST API calls on port 3001)
↓
┌─────────────────────────────────────────────────────────┐
│ SERVER (Node.js) │
├─────────────────────────────────────────────────────────┤
│ server.js │
│ - Express.js web server │
│ - REST API route handlers │
│ - Request validation & processing │
└────────────────────┬────────────────────────────────────┘
│ SQL Queries
│
↓
┌─────────────────────────────────────────────────────────┐
│ DATABASE (SQLite) │
├─────────────────────────────────────────────────────────┤
│ college_complaints.db │
│ - Persistent file-based database │
│ - Three tables: users, complaints, chats │
│ - Indexed for fast queries │
└─────────────────────────────────────────────────────────┘
// Browser sends login request
fetch('http://localhost:3001/api/users/student/student1')
// Server queries database
SELECT * FROM users WHERE username = 'student1' AND type = 'student'
// Server returns user data to browser
{ id: 'student_student1', username: 'student1', name: 'Student One', ... }
// Browser updates UI
showStudentDashboard()// Browser sends complaint data
POST http://localhost:3001/api/complaints
{ id: 'c123', studentId: 'student1', title: '...', ... }
// Server inserts into database
INSERT INTO complaints (id, student_id, ...) VALUES (...)
// Data is permanently saved to college_complaints.db// All data is still in college_complaints.db ✅
// Server reads from database again
// User can login and see all previous dataUsername: student1
Password: 1234
Name: Student One
Username: student2
Password: 1234
Name: Student Two
Username: admin
Password: admin123
Name: Admin Official
| Feature | IndexedDB | SQL Database |
|---|---|---|
| Persistence | ✅ Permanent | |
| Data Backup | ❌ No | ✅ Single file |
| Multi-device | ❌ No | ✅ Via Server |
| Reliability | ✅ Standard SQL | |
| Performance | 📊 OK | 📊 Indexed Queries |
| Scalability | ✅ Unlimited | |
| Security | ✅ Server-side |
Total Project Size: ~450 KB
Code Files: ~100 KB
├─ server.js: 15 KB
├─ script.js: 30 KB
├─ api-client.js: 9.6 KB
├─ database.js: 15 KB (deprecated)
├─ index.html: 12 KB
└─ styles.css: 12 KB
Database: 56 KB
└─ college_complaints.db
Dependencies: ~200 MB
└─ node_modules/ (npm packages)
Documentation: ~11 KB
├─ SQL_SETUP_GUIDE.md: 4.6 KB
├─ MIGRATION_COMPLETE.md: 6.5 KB
└─ Other guides
✅ Persistent Storage - Data stays after browser closes
✅ SQL Database - Professional-grade storage
✅ REST API - Clean endpoints for all operations
✅ Same UI - User interface unchanged
✅ Demo Data - Pre-loaded with test accounts
✅ Indexed Queries - Fast lookups and searches
✅ Error Handling - Comprehensive error messages
✅ CORS Support - Frontend-backend communication
Frontend:
├─ HTML5
├─ CSS3
└─ JavaScript (ES6+)
Backend:
├─ Node.js (Runtime)
├─ Express.js (Web Framework)
└─ SQLite3 (Database)
Communication:
└─ REST API (HTTP)
1. Server starts on port 3001
2. SQLite database initializes
3. Creates 3 tables if they don't exist
4. Creates default user accounts
5. Creates database indexes
6. Waits for HTTP requests from browser
When user opens index.html:
7. JavaScript loads and initializes
8. API client connects to server
9. User can login/register
10. All operations save to database immediately
11. Data persists indefinitely
User Action: Submit Complaint
↓
JavaScript function: submitComplaint()
↓
API call: dbAPI.addComplaint()
↓
HTTP POST: /api/complaints
↓
Server receives JSON
↓
Express route handler
↓
SQLite INSERT query
↓
Data written to college_complaints.db
↓
Response sent to browser
↓
UI updated with success message
This project demonstrates:
- How to build a full-stack web application
- Backend API design with Express.js
- Frontend-backend communication
- SQL database usage (SQLite)
- CORS and REST principles
- Error handling and validation
- Single Page Application (SPA) patterns
- Add authentication - Hash passwords properly
- Add database validation - Prevent SQL injection
- Add user session management - Better security
- Add backup functionality - Export/import data
- Deploy to web - Use Heroku, Vercel, etc.
- Add more categories - Expand complaint types
- Add email notifications - Send updates to users
- Add analytics - Track complaint statistics
# Check if port 3001 is in use
lsof -i :3001
# Kill process if needed
kill -9 <PID># Make sure server is running
npm start
# Check browser console for errors
# Press F12 → Console tab# Make sure server is running
# Check file exists: college_complaints.db
ls -l college_complaints.db| Component | Status | Details |
|---|---|---|
| Backend Server | ✅ Running | http://localhost:3001 |
| Database | ✅ Created | college_complaints.db (56 KB) |
| API Endpoints | ✅ Working | All 20+ endpoints functional |
| Frontend | ✅ Ready | index.html ready to open |
| Demo Accounts | ✅ Available | student1, student2, admin |
For issues:
- Check
SQL_SETUP_GUIDE.mdfor detailed instructions - Check
MIGRATION_COMPLETE.mdfor architecture overview - Check browser console (F12) for error messages
- Check server terminal for API errors
- Verify port 3001 is not in use
Your SQL database system is ready to use! 🎉
Start server: npm start
Open app: file:///Users/ntggamer1/Desktop/Project/index.html