Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

5 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Node.js Category Management API

A RESTful backend API for category management, CRUD operations, and image uploads.

Node.js Express.js MySQL Multer CORS

Backend API built with Node.js and Express.js for managing categories, custom categories, and category images.


✨ Features

  • Category CRUD: Create, read, update, and delete categories.
  • Custom Category Management: Manage custom category records through REST API endpoints.
  • Category Image Management: Upload and manage multiple category images.
  • File Uploads: Handle image uploads using Multer.
  • RESTful API: Structured API endpoints using Express.js.
  • MySQL Integration: Designed for MySQL-backed data management.
  • CORS Support: Enables communication with frontend applications.
  • Static File Serving: Uploaded images are served through a public API path.
  • JSON & Form Data Support: Supports JSON requests and URL-encoded form data.

πŸ› οΈ Tech Stack

Technology Purpose
Node.js JavaScript runtime environment
Express.js REST API and server framework
MySQL Relational database
Multer Image and multipart file uploads
CORS Cross-origin API communication
Body Parser Request body parsing
JavaScript Backend development

πŸ—οΈ API Architecture

The backend follows a standard REST API architecture:

React Frontend
      β”‚
      β–Ό
   Axios
      β”‚
      β–Ό
Express.js REST API
      β”‚
      β–Ό
Admin Routes
      β”‚
      β–Ό
Controller Layer
      β”‚
      β–Ό
MySQL Database

Image Upload Architecture

Frontend
   β”‚
   β–Ό
Multipart Form Data
   β”‚
   β–Ό
Multer
   β”‚
   β–Ό
public/images/
   β”‚
   β–Ό
Image URL Served by Express

πŸ”— API Integration

All administrative endpoints are available under: /api/admin/

πŸ“‚ Category Management

Method Endpoint Description
GET /api/admin/category/ Fetch all categories
POST /api/admin/category/ Create a new category
PUT /api/admin/category/:categoryid Update a category
DELETE /api/admin/category/:categoryid Delete a category

πŸ—‚οΈ Custom Category Management

Method Endpoint Description
GET /api/admin/mycategory/ Fetch all custom categories
POST /api/admin/mycategory/ Create a custom category
PUT /api/admin/mycategory/:mycategoryid Update a custom category
DELETE /api/admin/mycategory/:mycategoryid Delete a custom category

πŸ–ΌοΈ Category Image Management

Method Endpoint Description
GET /api/admin/mycategoryimage/ Fetch category images
POST /api/admin/mycategoryimage/ Upload new category images
PUT /api/admin/mycategoryimage/:mycategoryimageid Update image records
DELETE /api/admin/mycategoryimage/:mycategoryimageid Delete image records

πŸ”— Related Frontend

This backend API was designed to work with a React.js frontend application.

πŸ‘‰ Frontend Repository:
React Category Management Dashboard


πŸ“ Image Uploads

Click to view image upload details

The API uses Multer for handling image uploads.

Single Image Upload

Category images are uploaded using:

Image

Multiple Image Upload

Category image collections support multiple uploads using:

Images

The backend supports uploading up to:

10 images per request

Uploaded files are stored in:

public/images/

Images are served through:

/images/<filename>

Example:

http://localhost:5000/images/example.jpg

πŸ“‚ Project Structure

Click to view project structure
nodejs-category-management-api/
β”‚
β”œβ”€β”€ app/
β”‚   β”‚
β”‚   β”œβ”€β”€ controllers/
β”‚   β”‚   └── admin.controller.js
β”‚   β”‚
β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   └── admin.route.js
β”‚   β”‚
β”‚   └── ...
β”‚
β”œβ”€β”€ public/
β”‚   └── images/
β”‚
β”œβ”€β”€ package.json
β”‚
β”œβ”€β”€ main.js
β”‚
└── README.md

βš™οΈ Installation

Click to view installation instructions

1. Clone the repository

git clone https://github.com/yeshagevariya/nodejs-category-management-api.git

2. Navigate to the project directory

cd nodejs-category-management-api

3. Install dependencies

npm install

4. Start the API server

node main.js

The API server will run at:

http://localhost:5000

πŸ”Œ Frontend Integration

Click to view frontend integration

This backend API was designed to work with a React.js frontend application. Example Axios request:

axios.get("http://localhost:5000/api/admin/category/");

Example image URL for React component:

<img src="http://localhost:5000/images/image-name.jpg" alt="Category" />

πŸ§ͺ API Request Examples

Click to view api request examples

Create a Category

POST /api/admin/category/

The request supports multipart form data with the following fields:

  • Name
  • Description
  • Image Upload Category Images
POST /api/admin/mycategoryimage/

The request supports multiple image uploads using the following field:

  • Images

🎯 Project Purpose

This project demonstrates the development of a backend REST API using:

  • Node.js & Express.js
  • MySQL Database Integration
  • RESTful API architecture (CRUD operations)
  • Multer for multipart form data and file uploads
  • CORS configuration for cross-origin requests
  • Static file serving for image retrieval

The API provides the backend foundation for a complete React-based category management dashboard.


πŸ‘©β€πŸ’» Author

Yesha Gevariya

Frontend Engineer building modern web applications and AI-powered products.

Specialized in: React.js Next.js TypeScript JavaScript Node.js REST APIs AI Integration RAG LLM Applications

πŸ”— Connect With Me

Portfolio LinkedIn Upwork Email Resume

πŸ“„ License

This project was created for educational and professional development purposes.

Releases

Packages

Contributors

Languages