A complete, production-ready full-stack e-commerce platform with TypeScript/Node.js backend and React TypeScript frontend. Features authentication, product management, shopping cart, order processing, and Stripe payment integration.
Frontend: React + TypeScript + Tailwind CSS (client/)
Backend: Node.js + Express + MongoDB + TypeScript (server/)
Inspired by Roadmap.sh
E-Commerce API Solutions/
├── client/ # React TypeScript Frontend
│ ├── public/ # Static files
│ ├── src/
│ │ ├── api/ # API layer (Axios)
│ │ ├── components/ # Reusable React components
│ │ ├── contexts/ # React Context providers
│ │ ├── hooks/ # Custom React hooks
│ │ ├── pages/ # Page components
│ │ ├── routes/ # Routing configuration
│ │ └── tests/ # Unit tests
│ ├── package.json
│ └── README.md # Frontend documentation
│
├── server/ # Node.js TypeScript Backend
│ ├── src/
│ │ ├── config/ # DB connection
│ │ ├── controller/ # Route handlers
│ │ ├── middleware/ # Auth middleware
│ │ ├── models/ # Mongoose models
│ │ ├── routes/ # Express routers
│ │ └── utils/ # Helpers (JWT)
│ ├── dist/ # Compiled JavaScript
│ └── package.json
│
└── README.md # This file
- Node.js 18+ (LTS recommended) - Download
- npm 7+ (comes with Node.js)
- MongoDB - Local or MongoDB Atlas
- Stripe Account - For payment processing (test mode)
# Navigate to server directory
cd server
# Install dependencies
npm install
# Create .env file
# Add: PORT=5000, MONGO_URI, JWT_SECRET, STRIPE_SECRET_KEY
# Start development server
npm run devBackend will run on http://localhost:5000
# Navigate to client directory (from root)
cd client
# Install dependencies
npm install
# Create .env file
# Add: REACT_APP_API_BASE_URL=http://localhost:5000/api
# REACT_APP_STRIPE_PUBLISHABLE_KEY=your_key
# Start development server
npm startFrontend will open at http://localhost:3000
- Frontend: http://localhost:3000
- Backend API: http://localhost:5000/api
- Register a new user or use admin credentials (if seeded)
- Frontend Documentation: See
client/README.mdfor complete frontend setup, features, and deployment - Backend Documentation: Continue reading below for backend API details
cd server
npm installCreate server/.env with values for your environment:
PORT=5000
MONGO_URI=mongodb://localhost:27017/ecommerce
JWT_SECRET=your_jwt_secret_here
STRIPE_SECRET_KEY=sk_test_your_stripe_secret_key_here
NODE_ENV=developmentDevelopment (auto‑rebuild and restart):
cd server
npm run devProduction build and start:
cd server
npm run build
npm startnpm run dev— Watchessrc/, rebuilds TypeScript, restarts servernpm run build— Compiles TypeScript todist/npm start— Runs compiled app fromdist/index.js
- Local default:
http://localhost:5000
Base URL: http://localhost:5000/api
POST /api/auth/register- Register new userPOST /api/auth/login- Login userGET /api/auth/profile- Get user profile (protected)PUT /api/auth/profile- Update profile (protected)
GET /api/products- Get all products (with filters)GET /api/products/:id- Get single productPOST /api/products- Create product (admin only)PUT /api/products/:id- Update product (admin only)DELETE /api/products/:id- Delete product (admin only)GET /api/products/categories- Get categories
GET /api/cart- Get user cart (protected)POST /api/cart- Add item to cart (protected)PUT /api/cart/:itemId- Update cart item (protected)DELETE /api/cart/:itemId- Remove from cart (protected)DELETE /api/cart/clear- Clear cart (protected)POST /api/cart/sync- Sync local cart (protected)
POST /api/orders- Create order (protected)GET /api/orders- Get user orders (protected)GET /api/orders/:id- Get order details (protected)PUT /api/orders/:id/status- Update status (admin only)
POST /api/payments/create-intent- Create payment intent (protected)PUT /api/payments/:id/status- Update payment status (protected)GET /api/payments- Get payment history (protected)
For detailed API documentation, see route files in server/src/routes/*
ESLint and Prettier are installed. Run from server/ (add scripts as desired) or use your editor integrations.
PORT— Port to run the serverMONGO_URI— MongoDB connection stringJWT_SECRET— Secret for JWT signingSTRIPE_SECRET_KEY— Stripe secret key (if payments used)NODE_ENV—developmentorproduction
- Build with
npm run buildfromserver/ - Deploy
server/dist/to platforms like Heroku, Railway, or AWS - Set environment variables on your hosting platform
- Ensure MongoDB is accessible (use MongoDB Atlas for cloud)
- Build with
npm run buildfromclient/ - Deploy to Netlify, Vercel, or AWS S3 + CloudFront
- Set
REACT_APP_API_BASE_URLto your production backend URL - Set
REACT_APP_STRIPE_PUBLISHABLE_KEY(use live key for production)
Security Notes:
- Never commit
.envfiles or secrets to Git - Use different Stripe keys for development (test) and production (live)
- Enable HTTPS for both frontend and backend in production
- Configure CORS properly in backend for your frontend domain
cd server
npm testcd client
npm testRun with coverage:
npm test -- --coverage --watchAll=false- React 18.2.0
- TypeScript 4.9.5
- Tailwind CSS 3.3.6
- React Router DOM 6.20.1
- Axios 1.6.2
- Stripe (React Stripe.js)
- React Hook Form 7.48.2
- Node.js + Express
- TypeScript
- MongoDB + Mongoose
- JWT Authentication
- Stripe (Node.js SDK)
- Bcrypt for password hashing
✅ User authentication (register, login, JWT)
✅ Product browsing with filters and search
✅ Shopping cart (local storage + server sync)
✅ Stripe payment integration
✅ Order management and history
✅ Admin dashboard for product CRUD
✅ Protected routes (authentication + role-based)
✅ Responsive design (mobile-first)
✅ TypeScript for type safety
✅ Production-ready code (no placeholders)
See client/README.md for frontend-specific troubleshooting.
MongoDB Connection Failed:
- Check
MONGO_URIinserver/.env - Ensure MongoDB is running
- Check network/firewall settings
Port Already in Use:
# Change PORT in server/.env
PORT=5001JWT Authentication Errors:
- Verify
JWT_SECRETis set - Check token expiration settings
MIT License - See individual package.json files
- Fork the repository
- Create a feature branch
- Make your changes
- Write/update tests
- Submit a pull request
For issues or questions:
- Check documentation in
client/README.mdandserver/README.md - Review console logs (browser + server)
- Verify environment variables are set correctly
- Ensure all dependencies are installed
Built with ❤️ using React, TypeScript, Node.js, and MongoDB