A full-stack Simple E-commerce Store built as Task 1 for the CodeAlpha Full Stack Development Internship.
The application provides a complete e-commerce workflow including product browsing, product details, authentication, shopping cart, checkout, order processing, and an administrative dashboard.
-
π Home page with featured products and categories
-
π¦ Product listing
-
π Product search
-
ποΈ Category filtering
-
π Product details with related products
-
π Shopping cart
- Add products
- Update quantities
- Remove products
- Automatic total calculation
-
π³ Checkout with shipping information
-
π€ User registration
-
π User login/logout
-
π¦ Order processing
-
π My Orders
-
π Customer order history
- JWT-based authentication
- Password hashing with
bcryptjs - Protected customer routes
- Protected admin routes
- Admin authorization middleware
- Environment variables for sensitive configuration
- Protected API endpoints
- π Admin dashboard
- π Product, order, and revenue statistics
- β Add products
- βοΈ Edit products
- ποΈ Delete products
- πΌοΈ Product image upload
- π¦ View customer orders
- π Update order status
- π Admin-only access
| Layer | Technology |
|---|---|
| Frontend | HTML5, CSS3, Vanilla JavaScript |
| Backend | Node.js, Express.js |
| Database | MongoDB |
| ODM | Mongoose |
| Authentication | JWT |
| Password Security | bcryptjs |
| File Uploads | Multer |
| HTTP Client | Fetch API |
ββββββββββββββββββββββββββββββββ
β Frontend β
β HTML + CSS + JavaScript β
ββββββββββββββββ¬ββββββββββββββββ
β
β Fetch API / REST API
βΌ
ββββββββββββββββββββββββββββββββ
β Express.js β
β REST API + Server β
ββββββββββββββββ¬ββββββββββββββββ
β
β Mongoose
βΌ
ββββββββββββββββββββββββββββββββ
β MongoDB β
β Users / Products / Orders β
ββββββββββββββββββββββββββββββββ
The Express server provides the REST API and serves the static frontend from the same application.
CodeAlpha_SimpleEcommerce/
β
βββ backend/
β βββ config/
β β βββ db.js
β β
β βββ models/
β β βββ User.js
β β βββ Category.js
β β βββ Product.js
β β βββ Order.js
β β
β βββ middleware/
β β βββ auth.js
β β βββ upload.js
β β
β βββ controllers/
β β βββ authController.js
β β βββ productController.js
β β βββ categoryController.js
β β βββ orderController.js
β β
β βββ routes/
β β βββ authRoutes.js
β β βββ productRoutes.js
β β βββ categoryRoutes.js
β β βββ orderRoutes.js
β β
β βββ server.js
β βββ seed.js
β βββ package.json
β βββ .env.example
β
βββ frontend/
β βββ css/
β β βββ style.css
β β
β βββ js/
β β βββ api.js
β β βββ auth.js
β β βββ cart.js
β β βββ utils.js
β β βββ navbar.js
β β βββ home.js
β β βββ products.js
β β βββ product-details.js
β β βββ cart-page.js
β β βββ checkout.js
β β βββ order-success.js
β β βββ my-orders.js
β β βββ login.js
β β βββ register.js
β β βββ admin-dashboard.js
β β βββ admin-products.js
β β βββ admin-add-product.js
β β βββ admin-edit-product.js
β β βββ admin-orders.js
β β
β βββ images/
β β
β βββ admin/
β β βββ dashboard.html
β β βββ products.html
β β βββ add-product.html
β β βββ edit-product.html
β β βββ orders.html
β β
β βββ index.html
β βββ products.html
β βββ product-details.html
β βββ cart.html
β βββ checkout.html
β βββ login.html
β βββ register.html
β βββ my-orders.html
β βββ order-success.html
β
βββ .gitignore
βββ README.md
Make sure the following are installed:
- Node.js β LTS version recommended
- MongoDB Community Server
MongoDB Atlas can also be used instead of a local MongoDB server.
Check the installed versions:
node --version
npm --version
mongod --version
mongoshis optional and is only required if you want to inspect the MongoDB database manually from the command line.
git clone https://github.com/MBen213/CodeAlpha_SimpleEcommerce.git
cd CodeAlpha_SimpleEcommerceThen move into the backend directory:
cd backendnpm installCreate a .env file inside the backend directory.
Use .env.example as a template:
PORT=5000
MONGO_URI=mongodb://127.0.0.1:27017/codealpha_ecommerce
JWT_SECRET=your_secure_jwt_secretNever commit your .env file to GitHub.
The repository should contain:
.env.example
and should not contain:
.env
Make sure your MongoDB server is running before starting the application.
On Windows, you can check the MongoDB service using:
services.msc
Look for the MongoDB service and make sure it is running.
The project includes a seed script that creates sample categories, products, and an administrator account.
Run:
npm run seednpm startThe application will be available at:
http://localhost:5000
Open this URL in your browser.
The seed script creates an administrator account for development and testing.
The credentials are defined by the project's seed configuration.
Security: The default development credentials should never be used in a production deployment. Change the password and JWT secret before deployment.
| Method | Endpoint | Description | Authentication |
|---|---|---|---|
| POST | /api/auth/register |
Register a customer | Public |
| POST | /api/auth/login |
Login | Public |
| GET | /api/auth/me |
Get current user | Authenticated |
| Method | Endpoint | Description | Authentication |
|---|---|---|---|
| GET | /api/products |
Get products with search/filter | Public |
| GET | /api/products/:id |
Get product details | Public |
| POST | /api/products |
Create product | Admin |
| PUT | /api/products/:id |
Update product | Admin |
| DELETE | /api/products/:id |
Delete product | Admin |
| Method | Endpoint | Description | Authentication |
|---|---|---|---|
| GET | /api/categories |
Get categories | Public |
| POST | /api/categories |
Create category | Admin |
| Method | Endpoint | Description | Authentication |
|---|---|---|---|
| POST | /api/orders |
Create an order | Authenticated |
| GET | /api/orders/my |
Get current user's orders | Authenticated |
| GET | /api/orders |
Get all orders | Admin |
| GET | /api/orders/:id |
Get an order | Owner/Admin |
| PUT | /api/orders/:id/status |
Update order status | Admin |
Browse Products
β
View Product Details
β
Add to Cart
β
Update Cart
β
Checkout
β
Enter Shipping Information
β
Create Order
β
Order Confirmation
β
View Order History
Register
β
Login
β
JWT Token
β
Token stored in Browser
β
Authorization Header
β
Protected API Requests
β
User / Admin Resources
Passwords are hashed with bcryptjs, and JWT tokens are used to authenticate protected API requests.
Before submission, verify the following:
- User registration works
- User login works
- Invalid credentials are rejected
- Product listing works
- Product search works
- Category filtering works
- Product details work
- Add to cart works
- Cart quantity updates work
- Product removal works
- Cart totals are calculated correctly
- Checkout works
- Orders are created successfully
- Product stock is updated
- My Orders works
- Admin login works
- Admin dashboard works
- Admin can add products
- Admin can edit products
- Admin can delete products
- Admin can view orders
- Admin can update order status
- This project implements a simplified checkout process.
- No real payment gateway is connected.
- The shopping cart is stored client-side using
localStorage. - Orders are permanently stored in MongoDB after checkout.
- Product images are handled using Multer.
- JWT is used for protected API endpoints.
- Express serves both the REST API and the static frontend.
- The project is intended for educational and internship purposes.
This project was developed as part of the:
CodeAlpha Full Stack Development Internship
- β Product listings
- β Shopping cart
- β Product details page
- β Order processing
- β User registration/login
- β Database for products, users, and orders
- β Express.js backend
- β HTML/CSS/JavaScript frontend
Mohamed Ben
Full Stack Web Developer | Software Engineer
This project was created for educational and internship purposes as part of the CodeAlpha Full Stack Development Internship.








