mdnaimurrahman.com
Product Review Hub
Date
Jun 2026
Category
Full Stack
Source Code

Product Review Hub

A full-stack product review platform where users can browse products, submit star ratings and reviews, manage their own reviews, and admins can manage the catalog. Built with Next.js, FastAPI, and PostgreSQL.

Live Demo: Frontend | API | Swagger Docs


What This Project Demonstrates

This project is designed to showcase full-stack engineering skills across the complete web development spectrum:

  • Frontend (Next.js 16): App Router, TypeScript, server & client components, custom hooks, responsive design
  • Backend (FastAPI): Async Python, SQLAlchemy 2.x, Alembic migrations, Pydantic validation, JWT auth
  • Database (PostgreSQL): Relational schema design, indexed queries, cascade deletes
  • Testing: Backend tests (pytest + async fixtures) and frontend tests (Vitest + MSW)

Tech Stack

LayerTechnology
FrontendNext.js 16 (App Router), TypeScript, Tailwind CSS v4, shadcn/ui
BackendFastAPI, Python 3.12, SQLAlchemy 2.x (async), Alembic
DatabasePostgreSQL (asyncpg driver)
Authenticationfastapi-users with JWT (cookie-based tokens)
Package Managerspnpm (frontend), uv (backend)

Project Structure

product-review-hub/
├── frontend/                 # Next.js application
│   ├── app/                  # App Router pages (home, products/[id], dashboard)
│   ├── components/           # React components (shadcn/ui + custom)
│   ├── hooks/                # Custom React hooks (useAuth, useReviews)
│   ├── lib/                  # API client, utilities, schemas
│   └── tests/                # Vitest + MSW component tests
├── backend/                  # FastAPI application
│   ├── app/                  # Application code
│   │   ├── routers/          # API route handlers
│   │   ├── models.py         # SQLAlchemy ORM models (user, product, review)
│   │   ├── schemas.py        # Pydantic request/response schemas
│   │   └── auth.py           # JWT auth configuration
│   ├── alembic/              # Database migrations
│   ├── scripts/              # Seed script for sample data
│   └── tests/                # Pytest async tests
└── README.md

Pages & Features

Home Page

  • Product grid with pagination — each card shows the product image, title, average rating (stars), and review count
  • Search bar to find products by title/description
  • Rating filter to narrow results by minimum rating
  • Skeleton loaders while data is fetching
  • Error alerts with retry on API failure

Product Details Page

  • Full product information with image and description
  • Average rating summary
  • All user reviews displayed chronologically
  • Review submission form with fields for Name, Rating (1–5 with interactive star hover preview), and Comment
  • After submitting, the review list automatically refreshes and the average rating updates immediately

User Dashboard

  • View all reviews submitted by the logged-in user
  • Edit or delete your own reviews

Admin Panel (Superuser Only)

  • Create new products (title, description, image URL)
  • Delete products (cascades to remove all associated reviews)
  • Moderate and delete any inappropriate reviews

Database Schema

TableKey ColumnsNotes
userid (UUID), email, hashed_password, name, is_superuser, is_active, is_verified, created_atExtended beyond PRD spec with UUID PK, superuser roles, and verification flags
productid (int), title, description, image_url, created_atCascade delete to reviews
reviewid (int), product_id (FK), user_id (FK), rating (1–5), comment, created_atUnique constraint on (product_id, user_id) — one review per product per user

Migrations

cd backend
uv run alembic upgrade head
uv run alembic current
uv run alembic downgrade -1

API Endpoints

All endpoints are prefixed with /api. Interactive docs at /docs.

Authentication

MethodEndpointAuthDescription
POST/api/auth/registerPublicRegister a new user (name, email, password)
POST/api/auth/jwt/loginPublicLogin — returns cookie-based JWT
POST/api/auth/jwt/logoutJWTLogout
GET/api/users/meJWTGet current user profile

Products

