Skip to content

A full-stack Express + PostgreSQL inventory app for managing books and genres. Features CRUD operations, image uploads, search, filtering, sorting, and server-rendered views using EJS and Tailwind CSS.

Notifications You must be signed in to change notification settings

devxsameer/chapterhub-inventory

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

20 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ“š ChapterHub Inventory

A full-stack Express + PostgreSQL (Neon) bookstore inventory application featuring CRUD, image uploads, search, sorting, filtering, and clean server-rendered views using EJS + Tailwind CSS.

Built as part of The Odin Project, but structured like a production-grade MVC application.


πŸš€ Live Demo

Render: https://chapterhub-inventory.onrender.com/


πŸ”– Tech Stack & Tools

Node.js Express PostgreSQL Neon EJS TailwindCSS Multer JavaScript The Odin Project


πŸ“Έ Screenshots

Home Page

home

Books Page

home

Edit Book Page

home

Delete Genre Page

home

Error Page

home

Go to Live demo Section to see more pages - Error 500 Page, Edit Genre Page , Delete Book Page


🧰 Features

πŸ“– Books Management

  • Create, edit, delete books
  • Upload cover images (Multer)
  • Metadata support: title, author, year, description
  • Additional fields: price, quantity
  • Filename hashing using crypto
  • Full validation with express-validator

πŸ“‚ Genres Management

  • Create, edit, delete genres
  • Name + description fields
  • Prevent duplicates using DB constraints
  • Genre dropdown in book forms

πŸ” Search, Filter & Sort

  • Search books by title
  • Filter books by one or multiple genres
  • Sort options:
    • Title (A–Z / Z–A)
    • Year (Oldest / Newest)
    • Price (Low β†’ High / High β†’ Low)

πŸ“¦ Database Layer

  • PostgreSQL hosted on Neon
  • Parameterized SQL queries (SQL injection safe)
  • Modular queries for books & genres
  • Seed script includes:
    • Schema generation
    • Sample genres & books
    • --reset mode
    • Index creation for genres

🎨 UI (Tailwind + EJS)

  • Tailwind CSS v4
  • Modern, minimal, responsive UI
  • Clean EJS templates

πŸ—οΈ Tech Stack

Backend

  • Node.js
  • Express 5
  • Express Validator
  • Multer (image uploads)
  • PostgreSQL (Neon)

Frontend

  • EJS
  • Tailwind CSS 4
  • Vanilla JavaScript

Dev Tools

  • Nodemon
  • Concurrently
  • pnpm
  • dotenv

πŸ“ Folder Structure

chapterhub-inventory/
β”‚
β”œβ”€ app.js
β”œβ”€ package.json
β”œβ”€ nodemon.json
β”‚
β”œβ”€ db/
β”‚   β”œβ”€ seed.js
β”‚   β”œβ”€ pool.js
β”‚   β”œβ”€ data/
β”‚   β”‚    β”œβ”€ books.js
β”‚   β”‚    └─ genres.js
β”‚   └─ queries/
β”‚        β”œβ”€ books.js
β”‚        └─ genres.js
β”‚
β”œβ”€ controllers/
β”‚   β”œβ”€ booksController.js
β”‚   └─ genresController.js
β”‚
β”œβ”€ routes/
β”‚   β”œβ”€ booksRouter.js
β”‚   β”œβ”€ genresRouter.js
β”‚   └─ indexRouter.js
β”‚
β”œβ”€ validators/
β”‚   β”œβ”€ booksValidators.js
β”‚   └─ genresValidators.js
β”‚
β”œβ”€ middlewares/
β”‚   β”œβ”€ upload.js
β”‚   └─ setLocals.js
β”‚
β”œβ”€ views/
β”‚
└─ public/


πŸ—„οΈ Database Schema

genres

Column Type Notes
id identity (PK) auto-generated
name varchar(100) unique, required
description text optional
created_at timestamptz defaults to NOW()

books

Column Type Notes
id identity (PK) auto-generated
title varchar(255) required
author varchar(255) optional
description text optional
year integer optional
genre_id integer (FK) references genres(id)
image_url text uploaded path
price numeric(10,2) default 0
quantity int default 0
created_at timestamptz defaults to NOW()
UNIQUE(title, author) prevents duplicates

πŸ“Œ Index:

CREATE INDEX idx_books_genre_id ON books(genre_id);

βš™οΈ Setup & Installation

1. Clone the repository

git clone https://github.com/devxsameer/chapterhub-inventory.git
cd chapterhub-inventory

2. Install dependencies

pnpm install

3. Create .env

DATABASE_URL=your_neon_connection_string
PORT=6969

4. Seed the database

Fresh reset:

pnpm seed:reset

Normal seed:

pnpm seed

πŸ§ͺ Running the Project

Development mode (server + Tailwind watcher)

pnpm dev

Build Tailwind for production

pnpm css:build

Start server normally

pnpm start

Server runs at:

http://localhost:6969

πŸ–ΌοΈ Image Upload System

  • Uploads stored in: public/uploads/
  • Uses Multer disk storage
  • Accepts: .jpg, .jpeg, .png, .webp
  • Max file size: 5MB
  • Unique filenames using crypto.randomBytes

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

Sameer Ali
Full-stack developer & Odin Project learner.


πŸ“ License

MIT License β€” free to modify & share.

About

A full-stack Express + PostgreSQL inventory app for managing books and genres. Features CRUD operations, image uploads, search, filtering, sorting, and server-rendered views using EJS and Tailwind CSS.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published