Skip to content

anis009/sinaEcom-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

20 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

SinaEcom Client

A modern, full-featured e-commerce web application built with React that enables businesses to sell their products online. This is the client-side application that provides an intuitive shopping experience for customers and a comprehensive admin panel for store management.

🌐 Live Demo: https://sina-ecom.web.app/

πŸ“‹ Table of Contents

✨ Features

Customer Features

  • Product Catalog: Browse products with detailed descriptions, prices, images, and ratings
  • Search Functionality: Search products by name with real-time filtering
  • Category Navigation: Filter products by categories
  • Product Details: View comprehensive product information with image magnification
  • Shopping Cart: Add, update, and remove items from cart with quantity management
  • User Authentication: Secure signup/login system with JWT tokens
  • User Profile: Manage personal information and view order history
  • Password Recovery: Forgot password and reset password functionality
  • Shipping Information: Enter and save shipping addresses
  • Order Placement: Complete checkout process with order confirmation
  • Payment Integration: Secure payment processing
  • Product Reviews: Leave ratings and reviews for purchased products
  • Responsive Design: Fully responsive UI that works on all devices

Admin Features

  • Admin Dashboard: Dedicated admin panel with protected routes
  • Product Management: Add, edit, and manage products
  • Category Management: Create and organize product categories
  • Inventory Control: Track and update stock levels
  • Rich Text Editor: Use Draft.js editor for product descriptions
  • Image Upload: Upload product images via ImgBB API integration
  • Order Management: View and manage customer orders

πŸ›  Technology Stack

Frontend Framework & Libraries

  • React 17.0.2 - Core UI library
  • React Router DOM 6.4.5 - Client-side routing and navigation
  • Redux 4.1.2 - State management
  • React Redux 7.2.6 - React bindings for Redux
  • Redux Thunk 2.4.1 - Async Redux middleware
  • Redux DevTools Extension - Development debugging tools

UI Components & Styling

  • React Bootstrap 2.1.2 - UI component library
  • Bootstrap 4.6.0 - CSS framework
  • Ant Design 4.18.5 - Enterprise-level UI design system
  • Tailwind CSS 2.2.19 - Utility-first CSS framework
  • Framer Motion 6.2.7 - Animation library
  • React Icons 4.7.1 - Icon library

Form Handling & Validation

  • React Hook Form 7.43.4 - Form validation and management
  • React Hot Toast 2.4.0 - Toast notifications

Rich Text & Media

  • Draft.js 0.11.7 - Rich text editor framework
  • TinyMCE React 3.13.0 - WYSIWYG editor
  • React Image Magnify 2.7.4 - Product image zoom
  • React Slick 0.29.0 - Carousel/slider component
  • Slick Carousel 1.8.1 - Carousel base library

HTTP & API

Additional Libraries

  • JSON Web Token 8.5.1 - JWT token handling
  • bcryptjs 2.4.3 - Password hashing
  • SweetAlert2 11.3.10 - Beautiful alert dialogs
  • React Loader Spinner 5.3.4 & React Spinners 0.11.0 - Loading indicators

Development Tools

  • React Scripts 5.0.0 - Create React App build tooling
  • Firebase Hosting - Deployment platform

πŸ“ Project Structure

