A full-stack React + Vite frontend and Express + MongoDB backend for Jalops Electrical Services.
- Node.js 20+
- MongoDB local instance or MongoDB Atlas database
- npm
cd server
npm install
copy .env.example .envOn macOS/Linux use cp .env.example .env. Edit server/.env:
MONGODB_URI: your MongoDB connection stringJWT_SECRET: a long random secretADMIN_NAME,ADMIN_EMAIL,ADMIN_PASSWORD: initial administrator credentialsCLIENT_ORIGIN: normallyhttp://localhost:5173
Create the initial admin account:
npm run seed:adminThe seed command creates the admin if it does not already exist. Change the initial password before a public launch.
Start the API:
npm run devAPI health check: http://localhost:5000/api/health
Open a second terminal:
cd client
npm install
copy .env.example .env
npm run devOpen http://localhost:5173.
/Home/aboutAbout/servicesServices/productsProduct catalogue/quoteRequest a quote/contactContact/admin/loginAdmin login/adminProtected dashboard
Sign in using the values configured in server/.env. From the dashboard you can create, edit and delete catalogue products, review contact enquiries and quotation requests, and update enquiry statuses.
POST /api/enquiriescontact formGET /api/enquiriesadmin listPATCH /api/enquiries/:id/statusadmin status updatePOST /api/quotesquotation formGET /api/quotesadmin listPATCH /api/quotes/:id/statusadmin status updateGET /api/productspublic catalogueGET /api/products/:idpublic product detailPOST /api/productsadmin createPUT /api/products/:idadmin updateDELETE /api/products/:idadmin deletePOST /api/auth/loginadmin loginGET /api/auth/mecurrent adminGET /api/dashboardadmin summary
Service and product categories are presented as proposed catalogue content and should be confirmed by management before publication. Product entries are clearly labelled as catalogue examples; no price or stock claims are made. Replace editable company profile copy with owner-approved details. No registration numbers, certifications, years of experience, warranties or testimonials are fabricated.
- Deploy the Express server to a Node hosting provider and provision MongoDB Atlas.
- Set production environment variables (
NODE_ENV=production,MONGODB_URI,JWT_SECRET,ADMIN_*,CLIENT_ORIGIN). - Deploy the
clientfolder as a static Vite site. SetVITE_API_URLto the deployed API base URL, e.g.https://api.example.com/api. - Configure the frontend host's SPA rewrite so unknown paths serve
index.html. - Use HTTPS, restrict
CLIENT_ORIGINto the exact production frontend origin, use a strong admin password, and rotate secrets. - Review service/product content with the business owner before publishing.
- Contact and quote submissions are validated on both client and server and persisted in MongoDB.
- Admin access uses bcrypt password hashing and JWT authentication. Tokens are stored in session storage and sent in the Authorization header.
- The frontend uses text-based product image URLs for simple catalogue maintenance. Use image URLs from assets you own or are licensed to use.