A modern, full-stack e-commerce application built with Next.js 16 (App Router), Express.js, and NextAuth.js.
ShopHub is a feature-rich online shopping platform that allows users to browse products, view detailed information, and manage items through an intuitive interface. The application includes authentication, protected routes, and a complete CRUD API for product management.
-
Landing Page β
- 7 comprehensive sections (Hero, Features, Categories, Stats, Testimonials, Newsletter, CTA)
- Responsive design with Tailwind CSS and DaisyUI
- Navigation to all major pages
- Professional UI/UX
-
Authentication System β
- NextAuth.js integration for secure authentication
- Mock login with hardcoded credentials
- Session management with cookies
- Protected routes using middleware
- Login credentials:
admin@shophub.com/admin123
-
Items List Page β
- Publicly accessible
- Fetches data from Express.js API
- Displays product cards with:
- Product name
- Description
- Price
- Image
- Category
- Stock information
- Responsive grid layout
- Link to detailed view
-
Item Details Page β
- Publicly accessible
- Full product information display
- Large product image
- Detailed specifications
- Add to cart functionality (UI)
- Related product features
-
Protected Add Item Page β
- Only accessible when logged in
- Form to add new products
- Stores data via Express.js API
- Automatic redirect for unauthenticated users
- Form validation
-
Toast Notifications β
- Success/error messages using react-hot-toast
- Login feedback
- Product creation confirmation
-
Express.js Backend β
- RESTful API for product management
- CRUD operations (Create, Read, Update, Delete)
- Mock database with sample products
- CORS enabled for Next.js integration
-
Additional Pages β
- About page
- Contact page with form
- Professional footer
-
Frontend:
- Next.js 16 (App Router)
- React 19
- Tailwind CSS 4
- DaisyUI 5
- NextAuth.js (Authentication)
- React Hot Toast (Notifications)
-
Backend:
- Express.js
- Node.js
- MongoDB (Database)
- Mongoose (ODM)
- CORS
-
Other:
- Axios (HTTP client)
- js-cookie (Cookie management)
- Node.js (v18 or higher)
- npm or yarn
git clone <repository-url>
cd simple_applicationnpm installCreate a .env.local file in the root directory:
NEXTAUTH_URL=http://localhost:3000
NEXTAUTH_SECRET=your-secret-key-change-this-in-production
API_URL=http://localhost:5000
# MongoDB Configuration
MONGODB_URI=mongodb://localhost:27017/shophub
# Or use MongoDB Atlas:
# MONGODB_URI=mongodb+srv://userName:password@allunityit.looszdp.mongodb.net/?appName=AllUnityItOption 1: Local MongoDB
- Install MongoDB from: https://www.mongodb.com/try/download/community
- Start MongoDB service
Option 2: MongoDB Atlas (Cloud)
- Create free account at: https://www.mongodb.com/cloud/atlas
- Get connection string and update
.env.local
See MONGODB_QUICK_START.md for detailed instructions
npm run seedThis will populate your MongoDB with sample products.
npm run dev:allThis will start:
- Next.js dev server on
http://localhost:3000 - Express.js API server on
http://localhost:5000
Terminal 1 - Next.js:
npm run devTerminal 2 - Express.js:
npm run serverOpen your browser and navigate to:
- Frontend: http://localhost:3000
- API: http://localhost:5000/api/items
- Health Check: http://localhost:5000/api/health
| Route | Description |
|---|---|
/ |
Landing page with 7 sections |
/items |
List of all products |
/items/[id] |
Individual product details |
/about |
About page |
/contact |
Contact page with form |
/login |
Login page |
| Route | Description | Auth Required |
|---|---|---|
/items/add |
Add new product form | β Yes |
| Method | Endpoint | Description |
|---|---|---|
| GET | /api/items |
Get all items |
| GET | /api/items/:id |
Get single item |
| POST | /api/items |
Create new item |
| PUT | /api/items/:id |
Update item |
| DELETE | /api/items/:id |
Delete item |
For testing purposes, use these credentials:
- Email: admin@shophub.com
- Password: admin123
- User enters credentials on
/loginpage - NextAuth.js validates credentials
- Session is created and stored in cookies
- Protected routes check for valid session
- Unauthenticated users are redirected to login
- Hero: Eye-catching introduction with CTA
- Features: Key benefits (Fast Delivery, Quality, Security)
- Categories: Product category navigation
- Stats: Business metrics and achievements
- Testimonials: Customer reviews
- Newsletter: Email subscription form
- CTA: Final call-to-action for conversions
- Mock authentication using NextAuth.js
- Credentials stored securely in session cookies
- Middleware protects sensitive routes
- Automatic redirect on unauthorized access
- Browse: View all products in grid layout
- Details: Click any product for full information
- Add: Authenticated users can add new products
- API Integration: All data fetched from Express.js backend
- Real-time feedback for user actions
- Success messages for completed operations
- Error handling with user-friendly messages
The application uses:
- Tailwind CSS: Utility-first CSS framework
- DaisyUI: Component library for consistent design
- Responsive Design: Mobile-first approach
- Custom Components: Reusable UI elements
Deploy to Vercel:
vercel deployDeploy to:
- Heroku
- Railway
- DigitalOcean
- AWS EC2
Update .env.local with production API URL.
- Login with credentials
- Navigate to "Add Item" button
- Fill out the form
- Submit to add to database
Edit server/server.js to modify the initial product list.
To add Google OAuth:
- Configure Google Cloud Console
- Add GoogleProvider to NextAuth config
- Update environment variables
- Ensure Express.js server is running on port 5000
- Check console for API errors
- Verify CORS is enabled
- Clear browser cookies
- Check NEXTAUTH_SECRET is set
- Verify credentials match mock data
- Ensure image URLs are valid
- Check Next.js config for image domains
- Use Unsplash for free placeholder images
This project is open source and available under the MIT License.
Contributions are welcome! Please feel free to submit a Pull Request.
For questions or support, please contact: support@shophub.com
Built with β€οΈ using Next.js 16 and Express.js