sinaEcom-client/
β”œβ”€β”€ public/                      # Static public assets
β”‚   β”œβ”€β”€ index.html              # HTML template
β”‚   β”œβ”€β”€ manifest.json           # PWA manifest
β”‚   β”œβ”€β”€ robots.txt              # SEO robots file
β”‚   └── images/                 # Public images
β”‚
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ index.js                # Application entry point
β”‚   β”œβ”€β”€ App.js                  # Main App component
β”‚   β”œβ”€β”€ store.js                # Redux store configuration
β”‚   β”œβ”€β”€ index.css               # Global styles
β”‚   β”œβ”€β”€ App.css                 # App component styles
β”‚   └── customizeCss.css        # Custom styling
β”‚
β”‚   β”œβ”€β”€ actions/                # Redux action creators
β”‚   β”‚   β”œβ”€β”€ cartActions.js      # Cart operations
β”‚   β”‚   β”œβ”€β”€ categoriesAction.js # Category operations
β”‚   β”‚   β”œβ”€β”€ orderActions.js     # Order operations
β”‚   β”‚   β”œβ”€β”€ payActions.js       # Payment operations
β”‚   β”‚   β”œβ”€β”€ productActions.js   # Product CRUD operations
β”‚   β”‚   └── userActions.js      # User authentication & profile
β”‚
β”‚   β”œβ”€β”€ reducers/               # Redux reducers
β”‚   β”‚   β”œβ”€β”€ cartReducers.js
β”‚   β”‚   β”œβ”€β”€ categoriesReducers.js
β”‚   β”‚   β”œβ”€β”€ orderReducers.js
β”‚   β”‚   β”œβ”€β”€ payReducers.js
β”‚   β”‚   β”œβ”€β”€ productReducers.js
β”‚   β”‚   └── userReducers.js
β”‚
β”‚   β”œβ”€β”€ constants/              # Redux action constants
β”‚   β”‚   β”œβ”€β”€ cartConstant.js
β”‚   β”‚   β”œβ”€β”€ CategoriesConstant.js
β”‚   β”‚   β”œβ”€β”€ orderConstant.js
β”‚   β”‚   β”œβ”€β”€ payConstants.js
β”‚   β”‚   β”œβ”€β”€ productConstants.js
β”‚   β”‚   β”œβ”€β”€ urlConstant.js      # API endpoint configuration
β”‚   β”‚   └── userConstants.js
β”‚
β”‚   β”œβ”€β”€ components/             # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ Alert.js            # Alert component
β”‚   β”‚   β”œβ”€β”€ Card.js             # Card component
β”‚   β”‚   β”œβ”€β”€ Loader.js           # Loading spinner
β”‚   β”‚   β”œβ”€β”€ Message.js          # Message display
β”‚   β”‚   β”œβ”€β”€ Navbar.js           # Navigation bar
β”‚   β”‚   β”œβ”€β”€ Product.js          # Product card
β”‚   β”‚   β”œβ”€β”€ ProductList.js      # Product grid
β”‚   β”‚   β”œβ”€β”€ Rating.js           # Star rating display
β”‚   β”‚   β”œβ”€β”€ SideBar.js          # Sidebar component
β”‚   β”‚   └── Time.js             # Time display utility
β”‚
β”‚   β”œβ”€β”€ Layout/                 # Layout components
β”‚   β”‚   β”œβ”€β”€ AdminLayout/        # Admin panel layout
β”‚   β”‚   β”‚   β”œβ”€β”€ AdminLayout.js
β”‚   β”‚   β”‚   └── Admin.css
β”‚   β”‚   └── Main/               # Main app layout
β”‚   β”‚       └── Main.js
β”‚
β”‚   β”œβ”€β”€ Router/                 # Routing configuration
β”‚   β”‚   β”œβ”€β”€ PrivateRoutes/      # Protected route components
β”‚   β”‚   β”‚   └── PrivateRoutes.js
β”‚   β”‚   └── Routes/             # Route definitions
β”‚   β”‚       └── Routes.js
β”‚
β”‚   β”œβ”€β”€ screens/                # Page components
β”‚   β”‚   β”œβ”€β”€ HomeScreen.js       # Homepage with slider & products
β”‚   β”‚   β”œβ”€β”€ CartScreen.js       # Shopping cart
β”‚   β”‚   β”œβ”€β”€ ProductDetailsScreen.js  # Product detail page
β”‚   β”‚   β”œβ”€β”€ SearchScreen.js     # Search results
β”‚   β”‚   β”œβ”€β”€ ShippingScreen.js   # Shipping address form
β”‚   β”‚   β”œβ”€β”€ PayScreen.js        # Payment selection
β”‚   β”‚   β”œβ”€β”€ PlaceOrderScreen.js # Order confirmation
β”‚   β”‚   β”œβ”€β”€ SigninScreen.js     # User login
β”‚   β”‚   β”œβ”€β”€ SignupScreen.js     # User registration
β”‚   β”‚   β”œβ”€β”€ ForgotPasswordScreen.js  # Password recovery
β”‚   β”‚   β”œβ”€β”€ ResetPasswordScreen.js   # Password reset
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ admin/              # Admin panel screens
β”‚   β”‚   β”‚   β”œβ”€β”€ AddProductScreen.js   # Add new product
β”‚   β”‚   β”‚   β”œβ”€β”€ EditProductScreen.js  # Edit product
β”‚   β”‚   β”‚   β”œβ”€β”€ ProductScreen.js      # Product management
β”‚   β”‚   β”‚   └── AddCategory.js        # Category management
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ Profile/            # User profile screens
β”‚   β”‚   β”‚   β”œβ”€β”€ ProfileScreen.js      # User profile page
β”‚   β”‚   β”‚   β”œβ”€β”€ MyOrdersScreen.js     # Order history
β”‚   β”‚   β”‚   └── UserScreen.js         # User management
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ Categories/         # Category screens
β”‚   β”‚   β”‚   β”œβ”€β”€ Categories.js         # Category listing
β”‚   β”‚   β”‚   └── Category.js           # Single category
β”‚   β”‚   β”‚
β”‚   β”‚   β”œβ”€β”€ Footer/             # Footer component
β”‚   β”‚   β”‚   └── FooterScreen.js
β”‚   β”‚   β”‚
β”‚   β”‚   └── Slider/             # Homepage slider
β”‚   β”‚       └── HomeSlider.js
β”‚
β”œβ”€β”€ firebase.json               # Firebase hosting configuration
β”œβ”€β”€ package.json                # Dependencies and scripts
└── README.md                   # Project documentation

