Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

124 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸŽ“ CU Market

The Exclusive Campus Marketplace for Chandigarh University

Buy, sell, barter, and connect β€” all within your university ecosystem.


React Vite Tailwind CSS Zustand React Router Node.js Express MongoDB Mongoose JWT Cloudinary Nodemailer Zod PWA Android APK Jetpack Compose Vercel



Last Commit Top Language Repo Size

πŸ“‘ Table of Contents


🧭 Overview

CU Market is a full-stack, production-grade campus marketplace built exclusively for Chandigarh University students. Only users with a verified @cuchd.in email can register and participate. The platform enables students to list items for sale or barter, negotiate trades with automated cash-value computation, chat in real time, and stay updated with push notifications β€” all within a beautiful, mobile-first Progressive Web App.


πŸš€ Features

πŸ” Authentication & Access Control

  • University-exclusive registration β€” only @cuchd.in emails are accepted
  • OTP Email Verification via secure, stylized HTML emails (Gmail SMTP with Nodemailer)
  • JWT session management with secure Bcrypt password hashing
  • Forgot/Reset password flow with tokenized email links
  • Admin Dashboard for platform-wide user & listing management
  • Rate limiting on auth endpoints to prevent brute-force attacks

πŸ›’ Marketplace & Listings

  • Browse, search & filter products across categories (Electronics, Books, Vehicles, Clothing, etc.)
  • Create rich listings with multi-image uploads powered by Cloudinary
  • Lazy-loaded images with smooth skeleton placeholders for fast perceived performance
  • Item detail pages with seller info, pricing, condition tags, and trade/buy CTAs

πŸ”„ Trade & Barter System

  • Propose trades as alternatives to cash-only transactions
  • Automatic cash offer computation based on listed item values
  • Trade status tracking β€” pending, accepted, rejected, completed
  • Dedicated Trade Dashboard to manage all incoming/outgoing negotiations

πŸ’¬ Real-Time Chat (Socket.io)

  • Instant messaging powered by Socket.io for zero-latency communication
  • Real-time unread badges and message previews
  • Message persistence stored in MongoDB for full chat history

πŸ“‹ Item Requests

  • Community broadcast β€” request an item you need and notify the campus
  • Offer system β€” sellers can respond to requests by offering their listed items
  • Direct fulfillment β€” seamlessly bridge requests to the trade/chat system

πŸ“± Native Android App (Jetpack Compose)

  • Standalone Android APK available for direct download
  • Native Android UI built from scratch using modern Jetpack Compose
  • Digital Asset Links configured for secure cryptographic app verification
  • Native Push Notifications utilizing Chrome's notification delegation
  • Auto-updating β€” app stays in sync with web deployments instantly

πŸ“§ Developer Contact System

  • Authenticated contact form β€” only logged-in students can reach the developer
  • Auto-injected student data (Name, UID, Email) in every message for verification
  • No-reply SMTP delivery from the site's official Gmail account
  • Anti-spam headers and plain-text fallbacks for reliable inbox delivery

⭐ Ratings & Reviews

  • Post-trade rating system allowing buyers and sellers to rate each other
  • Trust building through visible community feedback on user profiles

🎨 UI & Design

  • Mobile-first responsive design using Tailwind CSS with custom design tokens
  • Custom branded splash screen with animated logo
  • Smooth micro-animations (fade-in, scale-in, slide-up transitions)
  • Dark mode sections with gradient overlays and glassmorphism accents
  • Google Fonts (Inter) for premium, modern typography
  • Custom SVG logo branding across Navbar, Footer, Login, Signup, and PWA icons

πŸ›  Tech Stack

Frontend

Technology Purpose
React 18 Component-based UI framework
Vite 5 Next-gen build tool & dev server
Tailwind CSS 3 Utility-first CSS styling
Zustand 4 Lightweight global state management
React Router 6 Client-side routing & navigation
React Hook Form + Zod Form handling with schema validation
Lucide React Beautiful, consistent icon system
Vite PWA Plugin Service Worker & manifest generation
Jetpack Compose Native Android UI Toolkit

Backend

Technology Purpose
Node.js Server-side JavaScript runtime
Express 4 Minimal, flexible web framework
MongoDB Atlas Cloud-hosted NoSQL database
Mongoose 8 Elegant ODM for MongoDB
JWT Stateless authentication tokens
Bcrypt.js Secure password hashing
Nodemailer SMTP email delivery (Gmail)
Cloudinary Cloud image storage & optimization
Multer Multipart file upload middleware
Web Push Server-side push notification dispatch
Express Rate Limit API abuse & brute-force prevention

Deployment

Service Purpose
Vercel Frontend hosting & CI/CD
MongoDB Atlas Managed database cluster
Cloudinary Image CDN & transformation

πŸ— Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                     CLIENT (React + Vite)                β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚  Zustand  β”‚  β”‚  Router   β”‚  β”‚  Forms   β”‚  β”‚   PWA   β”‚ β”‚
β”‚  β”‚  Store    β”‚  β”‚  v6       β”‚  β”‚  + Zod   β”‚  β”‚  Worker β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”˜ β”‚
β”‚        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜       β”‚
β”‚                       β”‚            β”‚                     β”‚
β”‚                 β”Œβ”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”             β”‚
β”‚                 β”‚     API Client (Axios)   β”‚             β”‚
β”‚                 β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜             β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                              β”‚ HTTPS / REST
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                   SERVER (Express.js)                    β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚   Auth MW  β”‚  β”‚  Rate Limitβ”‚  β”‚  Multer + Cloudinaryβ”‚ β”‚
β”‚  β”‚   (JWT)    β”‚  β”‚  Middleware β”‚  β”‚  Upload Pipeline    β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”˜  β””β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜                 β”‚
β”‚                         β”‚                                β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚              REST API Routes                        β”‚ β”‚
β”‚  β”‚  /auth Β· /items Β· /trades Β· /conversations          β”‚ β”‚
β”‚  β”‚  /ratings Β· /push Β· /upload Β· /admin Β· /contact     β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                         β”‚                                β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β–Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β” β”‚
β”‚  β”‚         MongoDB Atlas (Mongoose ODM)                β”‚ β”‚
β”‚  β”‚  Users Β· Items Β· Trades Β· Conversations             β”‚ β”‚
β”‚  β”‚  Messages Β· Ratings Β· PushSubscriptions             β”‚ β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜ β”‚
β”‚                                                          β”‚
β”‚  β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”   β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”  β”‚
β”‚  β”‚  Nodemailer SMTPβ”‚   β”‚  Web Push (VAPID Keys)      β”‚  β”‚
β”‚  β”‚  β†’ Gmail        β”‚   β”‚  β†’ Browser Notifications    β”‚  β”‚
β”‚  β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜   β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ”’ Security

Layer Implementation
Password Storage Bcrypt hashing with automatic salt rounds
Session Tokens JWT with configurable expiration, validated on every protected route
Email Verification SHA-256 hashed tokens with 1-hour TTL stored in MongoDB
Rate Limiting 3 verification attempts/hour, throttled login/signup endpoints
CORS Protection Whitelisted frontend origins only
File Uploads Server-side validation via Multer before Cloudinary forwarding
Data Privacy UIDs and emails hidden from public API responses
No-Reply Emails replyTo set to inactive address preventing unauthorized replies
Service Worker Safety Graceful getRegistration() probing to avoid UI deadlocks in restricted contexts

πŸ“„ Pages & Routes

Route Page Auth Required Description
/ Home ❌ Landing page with hero, features, and categories
/marketplace Marketplace ❌ Browse, search, and filter all listings
/items/:id Item Detail ❌ Full item page with images, seller info, trade CTA
/login Login ❌ Sign in with branded logo
/signup Signup ❌ Register with @cuchd.in email verification
/verify-email Email Verification ❌ Token-based email verification handler
/forgot-password Forgot Password ❌ Request a password reset link
/reset-password Reset Password ❌ Set a new password via tokenized link
/create-listing Create Listing βœ… Multi-image upload with category & pricing
/profile Profile βœ… View/edit profile, manage your listings
/trades Trade Dashboard βœ… Full negotiation dashboard with status tracking
/chat Chat βœ… Real-time messaging with trade context
/admin Admin Dashboard βœ… Platform-wide user & listing management
/contact Developer Contact βœ… Authenticated feedback form with auto-injected student data

