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