Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

1 Commit
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ† Gold Trading Platform

A professional-grade, full-stack gold trading Single-Page Application (SPA) built with React 18+ that allows users to monitor real-time market prices, execute trades, and manage their gold portfolio.

Gold Trading Platform Vite License

✨ Features

πŸ” Secure Authentication

  • User registration with comprehensive validation
  • Secure login/logout functionality
  • Protected routes with session management
  • 30-minute session timeout

πŸ“Š Real-Time Market Data

  • Live gold prices from Metals.live API (free, no API key required)
  • Automatic fallback to simulated data if API unavailable
  • Price tracking for 24K, 22K, and 18K gold
  • Interactive price history charts (7D, 30D, 90D views)
  • Real-time price updates every 5 seconds
  • Price change indicators with percentage

πŸ’° Transaction Management

  • Buy gold with real-time price calculations
  • Sell gold from your holdings
  • Automatic fee and tax calculations:
    • 2% processing fee
    • 3% GST
  • Transaction confirmation modals
  • Instant notifications for successful trades

πŸ“ˆ Portfolio Management

  • Real-time portfolio value tracking
  • Holdings breakdown by purity
  • Profit/Loss calculations with percentages
  • Average buy price tracking
  • Dynamic value updates as market prices change

πŸ“œ Transaction History

  • Complete transaction log
  • Filter by type (Buy/Sell/All)
  • Sort by date (newest/oldest)
  • Detailed transaction breakdown
  • Export-ready data structure

🎨 Premium UI/UX

  • Professional design with deep blue and gold color scheme
  • Fully responsive (Mobile, Tablet, Desktop)
  • Smooth animations and transitions
  • Loading states and error handling
  • Toast notifications
  • Accessibility compliant (WCAG AA)

πŸš€ Getting Started

Prerequisites

  • Node.js 16+ and npm
  • Modern web browser (Chrome, Firefox, Safari, Edge)

Installation

  1. Clone the repository

    git clone https://github.com/yourusername/gold-trading-platform.git
    cd gold-trading-platform
  2. Install dependencies

    npm install
  3. Run the development server

    npm run dev
  4. Open your browser Navigate to http://localhost:5173

πŸ“‘ Real-Time API Integration

The platform uses Metals.live API for real-time gold prices:

  • βœ… Free tier - No API key required
  • βœ… Real-time data - Updates every 5 seconds
  • βœ… Automatic fallback - Uses simulated data if API unavailable
  • βœ… USD to INR conversion - Automatic currency conversion

Optional: Enhanced API Support

For more features, you can add API keys for additional providers:

  1. Create a .env file in the root directory:

    VITE_GOLDAPI_KEY=your_goldapi_key_here
  2. Sign up for free API keys:

πŸ—οΈ Project Structure

gold-trading-platform/
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ components/
β”‚   β”‚   β”œβ”€β”€ auth/          # Authentication components
β”‚   β”‚   β”œβ”€β”€ dashboard/     # Dashboard components
β”‚   β”‚   β”œβ”€β”€ market/        # Market data components
β”‚   β”‚   β”œβ”€β”€ portfolio/     # Portfolio components
β”‚   β”‚   β”œβ”€β”€ transactions/  # Transaction components
β”‚   β”‚   └── ui/            # Reusable UI components
β”‚   β”œβ”€β”€ contexts/
β”‚   β”‚   β”œβ”€β”€ AuthContext.jsx       # Authentication state
β”‚   β”‚   β”œβ”€β”€ MarketContext.jsx     # Market data state
β”‚   β”‚   └── PortfolioContext.jsx  # Portfolio state
β”‚   β”œβ”€β”€ hooks/
β”‚   β”‚   β”œβ”€β”€ useLocalStorage.js
β”‚   β”‚   β”œβ”€β”€ useNotification.js
β”‚   β”‚   └── useTransactionCalculation.js
β”‚   β”œβ”€β”€ pages/
β”‚   β”‚   β”œβ”€β”€ LoginPage.jsx
β”‚   β”‚   β”œβ”€β”€ RegisterPage.jsx
β”‚   β”‚   β”œβ”€β”€ DashboardPage.jsx
β”‚   β”‚   β”œβ”€β”€ PortfolioPage.jsx
β”‚   β”‚   └── HistoryPage.jsx
β”‚   β”œβ”€β”€ utils/
β”‚   β”‚   β”œβ”€β”€ validation.js      # Input validation
β”‚   β”‚   β”œβ”€β”€ formatting.js      # Data formatting
β”‚   β”‚   β”œβ”€β”€ marketData.js      # Market data logic
β”‚   β”‚   └── goldPriceAPI.js    # API integration
β”‚   β”œβ”€β”€ styles/
β”‚   β”‚   └── variables.css      # CSS variables
β”‚   β”œβ”€β”€ App.jsx
β”‚   β”œβ”€β”€ main.jsx
β”‚   └── index.css
β”œβ”€β”€ public/
β”œβ”€β”€ package.json
└── vite.config.js

