Skip to content

hanyucrocks/Amazon-Hackon

Repository files navigation

🏦 VaultX - Secure Payment Platform

Amazon HackOn Season 5 Submission
A middleware solution integrated with Amazon Pay with SmartCoins rewards and Offline Payment Storing (SnapPay).

🌐 Vercel Link

Live Demo: VaultX - Secure Payment Platform Default PIN: 123456

Presentation: Team What-If - VaultX Project Presentation

Demo Video in YT: Demo Video of showcasing the entire prototype and its functionalities

Next.js TypeScript Tailwind CSS AWS DynamoDB AWS Lambda

πŸ“‹ Table of Contents

πŸš€ Overview

VaultX is a middleware prototype solution integrated with Amazon Pay, to help users experience a more smoother payment experience. Equipped with SnapPay, Our Offline Payment system with Smartcoins that refund whenever there is a price drop post-purchase, VaultX is a solution that not only benefits Tier 2/3 Rural Users who have low connectivity of internet, but also those people who have a hard time buying products with digital money.

🎯 Project Goals

  • Secure Payments: Biometric authentication and PIN-based security
  • Smart Rewards: SmartCoins system for customer loyalty
  • Trust Scoring: Advanced seller trust and safety metrics
  • Offline-First: Robust offline payment processing
  • Price Intelligence: Real-time price tracking and history
  • Automated Refunds: AWS Lambda-powered automatic refund processing

✨ Features

πŸ’³ Payment Features

  • Biometric Authentication: Face-ID and PIN-based security
  • Offline Processing: Payments work without internet connection
  • Transaction Sync: Automatic synchronization when online
  • Multi-factor Security: PIN lockout protection and retry limits

πŸͺ™ SmartCoins System

  • Refund Rewards: Earn SmartCoins from product refunds
  • Balance Tracking: Real-time SmartCoins balance
  • Transaction History: Complete refund and reward history
  • Price History Access: Direct access to product price charts

πŸ›‘οΈ Trust & Safety

  • Seller Trust Scoring: Multi-dimensional trust analysis
  • Safe Shopping Score: Comprehensive safety metrics
  • Price Drop Tracking: Monitor product price changes
  • Refund Rate Analysis: Seller reliability indicators

πŸ“Š Analytics & Insights

  • Price History Dashboard: Interactive price charts
  • Seller Performance: Detailed seller analytics
  • Transaction Monitoring: Real-time payment tracking
  • Network Status: Connectivity monitoring

πŸ€– Automated Refund Processing

  • Price Change Detection: AWS Lambda monitors product price changes
  • Automatic Refund Calculation: Intelligent refund amount computation
  • Backend Integration: Seamless refund processing through API
  • Frontend Updates: Real-time SmartCoins balance updates
  • Transaction History: Complete audit trail of automatic refunds

πŸ—οΈ Architecture

VaultX/
β”œβ”€β”€ app/                          # Next.js App Router
β”‚   β”œβ”€β”€ api/                      # API Routes
β”‚   β”‚   β”œβ”€β”€ products/             # Product management
β”‚   β”‚   β”œβ”€β”€ smartcoins/           # SmartCoins system
β”‚   β”‚   β”œβ”€β”€ seller-trust/         # Trust scoring
β”‚   β”‚   └── transactions/         # Payment processing
β”‚   β”œβ”€β”€ components/               # React components
β”‚   β”œβ”€β”€ dashboard/                # Analytics dashboard
β”‚   β”œβ”€β”€ vaultx/                   # Main VaultX interface
β”‚   └── auth/                     # Authentication pages
β”œβ”€β”€ components/                   # Shared UI components
β”œβ”€β”€ lib/                          # Utility functions
β”œβ”€β”€ public/                       # Static assets
└── styles/                       # Global styles

