Skip to content
reactjayPublic

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

6 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

RailPay - Railway Payment System

A modern, full-featured railway payment and ticketing system built with Next.js 14, TypeScript, Tailwind CSS, and Web3 wallet integration.

Features

User Features

  • πŸ” Authentication (Login/Register)
  • 🎫 Ticket booking and management
  • 🎟️ Travel passes purchase
  • πŸ“± QR code ticket generation and scanning
  • πŸ’³ Multiple payment methods (Card, Crypto Wallet, Mobile)
  • πŸ“Š Dashboard with travel overview
  • πŸ‘€ User profile management

Admin Features

  • πŸ“ˆ Revenue analytics and reporting
  • πŸš‚ Route management
  • πŸ’° Fare configuration
  • πŸ‘₯ Staff management
  • πŸ”Œ Device management
  • πŸ“Š Real-time statistics

Tech Stack

  • Framework: Next.js 14 (App Router)
  • Language: TypeScript
  • Styling: Tailwind CSS
  • UI Components: ShadCN UI
  • State Management: Zustand
  • API Client: Axios
  • Wallet Integration: RainbowKit + Wagmi
  • QR Code: qrcode.react, html5-qrcode
  • Blockchain: Sepolia Testnet

Project Structure

railpay/
β”œβ”€β”€ app/                      # Next.js App Router pages
β”‚   β”œβ”€β”€ auth/                 # Authentication pages
β”‚   β”‚   β”œβ”€β”€ login/
β”‚   β”‚   └── register/
β”‚   β”œβ”€β”€ dashboard/            # User dashboard pages
β”‚   β”‚   β”œβ”€β”€ tickets/
β”‚   β”‚   β”œβ”€β”€ passes/
β”‚   β”‚   └── profile/
β”‚   β”œβ”€β”€ admin/                # Admin pages
β”‚   β”‚   β”œβ”€β”€ routes/
β”‚   β”‚   β”œβ”€β”€ fares/
β”‚   β”‚   β”œβ”€β”€ revenue/
β”‚   β”‚   β”œβ”€β”€ staff/
β”‚   β”‚   └── devices/
β”‚   β”œβ”€β”€ pay/                  # Payment page
β”‚   β”œβ”€β”€ qr/                   # QR code pages
β”‚   β”‚   β”œβ”€β”€ generate/
β”‚   β”‚   └── scan/
β”‚   β”œβ”€β”€ layout.tsx            # Root layout
β”‚   β”œβ”€β”€ page.tsx              # Landing page
β”‚   β”œβ”€β”€ providers.tsx         # Providers (RainbowKit, etc.)
β”‚   └── globals.css           # Global styles
β”œβ”€β”€ components/               # React components
β”‚   β”œβ”€β”€ ui/                   # ShadCN UI components
β”‚   β”œβ”€β”€ Sidebar.tsx
β”‚   β”œβ”€β”€ NavBar.tsx
β”‚   β”œβ”€β”€ TicketCard.tsx
β”‚   β”œβ”€β”€ RouteSelector.tsx
β”‚   β”œβ”€β”€ PaymentModal.tsx
β”‚   β”œβ”€β”€ QRDisplay.tsx
β”‚   └── QRScanner.tsx
β”œβ”€β”€ lib/                      # Utility libraries
β”‚   β”œβ”€β”€ api.ts                # API client setup
β”‚   β”œβ”€β”€ wallet.ts             # Wallet utilities
β”‚   β”œβ”€β”€ store.ts              # Zustand stores
β”‚   └── utils.ts              # Utility functions
└── public/                   # Static assets
    β”œβ”€β”€ logos/
    └── icons/

Getting Started

Prerequisites

  • Node.js 18+ installed
  • npm or yarn package manager
  • WalletConnect Project ID (for RainbowKit - optional)

Installation

  1. Clone the repository (or navigate to the project directory)
cd "C:\Users\DELL\Desktop\NEW VERSION RAILPAY"
  1. Install dependencies
npm install
# or
yarn install
  1. Set up environment variables

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

NEXT_PUBLIC_API_URL=http://localhost:3001/api
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=your_walletconnect_project_id

Note: For WalletConnect (RainbowKit) to work properly, you'll need to:

  • Sign up at WalletConnect Cloud
  • Create a project and get your Project ID
  • Add it to .env.local as shown above

Alternatively, you can use the placeholder YOUR_PROJECT_ID in the code for development.

  1. Run the development server
npm run dev
# or
yarn dev
  1. Open your browser

Navigate to http://localhost:3000

Usage

User Flow

  1. Register/Login: Create an account or sign in
  2. Book Ticket: Go to /pay to search and book tickets
  3. View Tickets: Check your tickets in /dashboard/tickets
  4. Generate QR: Create QR codes for your active tickets
  5. Scan QR: Use the scanner to verify tickets (admin feature)

Admin Flow

  1. Login as Admin: Use an email containing "admin" to access admin features
  2. Manage Routes: Add, edit, or delete routes in /admin/routes
  3. Configure Fares: Set pricing in /admin/fares
  4. View Revenue: Check analytics in /admin/revenue
  5. Manage Staff: Add/remove staff members in /admin/staff
  6. Monitor Devices: Track connected devices in /admin/devices

Mock Authentication

Currently, the app uses mock authentication:

  • Any email and password will work for login/register
  • Emails containing "admin" will be assigned admin role
  • All other users get the user role

Building for Production

npm run build
npm start

Environment Variables

Variable Description Required
NEXT_PUBLIC_API_URL Backend API URL No (defaults to localhost:3001)
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID WalletConnect Project ID for RainbowKit No (optional)

Features Overview

Authentication

  • User registration and login
  • Session management with Zustand
  • Protected routes

Ticketing System

  • Route search and selection
  • Ticket booking
  • Ticket management (view, filter, search)
  • QR code generation for tickets

Payment System

  • Multiple payment methods
  • Crypto wallet integration (RainbowKit)
  • Card payments
  • Mobile payments

Admin Panel

  • Comprehensive dashboard with statistics
  • Route CRUD operations
  • Fare management
  • Revenue analytics
  • Staff management
  • Device monitoring

Customization

Theme Colors

Edit app/globals.css to customize the color scheme:

:root {
  --primary: 221.2 83.2% 53.3%;
  /* ... other colors */
}

API Configuration

Update lib/api.ts to connect to your backend API:

const API_BASE_URL = process.env.NEXT_PUBLIC_API_URL || 'http://localhost:3001/api'

Troubleshooting

Wallet Connection Issues

  • Ensure you have a valid WalletConnect Project ID
  • Check that your wallet extension is installed and unlocked
  • Verify you're on the Sepolia testnet

QR Scanner Not Working

  • Ensure camera permissions are granted
  • Use HTTPS or localhost (HTTP doesn't support camera access)
  • Check browser compatibility (Chrome, Firefox, Safari supported)

Build Errors

  • Clear .next folder: rm -rf .next
  • Reinstall dependencies: rm -rf node_modules && npm install
  • Check Node.js version (requires 18+)

Next Steps

To connect this frontend to a backend:

  1. Update lib/api.ts with your actual API endpoints
  2. Implement real authentication tokens
  3. Replace mock data with API calls
  4. Set up WebSocket connections for real-time updates (optional)

License

This project is open source and available for use.

Support

For issues or questions, please check the documentation or create an issue in the repository.


Built with ❀️ using Next.js 14 and modern web technologies.

About

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages