The Decentralized Operating System for Local Thrift, Vintage & Circular Commerce
Unifying fragmented, offline secondhand store inventories into an ultra-fast, real-time online marketplace.
- π Project Overview
- β¨ Key Features
- ποΈ System Architecture & Data Flow
- π§° Tech Stack
- π Monorepo Structure
- π Quick Start & Local Setup
- π‘ API Reference
- π Security & Verification Engine
- π Available NPM Scripts
- π€ Contributing
- π License
Traditional thrift, vintage, and secondhand fashion retail is constrained by the 1-of-1 single-stock inventory paradox: each item is physically unique, with distinct condition grades, sizing nuances, and offline in-store walk-in sales risks.
UnRetail solves this with a high-concurrency, unified commerce engine:
- Real-Time Single-Item State Machine: Eliminates double-booking between in-store cash sales and digital checkouts.
- Sub-50ms Search & Faceted Discovery: Instant typo-tolerant queries across eras, condition tiers, styles, and local shop locations.
- Zero-Overhead Direct Media Pipeline: Browser-direct signed uploads to Cloudinary without consuming Node.js API server RAM or CPU cycles.
- Merchant KYC & Buyer Protection: Anti-fraud electronic device checklists, verified merchant badges, and escrow-backed payment protection.
- Instant Search with Meilisearch: Millisecond-level filtering across categories, subcategories, era (Y2K, 90s, 80s, Vintage), condition (
LIKE_NEW,GENTLY_USED,FLAWED), and shop city. - Dynamic 1-of-1 Catalog Feed: Curated item drops, store spotlights, and real-time stock availability flags (
AVAILABLE,PENDING,SOLD,SOLD_OFFLINE). - Interactive Cart & Razorpay Checkout: Instant order reservation with dynamic INR currency formatting and Razorpay gateway integration.
- Order Tracking & Dispute Filing: Buyer order history with carrier tracking codes, delivery status, and direct dispute escalation.
- Rapid Listing Workflow (< 60 Seconds): Mobile-first item onboarding with automatic Cloudinary client-side pre-signed uploads.
- Electronics & Retro Tech Fraud Shield: Specialized verification for secondhand gadgets (Power-on status, screen/sensor clarity, charging ports, IMEI/Serial verification, and declared defect logs).
- Physical Store POS Sync: 1-tap
Mark as Sold Offlinetoggle to synchronize in-store retail transactions with the live web feed. - Fulfillment & Dispatch Desk: Real-time order dispatch updates with carrier name and tracking ID integration.
- Merchant KYC Verification Desk: Review Indian identity proof documents (Aadhaar Card, PAN Card, Voter ID, Passport) and merchant selfies with one-click Approve / Reject + audit feedback reason.
- Shop Verification & Badging: Grant official verified store badges to reputable local thrift merchants.
- Dispute Resolution Console: Review customer claims, investigate order timelines, and trigger automated resolutions.
- Platform Analytics & GMV Overview: High-level platform health, catalog metrics, and merchant performance metrics.
+--------------------------------------------------+
| NEXT.JS FRONTEND |
| (App Router) |
| - Customer Feed - Merchant Portal - Admin Desk |
+--------------------------------------------------+
β β
(Direct Browser Uploads) (REST API Requests)
β β
βΌ βΌ
+--------------------------+ +--------------------------+
| CLOUDINARY CDN | | NODE.JS / EXPRESS |
| | | BACKEND API |
| - Photo Compression | | - Google OAuth & JWT |
| - Mobile Image Cropping | | - Order State Machine |
+--------------------------+ | - Role Guards & RBAC |
+--------------------------+
β β β
ββββββββββββββββββ β ββββββββββββββββββ
β β β
βΌ βΌ βΌ
+-----------------------+ +-----------------------+ +-----------------------+
| POSTGRESQL (PRISMA) | | RAZORPAY GATEWAY | | MEILISEARCH ENGINE |
| | | | | |
| - Relational DB | | - Webhook Signatures | | - Sub-50ms Search |
| - Transaction Locks | | - Escrow Order Flow | | - Faceted Filters |
+-----------------------+ +-----------------------+ +-----------------------+
[Client Browser] ββ(1. Request Signature)ββ> [Express API /cloudinary/signature]
[Client Browser] <ββ(2. Return HMAC Sig)ββββ [Express API]
[Client Browser] ββ(3. POST image + Sig)βββ> [Cloudinary CDN]
[Client Browser] <ββ(4. Return CDN URLs)ββββ [Cloudinary CDN]
[Client Browser] ββ(5. Create Item + URLs)ββ> [Express API /items] ββ> [PostgreSQL + Meilisearch]
| Layer | Technologies |
|---|---|
| Frontend | Next.js 15 (App Router), React 19, Tailwind CSS, Framer Motion, Lucide React, Axios |
| Backend | Node.js (ES Modules), Express.js 4, Prisma ORM 5 |
| Database | PostgreSQL (Hosted on Neon / Supabase / Local PostgreSQL) |
| Search Engine | Meilisearch (Typo-tolerant fast search & faceted indexing) |
| Media Pipeline | Cloudinary (Direct pre-signed client uploads & on-the-fly transformations) |
| Payments | Razorpay (Checkout SDK, Orders API, HMAC-SHA256 Webhook verification) |
| Authentication | Google OAuth 2.0, JWT (JSON Web Tokens), Role-Based Access Control |
| Security | Helmet-style security headers, Rate Limiting (express-rate-limit), CORS whitelist, Input sanitization |
Unretail/
βββ package.json # Root monorepo orchestration scripts
βββ README.md # Project documentation
β
βββ client/ # Next.js 15 Frontend Application
β βββ app/ # Next.js App Router
β β βββ (customer)/ # Customer portal (feed, search, item, checkout, orders, shops)
β β βββ (merchant)/ # Merchant portal (dashboard, listings, new-item, edit-item, orders)
β β βββ admin/ # Admin console (dashboard, login, KYC reviews, disputes)
β β βββ layout.jsx # Root layout with navigation & theme wrappers
β β βββ page.jsx # Landing page & platform hero
β βββ components/ # Reusable UI component library
β βββ lib/ # Client utilities, API Axios instance, Auth context
β βββ public/ # Static brand assets and icons
β βββ tailwind.config.js # Tailwind CSS theme configuration
β βββ package.json # Frontend dependencies
β
βββ server/ # Express.js REST API Backend
βββ config/ # Meilisearch, Cloudinary & database clients
βββ scripts/ # Seeding, cleanup, indexing & E2E test scripts
β βββ seed-curated-products.js
β βββ sync-search.js
β βββ e2e-api-test.js
βββ src/
β βββ app.js # Express application initialization & middleware stack
β βββ controllers/ # Business logic (Auth, Items, Orders, Payments, Merchant, Disputes)
β βββ middlewares/ # JWT Auth, RBAC guards, rate limiters, error handling
β βββ prisma/
β β βββ schema.prisma # PostgreSQL Prisma schema & domain models
β β βββ client.js # Singleton Prisma client instance
β βββ routes/ # Modular Express route declarations
β βββ services/ # Meilisearch sync, payment validation & external helpers
βββ package.json # Backend dependencies & Prisma scripts
Make sure you have the following installed on your machine:
- Node.js
>= 18.17.0(LTS recommended) - PostgreSQL database running locally or a cloud database URL (e.g. Neon, Supabase)
- Meilisearch (Local executable or Docker container)
- A free Cloudinary account
- A Razorpay test mode account
Clone the repository and install dependencies for all workspaces:
# Clone the repository
git clone https://github.com/Bala-Git-code/UnRetail.git
cd Unretail
# Install client and server dependencies
cd client && npm install
cd ../server && npm install
cd ..Create the .env files in both server/ and client/ directories based on the provided templates.
# Server Port & Environment
PORT=5001
NODE_ENV=development
# PostgreSQL Database Connection
DATABASE_URL="postgresql://postgres:password@localhost:5432/unretail?schema=public"
# JWT Secret & Admin Credentials
JWT_SECRET="your_super_secret_random_jwt_key_here"
GOOGLE_CLIENT_ID="your_google_oauth_client_id.apps.googleusercontent.com"
ADMIN_EMAIL="admin@unretail.in"
ADMIN_PASSWORD="your_secure_admin_password"
# Razorpay Payment Gateway (Test Mode)
RAZORPAY_KEY_ID="rzp_test_YourKeyId"
RAZORPAY_KEY_SECRET="YourRazorpaySecret"
RAZORPAY_WEBHOOK_SECRET="YourRazorpayWebhookSecret"
# Cloudinary CDN Configuration
CLOUDINARY_CLOUD_NAME="your_cloud_name"
CLOUDINARY_API_KEY="your_api_key"
CLOUDINARY_API_SECRET="your_api_secret"
# Meilisearch Engine
MEILISEARCH_HOST="http://localhost:7700"
MEILISEARCH_ADMIN_KEY="masterKey"
# Client CORS URL
CLIENT_URL="http://localhost:3000"# Backend API Base URL
NEXT_PUBLIC_API_URL="http://localhost:5001/api/v1"
# Google OAuth Client ID for Client-Side Login
NEXT_PUBLIC_GOOGLE_CLIENT_ID="your_google_oauth_client_id.apps.googleusercontent.com"You can start both frontend and backend concurrently or in separate terminals:
# Option A: Start both via separate terminals
# Terminal 1: Start Express API Server (Port 5001)
npm run dev:server
# Terminal 2: Start Next.js Frontend (Port 3000)
npm run dev:clientOpen your browser and navigate to:
- Customer Portal / Landing Page: http://localhost:3000
- Merchant Dashboard: http://localhost:3000/dashboard
- Admin Governance Desk: http://localhost:3000/admin
- Backend API Health Check: http://localhost:5001/health
- Role-Based Access Control (RBAC): Every sensitive API route is protected by
authenticateJwtandrequireRole(['CUSTOMER', 'MERCHANT', 'ADMIN']). - Pre-Signed Direct Cloudinary Uploads: Image binary payloads never traverse the Express API server memory, preventing memory leaks, DoS vulnerabilities, and server bandwidth saturation.
- HMAC-SHA256 Webhook & Signature Verification: Razorpay payment callbacks and webhook events require cryptographic signature validation prior to database state transitions.
- Rate Limiting & Defensive Headers: Automated rate limiting on authentication routes (
authRateLimiter) and API endpoints (apiRateLimiter) to prevent brute-force attacks.
| Command | Description |
|---|---|
npm run dev:client |
Starts Next.js development server on http://localhost:3000 |
npm run dev:server |
Starts Express backend server with nodemon on http://localhost:5001 |
npm run build |
Builds production Next.js frontend bundle |
npm run sync:search |
Synchronizes PostgreSQL products into Meilisearch index |
npm run test:api |
Executes end-to-end API test suite (server/scripts/e2e-api-test.js) |
| Command | Description |
|---|---|
npm run dev |
Run Express server with Nodemon auto-reload |
npm run start |
Run Express server in production mode |
npm run db:migrate |
Apply Prisma database migrations |
npm run db:generate |
Regenerate Prisma Client types |
npm run seed |
Seed database with demo items, shops, and categories |
npm run sync-search |
Index all items into Meilisearch |
Contributions are welcome! Please follow these steps:
- Fork the Repository
- Create a Feature Branch (
git checkout -b feature/AmazingFeature) - Commit your Changes (
git commit -m 'feat: Add some AmazingFeature') - Push to the Branch (
git push origin feature/AmazingFeature) - Open a Pull Request