A modern full-stack e-commerce application built with Next.js 15, featuring user authentication, product management, and a responsive design.
- Landing Page: Attractive hero section with navigation and product highlights
- Authentication: Secure login/signup with NextAuth.js (supports Google OAuth and credentials)
- Product Catalog: Browse and search products with detailed views
- Protected Dashboard: Add and manage products (authentication required)
- Responsive Design: Mobile-first approach with Tailwind CSS
- Database: SQLite with Prisma ORM for data management
- Theme Toggle: Light/dark mode support (optional enhancement)
- Framework: Next.js 15 (App Router)
- Authentication: NextAuth.js
- Database: SQLite with Prisma ORM
- Styling: Tailwind CSS
- UI Components: Lucide React icons
- Notifications: React Hot Toast
- TypeScript: Full type safety
my-product-app/
βββ app/
β βββ api/
β β βββ auth/[...nextauth]/
β β βββ products/
β β βββ register/
β βββ dashboard/
β β βββ add-product/
β β βββ layout.tsx
β βββ login/
β βββ products/
β β βββ [id]/
β βββ globals.css
β βββ layout.tsx
β βββ page.tsx
β βββ providers.tsx
βββ components/
β βββ Footer.tsx
β βββ Navbar.tsx
β βββ ProductCard.tsx
β βββ ThemeToggle.tsx
βββ lib/
β βββ auth.ts
β βββ prisma.ts
βββ prisma/
β βββ schema.prisma
βββ scripts/
βββ setup-db.js
- Node.js 18+
- npm or yarn
git clone <your-repo-url>
cd my-product-appnpm installCreate a .env.local file in the root directory:
# Database
DATABASE_URL="file:./dev.db"
# NextAuth Configuration
NEXTAUTH_URL="http://localhost:3000"
NEXTAUTH_SECRET="your-secret-key-here"
# Google OAuth (Optional)
GOOGLE_CLIENT_ID="your-google-client-id"
GOOGLE_CLIENT_SECRET="your-google-client-secret"# Generate Prisma client and setup database with sample data
npm run db:setupnpm run devVisit http://localhost:3000 to see the application.
-
Push to GitHub: Make sure your code is pushed to a GitHub repository.
-
Connect to Vercel:
- Go to vercel.com
- Import your GitHub repository
- Configure environment variables in Vercel dashboard
-
Environment Variables: Add the following to your Vercel environment variables:
DATABASE_URL=file:./dev.db NEXTAUTH_URL=https://your-app-name.vercel.app NEXTAUTH_SECRET=your-production-secret GOOGLE_CLIENT_ID=your-google-client-id GOOGLE_CLIENT_SECRET=your-google-client-secret -
Deploy: Vercel will automatically deploy your app.
- Netlify: Similar process to Vercel
- Railway: Good for full-stack apps with databases
- Heroku: Traditional platform-as-a-service option
| Route | Method | Description | Protected |
|---|---|---|---|
/api/auth/[...nextauth] |
GET/POST | Authentication endpoints | No |
/api/products |
GET | Fetch all products | No |
/api/products |
POST | Create new product | Yes |
/api/products/[id] |
GET | Fetch single product | No |
/api/register |
POST | User registration | No |
| Route | Access Level | Redirect |
|---|---|---|
/ |
Public | - |
/login |
Public | - |
/products |
Public | - |
/products/[id] |
Public | - |
/dashboard/* |
Protected | /login |
- Update the Prisma schema in
prisma/schema.prisma - Run
npx prisma db pushto update database - Update the API routes and forms accordingly
- Modify
app/globals.cssfor global styles - Use Tailwind CSS classes for component styling
- Customize the color scheme in
tailwind.config.js
Add more providers in lib/auth.ts:
providers: [
// Add more providers like GitHub, Twitter, etc.
GitHubProvider({
clientId: process.env.GITHUB_ID!,
clientSecret: process.env.GITHUB_SECRET!,
}),
]Run the application locally and test:
- Landing Page: Navigate to
/ - Authentication: Test login/signup flows
- Product Browsing: View products and individual product pages
- Protected Routes: Try accessing
/dashboardwithout login - Product Management: Add new products via dashboard
- The app uses SQLite for development (easily replaceable with PostgreSQL/MySQL for production)
- NextAuth.js handles session management automatically
- All forms include loading states and error handling
- The app is fully responsive and works on mobile devices
- Fork the repository
- Create a feature branch:
git checkout -b feature/new-feature - Commit changes:
git commit -m 'Add new feature' - Push to branch:
git push origin feature/new-feature - Submit a pull request
This project is open source and available under the MIT License.
Database Connection Error
- Ensure DATABASE_URL is correctly set in
.env.local - Run
npm run db:setupto initialize the database
Authentication Not Working
- Check NEXTAUTH_URL matches your domain
- Verify NEXTAUTH_SECRET is set
- For Google OAuth, ensure redirect URIs are configured
Build Errors
- Clear
.nextfolder:rm -rf .next - Reinstall dependencies:
rm -rf node_modules && npm install - Check for TypeScript errors:
npm run lint
If you encounter any issues or have questions, please create an issue in the GitHub repository.
Happy coding! π