βš™οΈ Prerequisites

Requirement Minimum Version
Node.js v16.0+
npm v8.0+
MongoDB Atlas Free tier (M0) or local instance
Google Account For Gmail SMTP App Password
Cloudinary Account Free tier for image uploads
Git Any recent version

πŸ’» Local Setup

1. Clone the Repository

git clone https://github.com/Pratik-kr21/cu-marketplace.git
cd cu-marketplace

2. Install Dependencies

# Frontend dependencies (from root)
npm install

# Backend dependencies
cd server
npm install
cd ..

3. Configure Environment Variables

Create the required .env files as described in the Environment Variables section below.

4. Start the Application

Open two terminal windows:

# Terminal 1 β€” Backend Server
cd server
node index.js
# β†’ Runs at http://localhost:4000
# Terminal 2 β€” Frontend Client
npm run dev
# β†’ Runs at http://localhost:5173

πŸ” Environment Variables

Frontend β€” .env (root directory)

VITE_API_URL=http://localhost:4000

Backend β€” server/.env

PORT=4000
MONGODB_URI=mongodb+srv://<user>:<password>@<cluster>.mongodb.net/<dbname>?retryWrites=true&w=majority
JWT_SECRET=your_super_secret_jwt_key

# Frontend URL (CORS & Email Links)
VITE_FRONTEND_URL=http://localhost:5173

# Gmail SMTP (Nodemailer)
EMAIL_USER=your_email@gmail.com
EMAIL_PASS=your_16_char_app_password

# Cloudinary
CLOUDINARY_CLOUD_NAME=your_cloud_name
CLOUDINARY_API_KEY=your_api_key
CLOUDINARY_API_SECRET=your_api_secret
πŸ“ How to Set Up Gmail App Password
  1. Log into your Google Account
  2. Go to Security β†’ Enable 2-Step Verification
  3. Search for App Passwords in account settings
  4. Generate a new App Password (e.g., name it CU Market)
  5. Copy the 16-character code (remove spaces) β†’ paste as EMAIL_PASS

πŸ’‘ Dev Bypass: If EMAIL_PASS is missing, the server will print a verification link directly in the terminal for local testing!

πŸ“ How to Set Up MongoDB Atlas
  1. Create a free cluster at MongoDB Atlas
  2. Create a Database User with a strong password
  3. Whitelist your IP in Network Access (use 0.0.0.0/0 for development)
  4. Copy the connection string and paste as MONGODB_URI

πŸ“‚ Project Structure

