A full-stack application built with Angular (frontend) and Node.js/Express (backend) for managing products, categories, and users. The system includes bulk upload capabilities and report generation features.
- User Management: CRUD operations for users with encrypted passwords
- Category Management: Create, read, update, and delete categories
- Product Management: Manage products with pagination, sorting, and search
- Bulk Upload: Upload large CSV files with products without timeout errors
- Report Generation: Download product reports in CSV or XLSX format
- Authentication: JWT-based authentication system
- Responsive UI: Modern Angular-based user interface
- Node.js
- Express.js
- Sequelize ORM
- MySQL/PostgreSQL
- JWT for authentication
- Multer for file uploads
- ExcelJS for XLSX generation
- json2csv for CSV generation
- Angular 17 (Standalone Components)
- TypeScript
- RxJS
- SCSS
- Node.js (v18 or higher)
- npm
- MySQL or PostgreSQL database
cd backend
npm installCreate a .env file in the backend directory:
PORT=3000
DB_HOST=localhost
DB_USER=root
DB_PASSWORD=your_password
DB_NAME=product_management
DB_DIALECT=mysql
JWT_SECRET=your_jwt_secret_key_hereNote: For PostgreSQL, set DB_DIALECT=postgres
Create the database:
CREATE DATABASE product_management;cd frontend
npm installcd backend
npm run devThe backend server will run on http://localhost:3000
cd frontend
npm startThe frontend application will run on http://localhost:4200
POST /api/auth/register- Register a new userPOST /api/auth/login- Login user
GET /api/users- Get all usersGET /api/users/:id- Get user by IDPUT /api/users/:id- Update userDELETE /api/users/:id- Delete user
GET /api/categories- Get all categoriesGET /api/categories/:id- Get category by IDPOST /api/categories- Create category (protected)PUT /api/categories/:id- Update category (protected)DELETE /api/categories/:id- Delete category (protected)
GET /api/products- Get products with pagination, sorting, and searchGET /api/products/:id- Get product by IDPOST /api/products- Create product (protected)PUT /api/products/:id- Update product (protected)DELETE /api/products/:id- Delete product (protected)POST /api/products/bulk/upload- Bulk upload products from CSV (protected)GET /api/products/report/csv- Download CSV report (protected)GET /api/products/report/xlsx- Download XLSX report (protected)
page- Page number (default: 1)limit- Items per page (default: 10)sortBy- Sort field (default: 'createdAt')sortOrder- Sort order: ASC or DESC (default: 'DESC')search- Search term for product namecategoryId- Filter by category ID
Example:
GET /api/products?page=1&limit=10&sortBy=price&sortOrder=ASC&search=laptop&categoryId=1
The CSV file for bulk upload should have the following columns:
name,price,categoryId
Product 1,99.99,1
Product 2,149.99,2
id(Primary Key, Auto Increment)email(String, Unique)password(String, Encrypted)createdAt,updatedAt(Timestamps)
id(Primary Key, Auto Increment)uniqueId(String, UUID, Unique)name(String, Unique)createdAt,updatedAt(Timestamps)
id(Primary Key, Auto Increment)uniqueId(String, UUID, Unique)name(String)image(String, File Path)price(Decimal)categoryId(Foreign Key to Category)createdAt,updatedAt(Timestamps)
A Postman collection is available for testing all API endpoints. Import the collection file Product-Management-API.postman_collection.json into Postman.
Assignment/
├── backend/
│ ├── config/
│ │ └── database.js
│ ├── middleware/
│ │ └── auth.js
│ ├── models/
│ │ ├── User.js
│ │ ├── Category.js
│ │ └── Product.js
│ ├── routes/
│ │ ├── auth.js
│ │ ├── users.js
│ │ ├── categories.js
│ │ └── products.js
│ ├── uploads/
│ ├── .env
│ ├── .gitignore
│ ├── package.json
│ └── server.js
├── frontend/
│ ├── src/
│ │ ├── app/
│ │ │ ├── components/
│ │ │ │ ├── login/
│ │ │ │ ├── register/
│ │ │ │ ├── products/
│ │ │ │ ├── categories/
│ │ │ │ └── users/
│ │ │ ├── guards/
│ │ │ ├── interceptors/
│ │ │ ├── services/
│ │ │ ├── app.component.ts
│ │ │ └── app.routes.ts
│ │ ├── environments/
│ │ ├── index.html
│ │ ├── main.ts
│ │ └── styles.scss
│ ├── angular.json
│ ├── package.json
│ └── tsconfig.json
└── README.md
ISC