πŸš€ Getting Started

Prerequisites

  • Node.js (v14 or higher)
  • npm or yarn package manager
  • A running backend server (see API Integration section)

Installation

  1. Clone the repository

    git clone https://github.com/anis009/sinaEcom-client.git
    cd sinaEcom-client
  2. Install dependencies

    npm install
  3. Configure environment variables Create a .env file in the root directory (see Environment Variables section)

  4. Start the development server

    npm start
  5. Open your browser Navigate to http://localhost:3000

πŸ” Environment Variables

Create a .env file in the root directory with the following variables:

# ImgBB API for image uploads (required for admin panel)
REACT_APP_imgbb_key=your_imgbb_api_key_here

To get an ImgBB API key:

  1. Visit https://api.imgbb.com/
  2. Sign up for a free account
  3. Generate your API key
  4. Add it to your .env file

πŸ“œ Available Scripts

In the project directory, you can run:

npm start

Runs the app in development mode at http://localhost:3000. The page will reload when you make changes.

npm run build

Builds the app for production to the build folder. Optimizes the build for best performance.

npm test

Launches the test runner in interactive watch mode.

npm run eject

Note: this is a one-way operation! Ejects from Create React App for full configuration control.

npm run add-tailwind

Processes Tailwind CSS from src/tailwind.css to src/styles.css.

🎯 Key Functionalities

Authentication System

  • JWT-based authentication with secure token storage
  • User registration with email and password validation
  • Login with credential verification
  • Password recovery via email token
  • Password reset functionality
  • User profile updates
  • Persistent login state using localStorage

Shopping Cart

  • Add/remove products with quantity selection
  • Real-time cart total calculation
  • Cart persistence in localStorage
  • Visual cart badge with item count
  • Quantity adjustment in cart view

Product Management

  • Product listing with pagination
  • Category-based filtering
  • Search functionality with URL parameters
  • Product detail view with image magnification
  • Rating and review system
  • Related products display
  • Top-rated products section