AWS Infrastructure/
β”œβ”€β”€ DynamoDB/                     # NoSQL database
β”‚   β”œβ”€β”€ products/                 # Product data
β”‚   β”œβ”€β”€ price_history/            # Price change tracking
β”‚   β”œβ”€β”€ refunds/                  # Refund records
β”‚   └── transactions/             # Payment transactions
β”œβ”€β”€ Lambda Functions/             # Serverless processing
β”‚   β”œβ”€β”€ price-change-monitor/     # Price change detection
β”‚   β”œβ”€β”€ refund-calculator/        # Refund amount computation
β”‚   └── smartcoins-updater/       # Balance updates

πŸ› οΈ Tech Stack

Frontend

  • Next.js 15.2.4 - React framework with App Router
  • TypeScript 5.0 - Type-safe JavaScript
  • Tailwind CSS 3.4.17 - Utility-first CSS framework
  • Radix UI - Accessible component primitives
  • Lucide React - Beautiful icons
  • Chart.js - Interactive charts and graphs

Backend & Database

  • AWS DynamoDB - NoSQL database for scalability
  • AWS Lambda - Serverless functions for automated processing
  • Next.js API Routes - Serverless API endpoints
  • IndexedDB - Client-side data storage
  • LocalStorage - Fallback storage

Authentication & Security

  • Biometric Auth - Face-ID and PIN security
  • PIN Management - Secure PIN storage and validation
  • Offline Security - Local data encryption

Development Tools

  • ESLint - Code linting
  • PostCSS - CSS processing
  • Autoprefixer - CSS vendor prefixing

πŸ“¦ Installation

Prerequisites

  • Node.js 18+
  • npm or pnpm
  • AWS Account (for DynamoDB)

Setup Instructions

  1. Clone the repository

    git clone https://github.com/yourusername/Amazon-HackOn-Season-5.git
    cd Amazon-HackOn-Season-5
  2. Install dependencies

    npm install (if this fails then use npm install -legacy -peer -deps)
    # or
    pnpm install
  3. Environment Configuration Create a .env.local file:

    AWS_REGION=eu-north-1
    AWS_ACCESS_KEY_ID=your_access_key
    AWS_SECRET_ACCESS_KEY=your_secret_key
  4. Run the development server

    npm run dev
    # or
    pnpm dev
  5. Open your browser Navigate to http://localhost:3000

πŸ”§ Configuration

AWS DynamoDB Setup

  1. Create DynamoDB Tables

    # Products table
    aws dynamodb create-table \
      --table-name products \
      --attribute-definitions AttributeName=id,AttributeType=N \
      --key-schema AttributeName=id,KeyType=HASH \
      --billing-mode PAY_PER_REQUEST
    
    # Price history table
    aws dynamodb create-table \
      --table-name price_history \
      --attribute-definitions AttributeName=id,AttributeType=S \
      --key-schema AttributeName=id,KeyType=HASH \
      --billing-mode PAY_PER_REQUEST
    
    # Refunds table
    aws dynamodb create-table \
      --table-name refunds \
      --attribute-definitions AttributeName=id,AttributeType=S \
      --key-schema AttributeName=id,KeyType=HASH \
      --billing-mode PAY_PER_REQUEST
    
    # Transactions table
    aws dynamodb create-table \
      --table-name transactions \
      --attribute-definitions AttributeName=id,AttributeType=S \
      --key-schema AttributeName=id,KeyType=HASH \
      --billing-mode PAY_PER_REQUEST
  2. Configure IAM Permissions Ensure your AWS credentials have DynamoDB read/write permissions.

Seller Trust Modal

// Comprehensive seller trust analysis
<SellerDetailModal 
  sellerId="seller_001"
  isOpen={true}
  onClose={handleClose}
/>

πŸš€ Usage

For Customers

  1. Browse Products: Visit the homepage to see featured products
  2. Make Payment: Click "Pay Now" and authenticate with PIN
  3. Earn SmartCoins: Get rewarded for refunds and price drops
  4. Track History: View transaction and price history

For Developers

  1. API Integration: Use the RESTful API endpoints
  2. Custom Components: Extend the UI component library
  3. Database Operations: Work with DynamoDB tables
  4. Authentication: Implement custom auth flows

πŸ“Š API Endpoints