MethodEndpointAuthDescription
GET/api/products/PublicList products (paginated, searchable by title, filterable by rating)
GET/api/products/{id}PublicGet product details with all reviews and user names

Reviews

MethodEndpointAuthDescription
POST/api/reviews/JWTCreate a review (rating 1–5, comment)
GET/api/reviews/meJWTGet current user's reviews (dashboard)
PUT/api/reviews/{id}JWTUpdate own review
DELETE/api/reviews/{id}JWTDelete own review

Admin (Superuser Only)

MethodEndpointAuthDescription
GET/api/admin/productsAdminList all products
POST/api/admin/productsAdminCreate a product
DELETE/api/admin/products/{id}AdminDelete a product (cascades)
GET/api/admin/reviewsAdminList all reviews
DELETE/api/admin/reviews/{id}AdminDelete any review

Getting Started

Prerequisites

  • Python 3.12+
  • Node.js 18.18+
  • PostgreSQL (local or hosted like Supabase)
  • uv (install)
  • pnpm (install)

1. Clone

git clone https://github.com/mdnaimur0/product-review-hub.git
cd product-review-hub

2. Backend

cd backend
uv venv && uv sync
cp .env.example .env   # edit with your DB URL and secret key
uv run alembic upgrade head
uv run python scripts/seed_products.py   # seed 20-25 sample products (optional)
uv run fastapi dev app/main.py --host 0.0.0.0 --port 8000 --reload

Backend → http://localhost:8000 | API docs → http://localhost:8000/docs

3. Frontend

cd frontend
pnpm install
cp .env.example .env   # edit if backend runs elsewhere
pnpm dev

Frontend → http://localhost:3000

4. Admin User

Register via the UI, then promote:

UPDATE "user" SET is_superuser = true WHERE email = 'admin@example.com';

Environment Variables

Backend (backend/.env)

DATABASE_URL=postgresql+asyncpg://user:password@localhost:5432/product_review_hub
ACCESS_SECRET_KEY=your-secret-key-here
ACCESS_TOKEN_EXPIRE_SECONDS=3600
FRONTEND_URL=http://localhost:3000
CORS_ORIGINS=["http://localhost:3000"]

Frontend (frontend/.env)

NEXT_PUBLIC_API_BASE_URL=http://localhost:8000

Testing

Backend (pytest + async fixtures)

Uses an in-memory SQLite database — no PostgreSQL needed.

cd backend
uv run pytest

Frontend (Vitest + MSW)

cd frontend
pnpm test          # run once
pnpm test:watch    # watch mode

Improvements Beyond the Original Spec

The PRD requested a basic review platform. The following were built as enhancements:

AreaPRD RequiredWhat Was Built
Product listingBasic listPaginated grid with search and rating filter
Star ratingStatic 1–5 inputInteractive stars with hover preview and click-to-rate
AuthenticationBasic register/loginCookie-based JWT, user roles (user/admin), verification flags
User managementJust id, name, emailUUID primary keys, is_superuser, is_active, is_verified, timestamps
Admin panelBonus — add/remove productsFull admin CRUD: create/delete products, list & moderate all reviews
User dashboardNot mentioned"My Reviews" page — edit/delete own reviews
Loading UX"Proper loading handling"Skeleton loaders on cards, product detail, and review lists
Error handling"Proper error handling"Retry-capable error alerts + toast notifications
DatabaseBasic tablesMigrations (Alembic), seed script, cascade deletes, unique constraints
Package managementNot specifiedpnpm (faster installs), uv (blazing-fast Python dependency management)
AsyncNot specifiedFully async — asyncpg + async SQLAlchemy 2.x + async pytest fixtures
TestsNot specifiedBackend: pytest with async fixtures, isolated SQLite DB; Frontend: Vitest + MSW mock service worker
CI/CDNot specifiedReady for Vercel (frontend) + Render (backend) deployment

License

MIT

Copyright © 2026 by Md. Naimur Rahman | All Rights Reserved