cu-marketplace/
β”œβ”€β”€ public/                      # Static assets, PWA manifest, favicons, logo SVGs
β”œβ”€β”€ index.html                   # App entry point with SEO meta tags
β”‚
β”œβ”€β”€ src/                         # ── React Frontend ──
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ auth/                # ProtectedRoute wrapper
β”‚   β”‚   β”œβ”€β”€ layout/              # Navbar, Footer
β”‚   β”‚   β”œβ”€β”€ marketplace/         # ItemGrid, ItemCard
β”‚   β”‚   └── ui/                  # Button, Input, Modal, Badge, Avatar,
β”‚   β”‚                            #   InstallPWA, NotificationBell, LazyImage
β”‚   β”œβ”€β”€ lib/
β”‚   β”‚   β”œβ”€β”€ api.js               # Axios HTTP client with JWT interceptors
β”‚   β”‚   β”œβ”€β”€ imageUpload.js       # Cloudinary upload utilities
β”‚   β”‚   β”œβ”€β”€ pushNotifications.js # Web Push subscription management
β”‚   β”‚   └── validators.js        # Zod schemas for form validation
β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ Home.jsx             # Landing page with hero & features
β”‚   β”‚   β”œβ”€β”€ Marketplace.jsx      # Browsable product grid with filters
β”‚   β”‚   β”œβ”€β”€ ItemDetail.jsx       # Full item view with trade actions
β”‚   β”‚   β”œβ”€β”€ CreateListing.jsx    # Multi-image listing creation form
β”‚   β”‚   β”œβ”€β”€ Login.jsx            # Branded sign-in page
β”‚   β”‚   β”œβ”€β”€ Signup.jsx           # University registration form
β”‚   β”‚   β”œβ”€β”€ VerifyEmail.jsx      # Email token verification
β”‚   β”‚   β”œβ”€β”€ ForgotPassword.jsx   # Password reset request
β”‚   β”‚   β”œβ”€β”€ ResetPassword.jsx    # New password submission
β”‚   β”‚   β”œβ”€β”€ Profile.jsx          # User profile & listing management
β”‚   β”‚   β”œβ”€β”€ TradeDashboard.jsx   # Trade negotiation hub
β”‚   β”‚   β”œβ”€β”€ Chat.jsx             # Real-time messaging
β”‚   β”‚   β”œβ”€β”€ AdminDashboard.jsx   # Admin controls panel
β”‚   β”‚   └── DeveloperContact.jsx # Authenticated feedback form
β”‚   β”œβ”€β”€ store/
β”‚   β”‚   └── authStore.js         # Zustand auth state & JWT persistence
β”‚   β”œβ”€β”€ App.jsx                  # Root component with routing & splash screen
β”‚   └── main.jsx                 # React DOM entry point
β”‚
└── server/                      # ── Express Backend ──
    β”œβ”€β”€ config/
    β”‚   └── db.js                # MongoDB Atlas connection
    β”œβ”€β”€ controllers/
    β”‚   β”œβ”€β”€ authController.js    # Register, login, verify, reset password
    β”‚   └── itemController.js    # CRUD item operations
    β”œβ”€β”€ middleware/
    β”‚   β”œβ”€β”€ auth.js              # JWT verification middleware
    β”‚   └── upload.js            # Multer + Cloudinary pipeline
    β”œβ”€β”€ models/
    β”‚   β”œβ”€β”€ User.js              # Student schema (name, UID, email, password)
    β”‚   β”œβ”€β”€ Item.js              # Listing schema (title, price, images, category)
    β”‚   β”œβ”€β”€ Trade.js             # Trade schema (buyer, seller, status, offers)
    β”‚   β”œβ”€β”€ Conversation.js      # Chat thread schema
    β”‚   β”œβ”€β”€ Message.js           # Individual message schema
    β”‚   β”œβ”€β”€ Rating.js            # Post-trade rating schema
    β”‚   └── PushSubscription.js  # Web push subscription storage
    β”œβ”€β”€ routes/
    β”‚   β”œβ”€β”€ auth.js              # /api/auth endpoints
    β”‚   β”œβ”€β”€ items.js             # /api/items CRUD
    β”‚   β”œβ”€β”€ trades.js            # /api/trades negotiation
    β”‚   β”œβ”€β”€ conversations.js     # /api/conversations messaging
    β”‚   β”œβ”€β”€ ratings.js           # /api/ratings feedback
    β”‚   β”œβ”€β”€ push.js              # /api/push subscription management
    β”‚   β”œβ”€β”€ upload.js            # /api/upload image handling
    β”‚   β”œβ”€β”€ admin.js             # /api/admin management
    β”‚   └── contact.js           # /api/contact developer feedback
    β”œβ”€β”€ utils/
    β”‚   β”œβ”€β”€ email.js             # Nodemailer SMTP transporter
    β”‚   └── cloudinary.js        # Cloudinary SDK configuration
    β”œβ”€β”€ index.js                 # Express server entry point
    └── vapid.json               # VAPID keys for Web Push

🌱 Roadmap

  • Advanced search with autocomplete suggestions
  • Seller verification badges
  • Automated E2E testing suite
  • Dark mode toggle across the entire app
  • Multi-language support (Hindi/English)

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

Pratik Kumar

LinkedIn GitHub


Β© 2026 CU Market Β· Designed & Developed by Pratik Kumar Β· All Rights Reserved

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Contributors

Languages