A modular full-stack e-commerce architecture designed for electronics retail, featuring a RESTful API backend, JWT authentication, cart session persistence, and an administrative product management dashboard.
graph TD
Client[Web Client & Admin Dashboard] --> Router[Express Router]
Router --> Auth[Auth Middleware & JWT]
Router --> ProductAPI[/api/products - CRUD/]
Router --> CartAPI[/api/cart - Cart Management/]
Auth --> MongoDB[(MongoDB Atlas / Local)]
ProductAPI --> MongoDB
CartAPI --> MongoDB
- JWT Authentication & Authorization: Secure registration, token-based session management, and role validation via
bcryptpassword hashing. - Product Lifecycle Management (CRUD): REST endpoints for listing, filtering, adding, updating, and removing electronics inventory.
- Shopping Cart Orchestration: Cart persistence with dynamic subtotal calculations.
- Admin Dashboard: Standalone client interface (
frontend/admin/) for real-time inventory adjustments and catalog audits. - ES Modules (ESM): Modern native
import/exportsyntax in Node.js 18+.
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
POST |
/api/auth/register |
Register a new user | ❌ No |
POST |
/api/auth/login |
Authenticate and obtain JWT token | ❌ No |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
GET |
/api/products |
Retrieve all products (with filters) | ❌ No |
GET |
/api/products/:id |
Get details for a single product | ❌ No |
POST |
/api/products |
Create a new product entry | ✅ Yes (Admin) |
PUT |
/api/products/:id |
Update product details / pricing | ✅ Yes (Admin) |
DELETE |
/api/products/:id |
Delete a product from inventory | ✅ Yes (Admin) |
| Method | Endpoint | Description | Auth Required |
|---|---|---|---|
GET |
/api/cart |
View user cart items & total | ✅ Yes |
POST |
/api/cart |
Add product to cart | ✅ Yes |
DELETE |
/api/cart/:id |
Remove specific item from cart | ✅ Yes |
TechHouse/
├── backend/
│ ├── package.json
│ └── src/
│ ├── app.js # Express application configuration
│ ├── server.js # Server entrypoint and DB connection
│ ├── controllers/ # Business logic (auth, product, cart)
│ ├── routes/ # Route definitions
│ └── data/db.js # Database connection layer
├── frontend/
│ ├── admin/ # Administrative product dashboard
│ └── login/ # Authentication interface
├── .gitignore # Ignored files (node_modules, .env)
└── README.md # Project documentation
git clone https://github.com/Az1zbekx/TechHouse.git
cd TechHouseNavigate to backend/ and create .env:
cd backend
cat <<EOF > .env
PORT=5000
MONGODB_URI=mongodb://localhost:27017/techhouse
JWT_SECRET=your_super_secret_jwt_key
EOFnpm install
npm run devThe backend API will start at http://localhost:5000.
Open frontend/login/index.html or frontend/admin/index.html directly in your browser or serve using VS Code Live Server.
- Developer: Azizbek (Az1zbekx)
- License: MIT