Products

  • GET /api/products/[id] - Get product details
  • PATCH /api/products/[id]/price - Update product price
  • POST /api/products/[id]/price-drop - Process price drop
  • GET /api/products/[id]/price-history - Get price history

SmartCoins

  • GET /api/smartcoins?userId={id} - Get user's SmartCoins balance

Seller Trust

  • GET /api/seller-trust - Get all sellers with trust scores
  • GET /api/seller-trust?sellerId={id} - Get specific seller details

Transactions

  • POST /api/transactions - Process payment transactions

🎯 Key Components

BiometricAuth Component

// Secure PIN-based authentication with offline support
<BiometricAuth 
  onSuccess={handleTransactionSuccess}
  onError={handleError}
  amount={100}
  productId="123"
/>

Price History Dashboard

// Interactive price charts with real-time data
<PriceHistoryChart 
  productId="123"
  data={priceHistoryData}
/>

Seller Trust Modal

πŸ” Security Features

Authentication

  • 6-digit PIN: Secure numeric authentication
  • Lockout Protection: 5 failed attempts trigger 20-second lockout
  • Biometric Support: Face-ID authentication ready
  • Offline Security: Local data protection

Data Protection

  • Encrypted Storage: Sensitive data encryption
  • Secure APIs: Parameterized queries prevent injection
  • Network Security: HTTPS enforcement
  • Session Management: Secure session handling

Privacy

  • User Anonymization: User ID generation
  • Data Minimization: Only necessary data collection
  • Local Processing: Offline-first approach

πŸ€– AWS Lambda Configuration

Automated Refund Processing Setup

  1. Create Lambda Functions

    # Price Change Monitor Lambda
    aws lambda create-function \
      --function-name vaultx-price-change-monitor \
      --runtime nodejs18.x \
      --handler index.handler \
      --role arn:aws:iam::YOUR_ACCOUNT:role/lambda-execution-role \
      --zip-file fileb://price-change-monitor.zip
    
    # Refund Calculator Lambda
    aws lambda create-function \
      --function-name vaultx-refund-calculator \
      --runtime nodejs18.x \
      --handler index.handler \
      --role arn:aws:iam::YOUR_ACCOUNT:role/lambda-execution-role \
      --zip-file fileb://refund-calculator.zip
    
    # SmartCoins Updater Lambda
    aws lambda create-function \
      --function-name vaultx-smartcoins-updater \
      --runtime nodejs18.x \
      --handler index.handler \
      --role arn:aws:iam::YOUR_ACCOUNT:role/lambda-execution-role \
      --zip-file fileb://smartcoins-updater.zip
  2. Lambda Function Workflow

    // Price Change Monitor Lambda
    export const handler = async (event: any) => {
      const { productId, oldPrice, newPrice } = event.detail;
      
      // Check if refund is applicable
      if (newPrice < oldPrice) {
        const refundAmount = oldPrice - newPrice;
        
        // Trigger refund calculation
        await lambda.invoke({
          FunctionName: 'vaultx-refund-calculator',
          Payload: JSON.stringify({ productId, refundAmount })
        });
      }
    };
  3. Environment Variables

    # Lambda Environment Variables
    DYNAMODB_TABLE_NAME=vaultx_refunds
    API_ENDPOINT=https://your-api.vercel.app/api
    SMARTCOINS_RATE=1.0

πŸ“± Screenshots

Main Interface

VaultX Main Interface

SmartCoins Dashboard

SmartCoins Dashboard

Price History Charts

Price History

Seller Trust Analysis

Seller Trust

πŸ™ Acknowledgments

  • Amazon Web Services for DynamoDB and Lambda infrastructure
  • Next.js Team for the amazing framework
  • Tailwind CSS for the utility-first CSS framework
  • Radix UI for accessible components
  • HackOn Season 5 organizers for the opportunity
  • Nikhil for building the APIs and Backend
  • Shreelekha for building the Face-ID Biometric and PPT
  • Mansi for building the Seller Trust and UI and PPT

Built with ❀️ for Amazon HackOn Season 5

About

VaultX - Secure payment platform with SmartCoins and Trust Index

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages