Skip to content

About

A OLX Clone using MERN Stack

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

Β 

History

54 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Random OLX Clone

An OLX Clone built with the MERN Stack (MongoDB, Express.js, React, Node.js)

This project is a complete replica of the OLX website, featuring a real-time chat system, user authentication, and product listing capabilities.

🌐 Live Demo: https://random.loophub.in/


πŸ“‘ Table of Contents


✨ Features

  • πŸ” User Authentication - Email/Password & Google OAuth sign-in
  • πŸ“§ Email Verification - Secure account verification via Resend
  • πŸ“ Product Listings - Create, view, and manage product ads
  • πŸ–ΌοΈ Image Upload - Multiple image uploads via Cloudinary (up to 12 images)
  • πŸ’¬ Real-time Chat - Direct messaging between buyers and sellers
  • πŸ” Search & Filter - Search products by title, category, and location
  • πŸ‘€ User Profiles - View and edit user profiles
  • πŸ“ Location Support - Country, State, City selection for listings
  • πŸ›‘οΈ Admin Dashboard - Administrative controls for managing users and products
  • πŸ“± Responsive Design - Works on desktop and mobile devices

πŸ› οΈ Tech Stack

Frontend

Technology Version Purpose
React 18.2.0 UI Framework
React Router DOM 6.11.1 Client-side routing
Chakra UI 2.6.1 Component library
Bootstrap 5.2.3 CSS framework
Axios 1.4.0 HTTP client
Framer Motion 10.12.14 Animations
React Icons 5.5.0 Icon library

Backend

Technology Version Purpose
Node.js β‰₯24.0.0 Runtime
Express 5.2.1 Web framework
MongoDB/Mongoose 9.0.0 Database
Cloudinary 2.8.0 Image storage
JWT 9.0.2 Authentication
Bcrypt 6.0.0 Password hashing
Resend 6.5.2 Email service

πŸ“ Project Structure

