Skip to content

A modern, full-featured web application for scrap material trading and management. ScrapCo provides a comprehensive platform for dealers to buy, sell, and manage scrap materials with an intuitive user interface.

Notifications You must be signed in to change notification settings

jjf2009/ScrapCo_Frontend

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

11 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

🌿 ScrapCo Frontend

A modern, full-featured web application for scrap material trading and management. ScrapCo provides a comprehensive platform for dealers to buy, sell, and manage scrap materials with an intuitive user interface.

πŸ“‹ Table of Contents

🎯 Overview

ScrapCo Frontend is a React-based single-page application (SPA) designed to facilitate the buying and selling of scrap materials. The platform provides features for dealers to browse available scrap materials, manage their cart, place orders, and track their transactions. Built with modern web technologies, it offers a responsive, fast, and user-friendly experience.

✨ Features

Core Features

  • πŸ” User Authentication: Secure login and registration system with protected routes
  • πŸ›’ Shopping Cart: Add, remove, and manage scrap materials in cart with quantity tracking
  • πŸ“¦ Product Catalog: Browse and search scrap materials with detailed information
  • πŸ’³ Checkout System: Complete checkout process with address and payment details
  • πŸ“‹ Order Management: View and track order history
  • πŸͺ Shop Interface: Dedicated shop page for browsing available materials
  • πŸ“ Location Services: Integration with Leaflet for map-based features
  • 🎨 Interactive UI: Beautiful animations and 3D elements using Spline

User Experience

  • ⚑ Fast Loading: Optimized with Vite for rapid development and build times
  • πŸ“± Responsive Design: Fully responsive layout using Tailwind CSS and DaisyUI
  • 🎭 Loading States: Smooth loading transitions and user feedback
  • πŸ”” Notifications: Sweet alerts for user actions and confirmations
  • 🎨 Modern UI Components: Beautiful components with Lucide React icons

Developer Features

  • πŸ”„ State Management: Redux Toolkit for predictable state management
  • 🌐 API Integration: Axios for HTTP requests and Supabase for backend services
  • πŸ›£οΈ Routing: React Router DOM for seamless navigation
  • πŸ“Š Data Visualization: Chart.js integration for analytics
  • 🎯 Form Handling: React Hook Form for efficient form management

πŸ› οΈ Technology Stack

Frontend Framework

  • React (v18.2.0) - UI library for building component-based interfaces
  • Vite (v5.0.10) - Next-generation frontend build tool
  • React Router DOM (v6.29.0) - Client-side routing

State Management

  • Redux Toolkit (v2.6.0) - State management with Redux best practices
  • React Redux (v9.0.4) - Official React bindings for Redux

Styling & UI

  • Tailwind CSS (v3.3.6) - Utility-first CSS framework
  • DaisyUI (v4.4.19) - Tailwind CSS component library
  • Lucide React (v0.294.0) - Beautiful, consistent icons
  • React Icons (v4.12.0) - Icon library

Forms & Validation

  • React Hook Form (v7.54.2) - Performant form validation library

Backend & Database

  • Supabase (v2.49.1) - Backend-as-a-Service platform
  • Axios (v1.6.2) - Promise-based HTTP client

Additional Libraries

  • Leaflet (v1.9.4) - Interactive maps
  • Leaflet Routing Machine (v3.2.12) - Routing and directions
  • Chart.js (v5.3.0 via react-chartjs-2) - Data visualization
  • SweetAlert2 (v11.17.2) - Beautiful, customizable alerts
  • Swiper (v11.2.4) - Modern mobile touch slider
  • Spline (v4.0.0) - 3D design tool integration
  • Firebase (v10.7.0) - Google's app development platform

Development Tools

  • ESLint (v8.55.0) - JavaScript linter
  • PostCSS (v8.5.3) - CSS transformation tool
  • Autoprefixer (v10.4.20) - PostCSS plugin to parse CSS

πŸ“‹ Prerequisites

