This backend system provides complete customer account management, invoice generation, printing, and service request tracking for the cleaning services business.
- β Customer registration and login
- β Customer account management
- β Invoice generation and management
- β Invoice viewing and printing
- β Service request tracking
- β Payment tracking
- β Admin dashboard
- β JWT authentication
- β SQLite database
.
βββ server.js # Main backend server
βββ package.json # Dependencies
βββ .env.example # Environment variables template
βββ public/
β βββ login.html # Customer login page
β βββ register.html # Customer registration page
β βββ customer-dashboard.html # Customer portal
β βββ admin-dashboard.html # Admin portal
βββ cleaning_service.db # SQLite database (created on first run)
βββ README.md # This file
- Node.js (v14 or higher)
- npm
-
Navigate to project directory
cd "path/to/industrial and domestic cleaning solutions"
-
Install dependencies
npm install
-
Create environment file
cp .env.example .env
-
Edit .env file (optional - defaults work for development)
PORT=5000 JWT_SECRET=your-super-secret-jwt-key-change-in-production NODE_ENV=development -
Start the server
npm start
For development with auto-reload:
npm run dev
-
Access the application
- Main Website:
http://localhost:5000/ - Customer Login:
http://localhost:5000/login.html - Customer Registration:
http://localhost:5000/register.html - Customer Dashboard:
http://localhost:5000/customer-dashboard.html - Admin Dashboard:
http://localhost:5000/admin-dashboard.html
- Main Website:
id- Unique identifieremail- Unique email address (login)password- Hashed passwordcompany_name- Business namefirst_name,last_name- Contact infophone,address,city,state,zip- Address informationcreated_at,updated_at- Timestamps
id- Unique identifiercustomer_id- Reference to customerinvoice_number- Unique invoice numberdescription- Service descriptionamount- Total invoice amountstatus- pending, paid, or overduedue_date- Payment due dateissue_date- When invoice was created
id- Unique identifierinvoice_id- Reference to invoicedescription- Item descriptionquantity- Quantity of service/productunit_price- Price per unittotal- Total for this line item
id- Unique identifiercustomer_id- Reference to customerservice_type- Type of service requesteddescription- Service detailsstatus- pending, scheduled, completed, cancelledrequested_date- When customer wants servicecompleted_date- When service was completed
id- Unique identifierinvoice_id- Reference to invoiceamount- Payment amountpayment_method- credit_card, bank_transfer, cash, checkpayment_date- When payment was madetransaction_id- Payment processor transaction ID
POST /api/auth/register- Create new customer accountPOST /api/auth/login- Login to account
GET /api/customer/profile- Get current customer profilePUT /api/customer/profile- Update customer profile
GET /api/invoices- Get all invoices for customerGET /api/invoices/:invoiceId- Get invoice detailsPUT /api/invoices/:invoiceId/status- Update invoice status
GET /api/service-history- Get service historyPOST /api/service-request- Request new service
POST /api/payments- Record paymentGET /api/payments/:invoiceId- Get payments for invoice
GET /api/admin/customers- Get all customersGET /api/admin/customer/:customerId/invoices- Get customer invoicesGET /api/admin/dashboard- Get dashboard statisticsPOST /api/invoices- Create invoice (admin)
To test the system:
- Email:
demo@example.com - Password:
demo123
(These will be created when you first create an account via registration)
- Dashboard - View summary of all invoices and account status
- Invoices - View all invoices, amounts, and payment status
- Service History - Track all past service requests
- Request Service - Submit new service requests with preferred dates
- My Profile - Update contact information and address
- View detailed invoices with itemized services
- See payment status at a glance
- Print invoices for records
- Download invoices as PDF (feature can be added with jsPDF library)
- View all customers and their details
- Create invoices for customers
- Track total revenue (paid vs pending)
- Monitor service requests
- Change JWT_SECRET in .env file to a strong random string
- Use HTTPS instead of HTTP
- Add password reset functionality
- Implement role-based access control (RBAC)
- Add input validation and sanitization
- Implement rate limiting
- Use environment variables for sensitive data
- Add admin authentication (currently open)
- Consider using bcryptjs with higher salt rounds
- Add CSRF protection
To integrate Stripe or PayPal:
const stripe = require('stripe')('stripe-key');
app.post('/api/payments/charge', async (req, res) => {
const charge = await stripe.charges.create({
amount: req.body.amount * 100,
currency: 'usd',
source: req.body.token
});
// Record payment in database
});npm install nodemailernpm install pdfkitnpm install multerServer won't start:
- Check if port 5000 is already in use
- Verify Node.js is installed:
node --version
Database errors:
- Delete
cleaning_service.dbto reset the database - Run the server again to initialize fresh database
Login not working:
- Make sure server is running
- Check browser console for errors (F12)
- Verify email and password are correct
CORS errors:
- The backend has CORS enabled for all origins by default
- For production, specify allowed origins in
cors()call
For issues or questions, contact the development team or check the server logs for detailed error messages.
All rights reserved - Industrial & Domestic Cleaning Solutions