Random-OLX-Clone/
β”œβ”€β”€ client/                          # React frontend
β”‚   β”œβ”€β”€ public/
β”‚   β”‚   β”œβ”€β”€ index.html
β”‚   β”‚   └── robots.txt
β”‚   └── src/
β”‚       β”œβ”€β”€ App.js                   # Main application component
β”‚       β”œβ”€β”€ App.css                  # Global styles
β”‚       β”œβ”€β”€ index.js                 # Entry point
β”‚       β”œβ”€β”€ components/
β”‚       β”‚   β”œβ”€β”€ auth/                # Authentication components
β”‚       β”‚   β”‚   β”œβ”€β”€ GoogleSignIn.js
β”‚       β”‚   β”‚   β”œβ”€β”€ Login.js
β”‚       β”‚   β”‚   └── Modallogin.js
β”‚       β”‚   β”œβ”€β”€ common/              # Shared/reusable components
β”‚       β”‚   β”‚   β”œβ”€β”€ Catagories.js
β”‚       β”‚   β”‚   β”œβ”€β”€ Loading.js
β”‚       β”‚   β”‚   β”œβ”€β”€ MaintenancePage.js
β”‚       β”‚   β”‚   β”œβ”€β”€ MapComponent.js
β”‚       β”‚   β”‚   β”œβ”€β”€ NotFound.js
β”‚       β”‚   β”‚   β”œβ”€β”€ NotListedAnything.js
β”‚       β”‚   β”‚   └── SearchNotFound.js
β”‚       β”‚   └── layout/              # Layout components
β”‚       β”‚       β”œβ”€β”€ CatNavbar.js
β”‚       β”‚       β”œβ”€β”€ Footer.js
β”‚       β”‚       └── Navbar.js
β”‚       β”œβ”€β”€ features/
β”‚       β”‚   β”œβ”€β”€ admin/               # Admin features
β”‚       β”‚   β”‚   └── AdminDashboard.js
β”‚       β”‚   β”œβ”€β”€ ads/                 # Product/Ad features
β”‚       β”‚   β”‚   β”œβ”€β”€ CatagoryView.js
β”‚       β”‚   β”‚   β”œβ”€β”€ MyadCards.js
β”‚       β”‚   β”‚   β”œβ”€β”€ Myads.js
β”‚       β”‚   β”‚   β”œβ”€β”€ PreviewAd.js
β”‚       β”‚   β”‚   └── ProductCards/
β”‚       β”‚   β”‚       β”œβ”€β”€ ProductCard.js
β”‚       β”‚   β”‚       └── ProductCardProfile.js
β”‚       β”‚   β”œβ”€β”€ chat/                # Chat features
β”‚       β”‚   β”‚   β”œβ”€β”€ FetchChat.js
β”‚       β”‚   β”‚   β”œβ”€β”€ Inbox.js
β”‚       β”‚   β”‚   β”œβ”€β”€ MyChat.js
β”‚       β”‚   β”‚   └── SendChat.js
β”‚       β”‚   β”œβ”€β”€ profile/             # User profile features
β”‚       β”‚   β”‚   β”œβ”€β”€ Profile.js
β”‚       β”‚   β”‚   β”œβ”€β”€ SearchProfile.js
β”‚       β”‚   β”‚   └── UserProfileEdit.js
β”‚       β”‚   β”œβ”€β”€ search/              # Search features
β”‚       β”‚   β”‚   β”œβ”€β”€ Searchbar.js
β”‚       β”‚   β”‚   └── SearchResults.js
β”‚       β”‚   └── sell/                # Selling features
β”‚       β”‚       β”œβ”€β”€ Addetails.js
β”‚       β”‚       β”œβ”€β”€ AdSuccess.js
β”‚       β”‚       β”œβ”€β”€ Details.js
β”‚       β”‚       β”œβ”€β”€ multiple-image-upload.component.js
β”‚       β”‚       β”œβ”€β”€ Price.js
β”‚       β”‚       β”œβ”€β”€ SelectLocation.js
β”‚       β”‚       β”œβ”€β”€ Sell.js
β”‚       β”‚       └── SellForm.js
β”‚       β”œβ”€β”€ pages/                   # Page components
β”‚       β”‚   β”œβ”€β”€ About.js
β”‚       β”‚   β”œβ”€β”€ Contact.js
β”‚       β”‚   β”œβ”€β”€ HelpCenter.js
β”‚       β”‚   β”œβ”€β”€ Home.js
β”‚       β”‚   β”œβ”€β”€ PrivacyPolicy.js
β”‚       β”‚   └── TermsOfService.js
β”‚       └── utils/
β”‚           └── imageUtils.js
β”‚
β”œβ”€β”€ server/                          # Express backend
β”‚   β”œβ”€β”€ index.js                     # Server entry point
β”‚   β”œβ”€β”€ package.json
β”‚   β”œβ”€β”€ adminRoutes/
β”‚   β”‚   └── adminRoutes.js
β”‚   β”œβ”€β”€ authRoutes/
β”‚   β”‚   β”œβ”€β”€ authRoutes.js
β”‚   β”‚   └── googleAuthRoutes.js
β”‚   β”œβ”€β”€ chatRoutes/
β”‚   β”‚   └── chatRoutes.js
β”‚   β”œβ”€β”€ contactRoutes/
β”‚   β”‚   └── contactRoutes.js
β”‚   β”œβ”€β”€ middleware/
β”‚   β”‚   β”œβ”€β”€ adminAuth.js
β”‚   β”‚   └── auth.js
β”‚   β”œβ”€β”€ models/
β”‚   β”‚   β”œβ”€β”€ Contact.js
β”‚   β”‚   β”œβ”€β”€ Message.js
β”‚   β”‚   β”œβ”€β”€ Product.js
β”‚   β”‚   β”œβ”€β”€ User.js
β”‚   β”‚   └── VerificationToken.js
β”‚   └── profileRoutes/
β”‚       └── profileRoutes.js
β”‚
β”œβ”€β”€ LICENSE
└── README.md

