Production-style e-commerce platform implementing your requested architecture, adapted to PostgreSQL (instead of MongoDB).
- Public storefront: home, listing, product details, search/filter/sort, guest cart, live cart count.
- Guest checkout: no login required, collects full name/email/phone/address/payment method, stores order with
isGuest: trueand email reference. - Authenticated checkout: links order to
userIdwithisGuest: false. - JWT auth with Bearer token sent in
Authorizationheader. - Password hashing with bcrypt.
- Role-based admin routes (
user,admin). - Guest cart in localStorage, user cart in DB (
Cart,CartItem) with merge on login. - Wishlist, profile update, saved shipping addresses.
- Order status workflow: pending, paid, shipped, delivered, cancelled.
- Stock validation + stock decrement on purchase.
- Action logs and admin reports/log pages.
- Security middleware currently enabled: CORS and centralized error handling.
- Stripe payment intent endpoint.
- Backend tests for health, auth middleware behavior, protected routes.
backend/src/controllersbackend/src/routesbackend/src/middlewarebackend/src/utilsbackend/src/configbackend/src/server.js
frontend/src/componentsfrontend/src/pagesfrontend/src/features(Redux)frontend/src/api/client.jsfrontend/src/components/ProtectedRoute.jsx
UserProductOrderReviewCart- plus:
OrderItem,CartItem,Wishlist,ActionLog
- Install dependencies:
cd mern-ecommerce/backend && npm install
cd ../frontend && npm install- Create env files:
cd ../backend
cp .env.example .env
cd ../frontend
cp .env.example .env- Ensure PostgreSQL DB exists:
CREATE DATABASE mern_ecommerce;- Apply schema + seed data:
cd ../backend
npm run prisma:generate
npm run prisma:push
npm run seed- Run backend:
npm run dev- Run frontend:
cd ../frontend
npm run dev- Open app:
http://localhost:5173http://localhost:5000/api/health
- Admin:
admin@mernstore.dev/Admin123! - User:
user@mernstore.dev/User123!
cd backend
npm testcd frontend
npm test -- --watch=falsecd mern-ecommerce
npm install- Pre-commit hook runs
lint-staged(ESLint + Prettier on staged files). - Manual checks:
npm run lintnpm run lint:fixnpm run format:checknpm run format
- Frontend: Vercel (
frontend/) - Backend: Render/Railway (
backend/) - Set env vars from
backend/.env.example - Use managed PostgreSQL connection string for
DATABASE_URL
- Requirement requested MERN; implementation uses PostgreSQL by your instruction.
- For full production payments, add Stripe webhook verification for payment finalization.
- In-process automation queue + scheduler starts with backend server startup.
- Jobs implemented:
abandoned-cart-recoverylow-stock-alertsweekly-kpi-digest
- Admin endpoints:
GET /api/admin/automation/summaryPOST /api/admin/automation/runwith{ "jobName": "abandoned-cart-recovery", "mode": "queue" }
- Admin UI:
/admin/automation