Before you begin, ensure you have the following installed:

  • Node.js (v16.0.0 or higher)
  • npm (v7.0.0 or higher) or yarn (v1.22.0 or higher)
  • Git for version control
  • A modern web browser (Chrome, Firefox, Safari, or Edge)

πŸš€ Installation

  1. Clone the repository

    git clone https://github.com/jjf2009/ScrapCo_Frontend.git
    cd ScrapCo_Frontend
  2. Install dependencies

    npm install

    or

    yarn install
  3. Set up environment variables

    Create a .env file in the root directory and add your configuration:

    VITE_SUPABASE_URL=your_supabase_url
    VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
  4. Start the development server

    npm run dev

    or

    yarn dev
  5. Open your browser

    Navigate to http://localhost:5173 (or the port shown in your terminal)

πŸ” Environment Variables

The application requires the following environment variables to be set in your .env file:

Variable Description Required
VITE_SUPABASE_URL Your Supabase project URL Yes
VITE_SUPABASE_ANON_KEY Your Supabase anonymous/public API key Yes

Note: Never commit your .env file to version control. The .gitignore file is configured to exclude it.

πŸ“œ Available Scripts

In the project directory, you can run:

npm run dev

Starts the development server with hot module replacement (HMR).

  • Opens on http://localhost:5173
  • Changes are reflected instantly

npm run build

Builds the application for production.

  • Creates optimized bundle in dist folder
  • Minifies and optimizes all assets
  • Ready for deployment

npm run preview

Locally previews the production build.

  • Serves the dist folder
  • Test production build before deployment

npm run lint

Runs ESLint to check code quality.

  • Identifies code issues
  • Enforces coding standards
  • Helps maintain code quality

πŸ“ Project Structure

ScrapCo_Frontend/
β”œβ”€β”€ public/                     # Static assets
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ assets/                # Images, fonts, and other assets
β”‚   β”œβ”€β”€ components/            # Reusable UI components
β”‚   β”‚   β”œβ”€β”€ Footer.jsx
β”‚   β”‚   β”œβ”€β”€ Loading.jsx
β”‚   β”‚   β”œβ”€β”€ Login.jsx
β”‚   β”‚   β”œβ”€β”€ Navbar.jsx
β”‚   β”‚   └── Register.jsx
β”‚   β”œβ”€β”€ context/               # React Context providers
β”‚   β”‚   └── AuthContext.jsx   # Authentication context
β”‚   β”œβ”€β”€ pages/                 # Page components
β”‚   β”‚   β”œβ”€β”€ AddItem/          # Add scrap item pages
β”‚   β”‚   β”œβ”€β”€ dashboard/        # Dashboard pages
β”‚   β”‚   β”‚   β”œβ”€β”€ EditItem/
β”‚   β”‚   β”‚   β”œβ”€β”€ manageItems/
β”‚   β”‚   β”‚   └── users/
β”‚   β”‚   β”œβ”€β”€ home/             # Home page components
β”‚   β”‚   β”‚   β”œβ”€β”€ Banner.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Card.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ Home.jsx
β”‚   β”‚   β”‚   └── Recommended.jsx
β”‚   β”‚   β”œβ”€β”€ scrapitem/        # Scrap item related pages
β”‚   β”‚   β”‚   β”œβ”€β”€ CartPage.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ CheckoutPage.jsx
β”‚   β”‚   β”‚   β”œβ”€β”€ OrderPage.jsx
β”‚   β”‚   β”‚   └── SingleScrapMaterial.jsx
β”‚   β”‚   └── shop/             # Shop pages
β”‚   β”‚       β”œβ”€β”€ Banner.jsx
β”‚   β”‚       β”œβ”€β”€ Recommended.jsx
β”‚   β”‚       └── Shop.jsx
β”‚   β”œβ”€β”€ redux/                 # Redux state management
β”‚   β”‚   β”œβ”€β”€ features/         # Redux slices
β”‚   β”‚   β”‚   β”œβ”€β”€ cart/
β”‚   β”‚   β”‚   β”œβ”€β”€ dealer/
β”‚   β”‚   β”‚   β”œβ”€β”€ items/
β”‚   β”‚   β”‚   β”œβ”€β”€ orders/
β”‚   β”‚   β”‚   β”œβ”€β”€ points/
β”‚   β”‚   β”‚   └── shop/
β”‚   β”‚   └── store.js          # Redux store configuration
β”‚   β”œβ”€β”€ routers/              # Routing configuration
β”‚   β”‚   β”œβ”€β”€ PrivateRoute.jsx  # Protected route wrapper
β”‚   β”‚   └── router.jsx        # Main router configuration
β”‚   β”œβ”€β”€ utils/                # Utility functions
β”‚   β”œβ”€β”€ App.css               # Global styles
β”‚   β”œβ”€β”€ App.jsx               # Root component
β”‚   β”œβ”€β”€ index.css             # Tailwind directives
β”‚   β”œβ”€β”€ main.jsx              # Application entry point
β”‚   └── supabaseClient.js     # Supabase client configuration
β”œβ”€β”€ images/                    # Product and scrap images
β”‚   └── scrap/
β”œβ”€β”€ .env                       # Environment variables (not in git)
β”œβ”€β”€ .gitignore                # Git ignore rules
β”œβ”€β”€ eslint.config.js          # ESLint configuration
β”œβ”€β”€ index.html                # HTML entry point
β”œβ”€β”€ package.json              # Project dependencies
β”œβ”€β”€ postcss.config.js         # PostCSS configuration
β”œβ”€β”€ tailwind.config.js        # Tailwind CSS configuration
β”œβ”€β”€ vite.config.js            # Vite configuration
└── README.md                 # This file