🌳 React Component Tree

graph TD
    A[App] --> B[Navbar]
    A --> C[Routes]
    A --> D[Footer]
    
    C --> E[Home]
    C --> F[PreviewAd]
    C --> G[CatagoryView]
    C --> H[SearchResults]
    C --> I[Profile Pages]
    C --> J[Sell Flow]
    C --> K[Chat]
    C --> L[Static Pages]
    C --> M[AdminDashboard]
    
    B --> B1[Searchbar]
    B --> B2[Modallogin]
    
    E --> E1[ProductCard]
    E --> E2[CatNavbar]
    
    F --> F1[ProductCardProfile]
    F --> F2[MapComponent]
    
    I --> I1[Profile]
    I --> I2[UserProfileEdit]
    I --> I3[SearchProfile]
    
    J --> J1[Sell]
    J --> J2[SellForm]
    J --> J3[AdSuccess]
    
    J2 --> J2A[Addetails]
    J2 --> J2B[Details]
    J2 --> J2C[Price]
    J2 --> J2D[SelectLocation]
    J2 --> J2E[MultipleImageUpload]
    
    K --> K1[MyChat]
    K --> K2[Inbox]
    K --> K3[FetchChat]
    K --> K4[SendChat]
    
    L --> L1[About]
    L --> L2[Contact]
    L --> L3[HelpCenter]
    L --> L4[PrivacyPolicy]
    L --> L5[TermsOfService]
    
    B2 --> B2A[Login]
    B2 --> B2B[GoogleSignIn]
Loading

Component Hierarchy Overview

graph LR
    subgraph Layout
        Navbar
        Footer
        CatNavbar
    end
    
    subgraph Auth
        Login
        GoogleSignIn
        Modallogin
    end
    
    subgraph Common
        Loading
        NotFound
        MaintenancePage
        MapComponent
        Catagories
    end
    
    subgraph Features
        subgraph Ads
            PreviewAd
            CatagoryView
            Myads
            ProductCard
        end
        
        subgraph Chat
            MyChat
            Inbox
            FetchChat
            SendChat
        end
        
        subgraph Profile
            ProfileView[Profile]
            UserProfileEdit
            SearchProfile
        end
        
        subgraph Sell
            SellPage[Sell]
            SellForm
            SelectLocation
            MultiImageUpload[MultipleImageUpload]
        end
    end
Loading

πŸ—ƒοΈ Database Models

User Schema

{
  email: String,          // Required, unique
  password: String,       // Hashed with bcrypt
  name: String,
  isEmailVerified: Boolean,
  isAdmin: Boolean,
  picture: String,        // Profile picture URL
  phonenumber: String,
  createdAt: Date
}

Product Schema

{
  useremail: String,      // Owner's email
  title: String,
  description: String,
  address: Array,         // [Country, State, City]
  price: String,
  productpic1-12: String, // Up to 12 image URLs
  owner: String,
  ownerpicture: String,
  catagory: String,
  subcatagory: String,
  createdAt: Date
}

Message Schema

{
  from: String,           // Sender email (ref: User)
  to: String,             // Receiver email (ref: User)
  product_id: ObjectId,   // Reference to Product
  message: String,
  createdAt: Date
}

Contact Schema

{
  name: String,
  email: String,
  subject: String,
  message: String,
  status: String,         // 'new', 'read', 'replied', 'resolved'
  createdAt: Date
}

πŸ”Œ API Routes

Authentication Routes

Method Endpoint Description
GET /api/check-status Check backend status
GET /auth-endpoint Verify authentication
POST /register User registration
POST /login User login
POST /google-auth Google OAuth login
POST /forgot-password Password reset request

Product Routes

Method Endpoint Description
POST /add_product Create new product listing
GET /getProducts Get all products
GET /getProductsbyCategory/:category Get products by category
GET /getProductsbyemail Get products by user email
GET /myads_view Get user's own ads
DELETE /myads_delete/:id Delete a product
POST /previewad/:id Get product details (authenticated)
POST /previewad/notloggedin/:id Get product details (public)
GET /search Search products

