Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

Open more actions menu

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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.