🎨 Key Features Documentation

Authentication System

The application uses a context-based authentication system:

  • AuthContext: Manages user authentication state
  • PrivateRoute: Protects routes that require authentication
  • User data is stored in localStorage for persistence

Shopping Cart

  • Add to Cart: Add scrap materials with quantity
  • Update Quantity: Modify item quantities in cart
  • Remove Items: Remove individual items or clear entire cart
  • Price Calculation: Automatic total price calculation based on quantity

Routing Structure

The application uses the following route structure:

  • / - Home page with featured scrap materials
  • /shop - Browse all available scrap materials
  • /scrap/:id - Individual scrap material details
  • /cart - Shopping cart (protected)
  • /checkout - Checkout process (protected)
  • /orders - Order history (protected)
  • /login - User login
  • /register - User registration
  • /create - Add new scrap item

State Management with Redux

The application uses Redux Toolkit for state management with the following slices:

  • cart: Shopping cart state and actions
  • dealer: Dealer information and authentication
  • items: Scrap items catalog
  • orders: Order management
  • points: Points/rewards system
  • shop: Shop-related state

πŸ”’ Authentication

The application implements a dual authentication strategy:

  1. Local Authentication: Using React Context API

    • Stores user session in localStorage
    • Provides sign-in and sign-out functionality
  2. Supabase Authentication: Backend authentication

    • Integrated with Supabase for secure authentication
    • Dealer management through API

Protected routes require authentication to access cart, checkout, and order pages.

🎯 State Management

Redux Toolkit is used for global state management:

// Example: Adding item to cart
import { useDispatch } from 'react-redux';
import { addToCart } from './redux/features/cart/cartSlice';

const dispatch = useDispatch();
dispatch(addToCart(item));

The store is configured in src/redux/store.js and includes:

  • RTK Query for API calls
  • Middleware for async operations
  • DevTools integration for debugging

🀝 Contributing

Contributions are welcome! Please follow these steps:

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

Coding Standards

  • Follow the existing code style
  • Use ESLint for code linting
  • Write meaningful commit messages
  • Add comments for complex logic
  • Test your changes thoroughly

πŸ“„ License

This project is private and proprietary. All rights reserved.

πŸ“ž Support

For support, please contact the development team or open an issue in the repository.


Built with ❀️ using React, Vite, and modern web technologies

About

A modern, full-featured web application for scrap material trading and management. ScrapCo provides a comprehensive platform for dealers to buy, sell, and manage scrap materials with an intuitive user interface.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages