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.
- Overview
- Features
- Technology Stack
- Prerequisites
- Installation
- Environment Variables
- Available Scripts
- Project Structure
- Key Features Documentation
- Authentication
- State Management
- Contributing
- License
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.
- π 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
- β‘ 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
- π 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
- 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
- Redux Toolkit (v2.6.0) - State management with Redux best practices
- React Redux (v9.0.4) - Official React bindings for Redux
- 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
- React Hook Form (v7.54.2) - Performant form validation library
- Supabase (v2.49.1) - Backend-as-a-Service platform
- Axios (v1.6.2) - Promise-based HTTP client
- 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
- ESLint (v8.55.0) - JavaScript linter
- PostCSS (v8.5.3) - CSS transformation tool
- Autoprefixer (v10.4.20) - PostCSS plugin to parse CSS
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)
-
Clone the repository
git clone https://github.com/jjf2009/ScrapCo_Frontend.git cd ScrapCo_Frontend -
Install dependencies
npm install
or
yarn install
-
Set up environment variables
Create a
.envfile in the root directory and add your configuration:VITE_SUPABASE_URL=your_supabase_url VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
-
Start the development server
npm run dev
or
yarn dev
-
Open your browser
Navigate to
http://localhost:5173(or the port shown in your terminal)
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.
In the project directory, you can run:
Starts the development server with hot module replacement (HMR).
- Opens on
http://localhost:5173 - Changes are reflected instantly
Builds the application for production.
- Creates optimized bundle in
distfolder - Minifies and optimizes all assets
- Ready for deployment
Locally previews the production build.
- Serves the
distfolder - Test production build before deployment
Runs ESLint to check code quality.
- Identifies code issues
- Enforces coding standards
- Helps maintain code quality
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
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
- 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
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
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
The application implements a dual authentication strategy:
-
Local Authentication: Using React Context API
- Stores user session in localStorage
- Provides sign-in and sign-out functionality
-
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.
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
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a new branch (
git checkout -b feature/AmazingFeature) - Make your changes
- Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
- Follow the existing code style
- Use ESLint for code linting
- Write meaningful commit messages
- Add comments for complex logic
- Test your changes thoroughly
This project is private and proprietary. All rights reserved.
For support, please contact the development team or open an issue in the repository.
Built with β€οΈ using React, Vite, and modern web technologies