πŸ› οΈ Technology Stack

  • Frontend Framework: React 18+
  • Build Tool: Vite 5.0
  • Routing: React Router DOM 6+
  • Charts: Recharts
  • Date Handling: date-fns
  • State Management: Context API + Custom Hooks
  • Styling: CSS Modules + CSS Variables
  • Data Persistence: LocalStorage
  • API Integration: Metals.live API (free)

🎯 Key Features Explained

Authentication System

  • Email validation with regex patterns
  • Password strength requirements (8+ chars, uppercase, lowercase, number)
  • Input sanitization to prevent XSS attacks
  • Session management with automatic timeout

Market Data

  • Real-time price fetching from Metals.live API
  • Automatic USD to INR conversion (1 USD β‰ˆ β‚Ή83)
  • Price calculation for different purities:
    • 24K: 99.9% pure gold
    • 22K: 91.6% pure gold (24K Γ— 0.916)
    • 18K: 75% pure gold (24K Γ— 0.75)
  • 90-day price history with interactive charts

Transaction Processing

  • Real-time cost calculations
  • Fee structure:
    • Subtotal = Quantity Γ— Current Price
    • Processing Fee = 2% of subtotal
    • GST = 3% of (subtotal + fee) for buy, (subtotal - fee) for sell
  • Average buy price tracking for profit/loss calculations

Portfolio Calculations

  • Current Value = Quantity Γ— Current Market Price
  • Invested Value = Quantity Γ— Average Buy Price
  • Profit/Loss = Current Value - Invested Value
  • Profit/Loss % = (Profit/Loss / Invested Value) Γ— 100

πŸ“± Responsive Design

  • Mobile (320px+): Single column layout, stacked components
  • Tablet (768px+): Two-column grid, collapsible sidebar
  • Desktop (1024px+): Multi-column layout, full navigation

β™Ώ Accessibility

  • WCAG AA compliant (4.5:1 color contrast)
  • Semantic HTML5 elements
  • ARIA labels and roles
  • Keyboard navigation support
  • Screen reader compatible
  • Focus indicators on all interactive elements

πŸ”’ Security

  • Input sanitization (XSS prevention)
  • Client-side validation
  • Session timeout (30 minutes)
  • No sensitive data in LocalStorage
  • Secure password requirements

Note: This is a demo application. For production deployment:

  • Implement backend authentication (JWT tokens)
  • Use a database for data persistence
  • Add server-side validation
  • Implement HTTPS
  • Add CSRF protection
  • Use environment variables for API keys

πŸ“¦ Build for Production

npm run build

The optimized build will be in the dist/ directory.

πŸ§ͺ Testing

The application includes:

  • Form validation testing
  • Transaction calculation verification
  • Portfolio value calculations
  • Responsive layout testing
  • LocalStorage persistence testing

🀝 Contributing

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

πŸ“„ License

This project is licensed under the MIT License.

πŸ™ Acknowledgments

  • Gold price data from Metals.live
  • Icons and design inspiration from modern fintech applications
  • Built with ❀️ using React and Vite

πŸ“ž Support

For issues or questions, please open an issue on GitHub.


Made with πŸ’› for gold traders and investors

Releases

Packages

Contributors

Languages