Order Processing

  1. Add items to cart
  2. Proceed to checkout
  3. Enter shipping information
  4. Select payment method
  5. Review order details
  6. Place order and receive confirmation
  7. Track order in profile

Admin Panel

  • Protected routes (admin-only access)
  • Add new products with rich text descriptions
  • Upload product images to ImgBB
  • Manage product inventory
  • Create and manage categories
  • View and manage all orders
  • Edit existing products

πŸ”Œ API Integration

Backend Server

API Endpoints Used

User Endpoints:

  • POST /api/users - User registration
  • POST /api/users/login - User login
  • PUT /api/users/ - Update user profile
  • POST /api/users/forgotpassword - Request password reset
  • POST /api/users/resetpassword/:token - Reset password

Product Endpoints:

  • GET /api/products - Get all products
  • GET /api/products/:id - Get single product
  • POST /api/products - Create product (admin)
  • PUT /api/products/:id - Update product (admin)
  • POST /api/products/:id/reviews - Add product review

Category Endpoints:

  • GET /api/categories - Get all categories
  • POST /api/categories - Create category (admin)

Order Endpoints:

  • POST /api/orders - Create order
  • GET /api/orders/myorders - Get user orders
  • GET /api/orders/:id - Get single order

Payment Endpoints:

  • POST /api/payment - Process payment

πŸ—„ State Management

Redux Store Structure

{
  userSignup: {
    userInfo: { _id, name, email, token, isAdmin },
    loading, error
  },
  userLogin: { loading, error },
  updateUser: { loading, success, error },
  cart: {
    cartItems: [{ product, name, image, price, qty, countInStock }]
  },
  categories: {
    categories: [{ _id, name, image }],
    loading, error
  },
  order: { order, loading, success, error },
  userOrder: { orders: [], loading, error },
  payment: { loading, success, error },
  getSingleOrder: { order, loading, error },
  sentToken: { loading, success, error },
  resetPassword: { loading, success, error },
  addProduct: { loading, success, error },
  editProduct: { loading, success, error },
  getProducts: {
    products: [], loading, error, pages, page
  },
  getTopProducts: { products: [], loading, error },
  getSingleProduct: { product, loading, error },
  addProductReview: { loading, success, error }
}

Middleware

  • Redux Thunk: Handles async actions for API calls
  • Redux DevTools: Browser extension integration for debugging

🚒 Deployment

Firebase Hosting

The application is deployed on Firebase Hosting:

  1. Install Firebase CLI

    npm install -g firebase-tools
  2. Login to Firebase

    firebase login
  3. Build the application

    npm run build
  4. Deploy to Firebase

    firebase deploy

Firebase Configuration

The firebase.json file is configured to:

  • Serve the build folder as the public directory
  • Rewrite all routes to index.html for SPA routing

πŸ“ Code Features

Component Organization

  • Separation of concerns with dedicated folders for screens, components, and layouts
  • Reusable components for consistency across the app
  • Custom hooks for shared logic

Error Handling

  • Centralized error messages using Message component
  • Toast notifications for user feedback
  • Form validation with error states

Performance Optimization

  • Lazy loading with React.lazy (if implemented)
  • Memoization of expensive computations
  • Optimized re-renders with proper state management

Security

  • JWT token authentication
  • Protected admin routes
  • Password hashing (bcryptjs)
  • Secure API communication

🀝 Contributing

Contributions are welcome! Please follow these steps:

  1. Fork the repository
  2. Create a 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 part of the MERN stack e-commerce application suite.

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

Anis Mola

πŸ™ Acknowledgments

  • Backend API: https://sina-ecom-server.vercel.app
  • Deployed on Firebase Hosting
  • Built with Create React App
  • UI components from Bootstrap, Ant Design, and custom implementations

Note: This is the client-side application. Make sure the backend server is running for full functionality. For the backend repository, please visit the SinaEcom server repository.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published