This is a full-stack eCommerce website built using Node.js, Express, React, and PostgreSQL. The application allows users to browse products, add items to the cart, and complete purchases using Stripe for payments. The admin panel provides functionality to manage products, and users.
- Browse through products
- Add products to the cart and update quantities
- Secure checkout with Stripe payment integration
- User authentication with JWT (JSON Web Token)
- Manage products (Create, Update, Delete)
- Manage users (Promote to admin)
- Inventory management with stock checks
- Node.js & Express.js – API development
- PostgreSQL – Database storage
- Stripe API – Payment processing
- JWT Authentication – Secure user login
- React.js – User interface
- React Bootstrap – Styling
- Axios – API calls
Ensure you have the following installed:
- Node.js (>= 16.x)
- PostgreSQL
- Stripe API keys
- Stripe CLI (Used for triggering events to test webhook integration locally)
-
Clone the repository:
git clone https://github.com/jamesh21/E-CommerceApp.git cd E-CommerceApp
-
Install dependencies for front end:
cd E-Commerce-Frontend npm install
-
Install dependencies for back end:
cd E-Commerce-Backend npm install
-
Configure environment variables:
- Create a
.env
file in the E-Commerce-Frontend folder and add the following:
REACT_APP_API_URL=http://localhost:4000/api/v1 (set this on your backend port)
- Create a
.env
file in the E-Commerce-Backend folder and add the following:
PORT=4000 DB_USER=your-local-postgres-db-username DB_HOST=your-local-postgres-db-host DB_NAME=your-local-postgres-db-name DB_PASSWORD=your-local-postgres-pw DB_PORT=your-local-postgres-port JWT_SECRET=your-jwt-secret JWT_LIFETIME=your-jwt-lifetime STRIPE_SECRET_KEY=your-stripe-secret-key STRIPE_SUCCESS_URL=http://localhost:3000/success (set this on your frontend port, defaults to localhost:3000) STRIPE_CANCEL_URL=http://localhost:3000/cart (set this on your frontend port, defaults to localhost:3000)
- Create a
-
Start Postgres server locally
psql -h your-local-postgres-db-host -U your-local-postgres-db-username -d your-local-postgres-db-name
-
Run DB Script (An inital user must be created in the db with admin priviledge, since you will need to be an admin to update roles)
- Navigate to E-Commerce-Backend
- Run db.sql to generate postgres tables
-
Start Stripe CLI: (This is necessary for stripe to confirm payment has gone through, so our webhook can update order status and deduct product inventory)
- Login to Stripe, browser will open to ask for credentials.
- Have stripe forward events to your local node server.
stripe login stripe listen --forward-to localhost:4000/api/v1/checkout/webhook
-
Navigate to
E-Commerce-Backend
directory and Start the backend server:npm start
-
Navigate to the
E-Commerce-Frontend
directory and Start the frontend:npm start
POST /api/v1/auth/register
– Register new userPOST /api/v1/auth/login
– Login user
GET /api/v1/product
– Get all productsGET /api/v1/product/:id
– Get product detailsPOST /api/v1/product
– (Admin) Add new productPUT /api/v1/product/:id
– (Admin) Update productDELETE /api/v1/product/:id
– (Admin) Delete product
POST /api/v1/cart
– Add item to cartGET /api/v1/cart
– Get user's cartDELETE /api/v1/cart/:id
– Remove item from cart- 'PATCH api/v1/cart/:id` – Update quantity of cart item
DELETE /api/v1/cart/
– Remove all items from cart
POST /api/v1/orders
– Place an order
- Add search and filter options with elastic search.
- Add guest checkout
- Implement wishlist functionality
- Add product reviews and ratings
This project is licensed under the MIT License. Feel free to contribute or use it as a reference for your own eCommerce projects!
- James Ho – Developer
For any inquiries or contributions, feel free to reach out:
- GitHub: jamesh21
This project idea is from roadmap.sh