WATEERDROP is a smart water delivery application with:
- Frontend: React (Vite or CRA) β
http://localhost:3000 - Backend: Node.js + Express β
http://localhost:8080 - Database: MongoDB Atlas
- Browse products (2L, 5L, 10L, 20L, 30L bottles)
- Add to cart & checkout
- View orders
- Admins can manage products, orders, and view dashboard stats
WATEERDROP/
βββ backend/
β βββ server.js
β βββ routes/
β βββ models/
β βββ controllers/
βββ frontend/
β βββ src/
β β βββ pages/
β β βββ components/
β β βββ App.js
β βββ package.json
βββ README.md
- Created React frontend and Express backend.
- Connected backend to MongoDB Atlas.
- Set up routes for products, orders, and users.
Issue:
Module not found: Error: Can't resolve './pages/AdminDashboard'
Fix:
Created src/pages/AdminDashboard.jsx with quick links to admin sections.
- Added
/admin/statsbackend route returning:- Total orders
- Pending orders
- Delivered orders
- Total products
- Low stock count
- Total users
- Updated
AdminDashboard.jsxto fetch and display stats.
Warning:
React Hook useEffect has a missing dependency: 'fetchOrders'
Fix:
Wrapped fetchOrders in useCallback and added it to dependency array.
API Response:
{
"total": 5,
"page": 1,
"totalPages": 1,
"products": [
{ "name": "Water Bottle", "sizeLiters": 2, "price": 20, "stock": 100 }
]
}Fix:
Updated frontend to use p.sizeLiters instead of missing fields.
Error:
Access to XMLHttpRequest at 'http://localhost:8080/products' from origin 'http://localhost:3000' has been blocked by CORS policy
Cause:
Backend not sending Access-Control-Allow-Origin header.
Fix:
import cors from 'cors';
app.use(cors({
origin: 'http://localhost:3000',
credentials: true
}));Options:
- Development: Use
"proxy": "http://localhost:8080"in frontendpackage.json. - Production: Serve React build from Express backend.
- Created
ParallaxSectioncomponent. - Built
Home.jsxwith parallax sections, feature bands, and CTAs.
flowchart TD
A[User in Browser] -->|Clicks Products| B[React Frontend]
B -->|Axios GET /products| C[Express Backend]
C -->|Query| D[MongoDB Atlas]
D -->|Data| C
C -->|JSON Response + CORS Headers| B
B -->|Render Products| A
| Symptom | Likely Cause | Fix |
|---|---|---|
Module not found |
Missing file/component | Create file or fix import path |
React Hook missing dependency |
Function used in useEffect not in deps |
Wrap in useCallback or inline |
Failed to load products |
Field mismatch or undefined array | Match API keys, add safe checks |
| CORS error | Backend not allowing frontend origin | Enable CORS in backend |
| All pages failing | API calls blocked by browser | Fix CORS or use proxy |
graph LR
subgraph Frontend [React App β Port 3000]
UI[UI Components]
State[State Management]
end
subgraph Backend [Express API β Port 8080]
Routes[API Routes]
Controllers[Controllers]
Models[MongoDB Models]
end
subgraph Database [MongoDB Atlas]
Collections[Products, Orders, Users]
end
UI --> State
State --> Routes
Routes --> Controllers
Controllers --> Models
Models --> Collections
- Backend: Running on
8080, CORS fixed, API functional. - Frontend: Running on
3000, pages render correctly. - Admin Dashboard: Stats working.
- Products Page: Displays items from backend.
- Parallax Home Page: Built and styled.
- Deploy backend & frontend together.
- Secure admin routes with authentication.
- Add error boundaries for better UX.
- Apply consistent UI styling.
- Start backend before frontend in dev.
- Use
.envfor sensitive configs. - Update CORS config for deployed domain.