An e-commerce platform built with Next.js, MongoDB for data storage, and Stripe for secure payment processing. Users can browse products, add items to cart, and complete purchases with automatic user account creation at checkout.
- No Authentication Required: Session-based cart system using localStorage
- Automatic User Creation: User accounts created during Stripe checkout
- Secure Payments: Stripe integration with webhook support
- MongoDB Storage: Cart items, users, and orders stored in MongoDB
- Responsive Design: Built with Tailwind CSS
- Node.js 18+ installed
- MongoDB Atlas account (free tier available)
- Stripe account (test mode works fine)
-
Clone the repository
git clone <your-repo-url> cd tMust
-
Install dependencies
npm install
-
Set up environment variables
Copy
.env.exampleto.envand fill in your values:cp .env.example .env
Required variables:
# MongoDB MONGODB_URI=mongodb+srv://username:[email protected]/ecommerce # Stripe STRIPE_SECRET_KEY=sk_test_your_key NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY=pk_test_your_key STRIPE_WEBHOOK_SECRET=whsec_your_webhook_secret
-
Set up Stripe Webhook
For local development, use Stripe CLI:
stripe listen --forward-to localhost:3000/api/webhook
For production, add webhook endpoint in Stripe Dashboard:
- URL:
https://yourdomain.com/api/webhook - Event:
checkout.session.completed
- URL:
-
Run the development server
npm run dev
-
Open your browser
Navigate to http://localhost:3000
- Unique session ID generated per browser
- Stored in localStorage
- Cart persists across page reloads
- No sign-in required
- User adds products to cart
- Clicks "Proceed to Checkout"
- Redirected to Stripe Checkout page
- Stripe collects: email, name, phone, addresses
- After payment success:
- Webhook triggers user creation
- User data saved to MongoDB
- Order recorded
- Cart automatically cleared
- cart: Temporary cart items with session IDs
- users: Customer information (created at checkout)
- orders: Order history and details
Use Stripe test card for testing:
- Card Number:
4242 4242 4242 4242 - Expiry: Any future date
- CVC: Any 3 digits
- ZIP: Any 5 digits
This project was recently migrated from:
- ❌ Clerk Authentication → ✅ Session-based cart
- ❌ PostgreSQL/Drizzle → ✅ MongoDB
- ❌ Pre-checkout user creation → ✅ Checkout-time user creation
See MIGRATION_GUIDE.md for detailed migration notes.
- Framework: Next.js 15
- Database: MongoDB
- Payments: Stripe
- Styling: Tailwind CSS
- Language: TypeScript
- Push your code to GitHub
- Import project in Vercel
- Add environment variables
- Update Stripe webhook URL to production domain
- Deploy!
This project is open source and available under the MIT License.
Contributions, issues, and feature requests are welcome!