Skip to content

ull-stack Product Management System built with Angular 17, Node.js/Express, and MySQL. Features: User/Category/Product CRUD, bulk CSV upload, report generation (CSV/XLSX), JWT auth, server-side pagination, sorting, and search. Handles large files without timeout. Includes Postman collection for API testing.

Notifications You must be signed in to change notification settings

Broly157/Angular-Node.js_Assignment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Product Management System

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.

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

Tech Stack

Backend

  • Node.js
  • Express.js
  • Sequelize ORM
  • MySQL/PostgreSQL
  • JWT for authentication
  • Multer for file uploads
  • ExcelJS for XLSX generation
  • json2csv for CSV generation

Frontend

  • Angular 17 (Standalone Components)
  • TypeScript
  • RxJS
  • SCSS

Prerequisites

  • Node.js (v18 or higher)
  • npm
  • MySQL or PostgreSQL database

Installation

1. Clone the repository

2. Backend Setup

cd backend
npm install

Create 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_here

Note: For PostgreSQL, set DB_DIALECT=postgres

Create the database:

CREATE DATABASE product_management;

3. Frontend Setup

cd frontend
npm install

Running the Application

Start Backend Server

cd backend
npm run dev

The backend server will run on http://localhost:3000

Start Frontend Application

cd frontend
npm start

The frontend application will run on http://localhost:4200

API Endpoints

Authentication

  • POST /api/auth/register - Register a new user
  • POST /api/auth/login - Login user

Users (Protected)

  • GET /api/users - Get all users
  • GET /api/users/:id - Get user by ID
  • PUT /api/users/:id - Update user
  • DELETE /api/users/:id - Delete user

Categories

  • GET /api/categories - Get all categories
  • GET /api/categories/:id - Get category by ID
  • POST /api/categories - Create category (protected)
  • PUT /api/categories/:id - Update category (protected)
  • DELETE /api/categories/:id - Delete category (protected)

Products

  • GET /api/products - Get products with pagination, sorting, and search
  • GET /api/products/:id - Get product by ID
  • POST /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)

API Query Parameters

Product List API

  • 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 name
  • categoryId - Filter by category ID

Example:

GET /api/products?page=1&limit=10&sortBy=price&sortOrder=ASC&search=laptop&categoryId=1

Bulk Upload CSV Format

The CSV file for bulk upload should have the following columns:

name,price,categoryId
Product 1,99.99,1
Product 2,149.99,2

Database Schema

User

  • id (Primary Key, Auto Increment)
  • email (String, Unique)
  • password (String, Encrypted)
  • createdAt, updatedAt (Timestamps)

Category

  • id (Primary Key, Auto Increment)
  • uniqueId (String, UUID, Unique)
  • name (String, Unique)
  • createdAt, updatedAt (Timestamps)

Product

  • 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)

Postman Collection

A Postman collection is available for testing all API endpoints. Import the collection file Product-Management-API.postman_collection.json into Postman.

Project Structure

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

License

ISC

About

ull-stack Product Management System built with Angular 17, Node.js/Express, and MySQL. Features: User/Category/Product CRUD, bulk CSV upload, report generation (CSV/XLSX), JWT auth, server-side pagination, sorting, and search. Handles large files without timeout. Includes Postman collection for API testing.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published