Chat Routes

Method Endpoint Description
POST /sendMessage Send a message
GET /api/new-messages Get new messages
GET /api/inbox Get inbox messages
GET /api/chat/:productId/:userEmail Get chat history

Profile Routes

Method Endpoint Description
POST /send-verification-email Send email verification OTP
POST /verify-email Verify email with OTP
PUT /update-profile Update user profile
GET /profile/:email Get user profile

Contact Routes

Method Endpoint Description
POST /api/contact Submit contact form

Admin Routes

Method Endpoint Description
GET /admin/check Check admin status
GET /admin/stats Get dashboard statistics
GET /admin/users Get all users
GET /admin/products Get all products
DELETE /admin/users/:id Delete a user
DELETE /admin/products/:id Delete a product

πŸ“¦ Categories

The platform supports the following product categories:

Category Subcategories
OLX Autos (Cars) Cars
Properties Houses & Apartments (Sale/Rent), Lands & Plots, Shops & Offices, PG & Guest Houses
Mobiles Mobile Phones, Accessories, Tablets
Jobs Data Entry, Sales, BPO, Driver, Teacher, IT Developer, and more
Bikes Motorcycles, Scooters, Spare Parts, Bicycles
Electronics & Appliances TVs, Computers, Cameras, Fridges, ACs, Washing Machines
Commercial Vehicles Commercial Vehicles, Spare Parts
Furniture Sofa & Dining, Beds & Wardrobes, Home Decor
Fashion Men, Women, Kids
Books, Sports & Hobbies Books, Gym & Fitness, Musical Instruments, Sports Equipment
Pets Fishes & Aquarium, Dogs, Pet Accessories
Services Electronics Repair, Education, Health & Beauty, Packers & Movers

πŸš€ Getting Started

Prerequisites

  • Node.js β‰₯ 24.0.0
  • MongoDB instance (local or Atlas)
  • Cloudinary account
  • Google OAuth credentials
  • Resend account (for email verification)

Installation

  1. Clone the repository

    git clone https://github.com/naveedqadir/Random-OLX-Clone.git
    cd Random-OLX-Clone
  2. Install dependencies

    # Install server dependencies
    cd server
    npm install
    
    # Install client dependencies
    cd ../client
    npm install
  3. Set up environment variables (see below)

  4. Start the development servers

    # Terminal 1 - Start server
    cd server
    npm run dev
    
    # Terminal 2 - Start client
    cd client
    npm start

Environment Variables

Client (client/.env)

REACT_APP_BACKEND_URL=http://localhost:5000
REACT_APP_CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name
REACT_APP_CLOUDINARY_UPLOAD_PRESET=your_cloudinary_upload_preset
REACT_APP_GOOGLE_CLIENT_ID=your_google_oauth_client_id

Server (server/.env)

# Server Configuration
PORT=5000

# Google OAuth
GOOGLE_CLIENT_ID=your-google-client-id
GOOGLE_CLIENT_SECRET=your-google-client-secret

# Cloudinary
CLOUDINARY_CLOUD_NAME=your-cloudinary-cloud-name
CLOUDINARY_API_KEY=your-cloudinary-api-key
CLOUDINARY_API_SECRET=your-cloudinary-api-secret

# Resend Email Configuration
RESEND_API_KEY=re_your_api_key_here
RESEND_FROM_EMAIL=Random <onboarding@resend.dev>

# MongoDB
MONGODB_URI=your-mongodb-uri

πŸ“œ Available Scripts

Client

Script Description
npm start Start development server
npm run build Build for production
npm test Run tests
npm run eject Eject from Create React App

Server

Script Description
npm start Start production server
npm run dev Start development server with nodemon

🀝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.


Made with ❀️ by naveedqadir

About

A OLX Clone using MERN Stack

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Used by

Contributors

Languages