Skip to content

shahadathhs/ecommerce-inventory-api

Repository files navigation

Ecommerce Inventory API

A backend API for managing categories, products, and inventory with file upload support.

📌 Overview

This is a simple Ecommerce Inventory Management API built with NestJS and Prisma ORM.
It supports Category & Product CRUD operations, product filtering (by category, price, pagination), and file upload to Supabase storage.

🔗 Live URL & Swagger API Docs

👉 https://ecommerce-inventory-api-irhk.onrender.com/api/docs

🗂 Database ERD

  • ERD Diagram: View Online
  • Diagram Image: available inside the /db folder at the root of the project

⚡ Tech Stack

⚙️ Environment Setup

Create a .env file in the root directory using .env.example as a reference:

DATABASE_URL="postgresql://postgres:postgres@localhost:5432/postgres?schema=public"

JWT_SECRET="super-secret-key"
ACCESS_TOKEN_EXPIRES_IN="7d"

NODE_ENV=development
PORT=4000

SUPABASE_URL="https://xyz.supabase.co"
SUPABASE_SERVICE_ROLE_KEY="service-role-key-with-permissions"

# Ensure the Supabase Storage has a bucket named "product"
# You can create one from Supabase Dashboard → Storage → Create Bucket

Running Locally

  1. Clone the repo

    git clone https://github.com/shahadathhs/ecommerce-inventory-api.git
    cd ecommerce-inventory-api
  2. Install dependencies

    pnpm install
  3. Generate Prisma client & run migrations

    pnpm db:generate
    pnpm db:migrate
  4. Start the server

    pnpm dev
  5. Open Swagger docs

    http://localhost:4000/api/docs
    

🌐 Deployment

  • Backend is hosted on Render
  • Database is hosted on Neon
  • File uploads are stored on Supabase Storage

📁 Project Structure

src/
 ├── modules/
 │   ├── category/      # Category management (CRUD)
 │   ├── product/       # Product management (CRUD + filters)
 │   ├── auth/          # Authentication (login, register, refresh, etc.)
 ├── common/            # Shared utils, decorators, guards, interceptors
 ├── lib/
 │   ├── prisma/        # Prisma service & client wrapper
 │   ├── file/          # Supabase file upload integration
 └── main.ts            # Application entrypoint

prisma/
 ├── migrations/        # Database migration files
 └── schema/            # Prisma schema definition

prisma.config.js        # Prisma CLI/config entry

✨ Features

  • Category CRUD (unique name, slug auto-generated)
  • Product CRUD with filters (category, price range, pagination)
  • Supabase file upload (with delete handling)
  • Swagger API documentation
  • Repository pattern architecture

About

A backend API for managing categories, products, and inventory with file upload support.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published