MERN e‑commerce starter with an optional Python AI microservice for price optimization, recommendations, and sentiment analysis. Fast local dev via Vite + Express, production friendly on Vercel (client) and Render (API + AI).
- Overview
- Features
- Architecture
- Quick Start
- Environment Variables
- Running Locally
- Deployment
- OAuth (Google & GitHub)
- Project Structure
- Contributing & Roadmap
PricePulse AI provides a modern scaffold to build a commerce app with:
- A Node/Express API with JWT auth and product/cart/order flows.
- A React+Vite client wired to the API via a dev proxy.
- A Python Flask AI service with endpoints for recommendations, pricing, and sentiment.
- Auth (register/login) with JWT and Passport strategies.
- Product CRUD with price recompute hooks and review endpoints.
- Cart, wishlist, checkout, order creation flow.
- AI service: recommendations, similar products, price prediction, sentiment.
- Clean UI with Redux Toolkit and responsive components.
- Client: client (React + Vite) → proxies
/apito backend during dev. - API: server (Express + MongoDB) → serves business logic on port 4000.
- AI: ai-service (Flask) → optional microservice on port 5000.
- Infra: render.yaml → Render deployment configuration.
# API (port 4000)
cd server
npm install
cp .env.example .env
npm run dev
# Client (port 5173)
cd ../client
npm install
npm run dev
# AI service (port 5000)
cd ../ai-service
python -m venv .venv && . .venv/Scripts/activate
pip install -r requirements.txt
python app.pyThe client dev server proxies /api to http://localhost:4000 (see client/vite.config.js). Health checks: API GET /api/health, AI GET /health.
Configure secrets via .env files. Templates should be committed; actual values should not.
-
API (server)
MONGO_URI— MongoDB connection stringJWT_SECRET— JWT signing secretCLIENT_ORIGIN— allowed origin(s), comma‑separated for local + VercelAI_SERVICE_URL— e.g.http://localhost:5000or deployed AI URLRAZORPAY_KEY_ID— Razorpay API key (get from Razorpay Dashboard)RAZORPAY_KEY_SECRET— Razorpay secret keyPORT— defaults to 4000- Optional OAuth/email keys as needed
-
Client (client)
VITE_API_URL— set on Vercel to your API base (e.g.https://your-api/api)
-
AI Service (ai-service)
AI_SERVICE_PORT— defaults to 5000 for localBACKEND_URL— optional, backend base URL if neededMODEL_PATH— defaults totrained_modelsENABLE_AUTO_TRAINING—true|falseLOG_LEVEL—INFO|DEBUG
- Start MongoDB (local or Atlas). Set
MONGO_URIaccordingly. - Launch API: server/app.js via
npm run dev. - Launch client: client via
npm run dev. - (Optional) Launch AI: ai-service/app.py via
python app.py.
Common dev scripts:
- API:
npm run dev(nodemon),npm start(production) - Client:
npm run dev,npm run build,npm run preview - AI service:
gunicorn --bind 0.0.0.0:$PORT app:appfor production (Render)
See DEPLOYMENT.md for the complete step-by-step deployment guide.
The project is configured for deployment on:
- Frontend: Vercel (React + Vite)
- Backend: Render (Node.js + Express)
- AI Service: Render (Python + Flask)
- Database: MongoDB Atlas
Before deployment, you'll need:
- MongoDB Atlas account and cluster setup
- Render account (for backend and AI services)
- Vercel account (for frontend)
- Strong JWT secrets (generate with:
node -e "console.log(require('crypto').randomBytes(32).toString('hex'))") - Email account with app password
- Optional: Razorpay, Google/GitHub OAuth credentials
The project includes deployment configuration files:
- vercel.json — Vercel configuration with SPA routing
- render.yaml — Render Blueprint for automated multi-service deployment
- .env.example files — Environment variable templates
-
Push to GitHub: Ensure your code is in a GitHub repository
-
Deploy via Render Blueprint:
- Go to Render Dashboard
- Click New + → Blueprint
- Connect your repository
- Render will detect
render.yamland create both services automatically - Configure environment variables marked with
sync: false
- Deploy Frontend to Vercel:
- Import your repository to Vercel
- Set Root Directory:
client - Add environment variable:
VITE_API_URL=https://your-backend.onrender.com/api - Deploy
- Update Environment Variables:
- In Render, update backend's
CLIENT_ORIGINwith your Vercel URL - Restart services if needed
If you prefer manual deployment:
Backend (Render):
# Service Configuration
Root Directory: server
Build Command: npm install
Start Command: npm start
# Environment Variables
PORT=4000
MONGO_URI=mongodb+srv://...
JWT_SECRET=your_secret_here
CLIENT_ORIGIN=https://your-app.vercel.app
AI_SERVICE_URL=https://your-ai.onrender.com
# ... see DEPLOYMENT.md for complete listAI Service (Render):
# Service Configuration
Root Directory: ai-service
Build Command: pip install -r requirements.txt
Start Command: gunicorn --bind 0.0.0.0:$PORT app:app
# Environment Variables
BACKEND_URL=https://your-backend.onrender.com
MODEL_PATH=trained_models
FLASK_ENV=productionFrontend (Vercel):
# Project Settings
Framework: Vite
Root Directory: client
Build Command: npm run build
Output Directory: dist
# Environment Variable
VITE_API_URL=https://your-backend.onrender.com/apiAfter deployment, verify your services:
- Backend:
https://your-backend.onrender.com/api/health - AI Service:
https://your-ai.onrender.com/health - Frontend:
https://your-app.vercel.app
- Seed Database (optional):
npm run seed # Add sample products
npm run seed:admin # Create admin user
npm run seed:superadmin # Create super admin- Configure OAuth Callbacks:
- Update Google/GitHub redirect URIs to production URLs
- Test Payment Flow:
- Verify Razorpay integration in test mode first
For detailed instructions, troubleshooting, and production checklist, see DEPLOYMENT.md.
Set provider credentials in the API .env:
GOOGLE_CLIENT_ID=...
GOOGLE_CLIENT_SECRET=...
GITHUB_CLIENT_ID=...
GITHUB_CLIENT_SECRET=...
SERVER_BASE_URL=http://localhost:4000
CLIENT_ORIGIN=http://localhost:5173
Callbacks must point to your API:
http://localhost:4000/api/auth/google/callbackhttp://localhost:4000/api/auth/github/callback
- Client app: client/src, entry client/src/main.jsx
- API entry: server/app.js, routes in server/routes
- Models: server/models
- Services: server/services, AI integration in server/services/aiService.js
- Python AI: ai-service/models, utilities ai-service/utils
- Contributing: open issues/PRs with clear descriptions; keep changes focused.
- Roadmap ideas:
- Integrate real price feeds and stronger ML models.
- Payments: Razorpay integration implemented for Credit Card, UPI, and Net Banking. Configure
RAZORPAY_KEY_IDandRAZORPAY_KEY_SECRETin the API.envto enable. COD orders process directly; online payments redirect to Razorpay checkout and verify signatures before creating orders.