A full-stack MERN application for booking travel tickets (Bus, Train, Launch, Plane) with role-based access control for Users, Vendors, and Admins.
- Live Site: https://ticketbari1.netlify.app/
- Email/Password and Google Sign-in with Firebase
- JWT token-based API protection
- Role-based access control (User, Vendor, Admin)
- Protected routes with persistent authentication
- Password validation (uppercase, lowercase, 6+ characters)
- Browse & Search: Search tickets by location with filters
- Advanced Filtering: Filter by transport type (Bus/Train/Launch/Plane)
- Smart Sorting: Sort tickets by price (Low to High / High to Low)
- Pagination: View 9 tickets per page for better performance
- Ticket Details: View full details with real-time countdown timer
- Easy Booking: Book tickets with quantity selection
- Secure Payment: Complete payment through Stripe integration
- PDF Download: Download ticket PDF after successful payment
- Booking History: Track all bookings with status updates
- Transaction History: View complete payment history
- Dark/Light Mode: Toggle between themes for comfortable viewing
- Add Tickets: Create new ticket listings with ImgBB image upload
- Manage Tickets: Update or delete tickets (restrictions apply)
- Booking Requests: View and respond to customer bookings
- Accept/Reject: Approve or decline booking requests
- Revenue Analytics: Track earnings with interactive Recharts visualizations
- Sales Dashboard: Monitor tickets sold and total listings
- Verification Status: Real-time ticket approval status from admin
- Ticket Management: Approve or reject vendor-submitted tickets
- User Management: Promote users to Admin or Vendor roles
- Fraud Detection: Mark vendors as fraud (hides all their tickets)
- Advertisement Control: Feature up to 6 tickets on homepage
- Platform Overview: Complete control over all platform content
- User Analytics: View all users and their activities
- React 18 - Modern UI library
- React Router DOM - Client-side routing
- TanStack Query - Powerful data fetching and caching
- React Hook Form - Performant form validation
- Tailwind CSS - Utility-first CSS framework
- DaisyUI - Beautiful component library
- Firebase - Authentication service
- Stripe - Payment processing
- Swiper.js - Touch slider for hero section
- Recharts - Data visualization library
- React Countdown - Real-time countdown timers
- React Hot Toast - Elegant notifications
- SweetAlert2 - Beautiful popup alerts
- jsPDF - PDF generation for tickets
- Axios - HTTP client
- React Icons - Icon library
- React Helmet Async - SEO management
- Node.js - JavaScript runtime
- Express.js - Web application framework
- MongoDB - NoSQL database
- JWT - Secure token authentication
- CORS - Cross-origin resource sharing
{
"@stripe/react-stripe-js": "^2.4.0",
"@stripe/stripe-js": "^2.2.0",
"@tanstack/react-query": "^5.17.9",
"axios": "^1.6.2",
"firebase": "^10.7.1",
"jspdf": "^2.5.1",
"react": "^18.2.0",
"react-countdown": "^2.3.5",
"react-dom": "^18.2.0",
"react-helmet-async": "^2.0.4",
"react-hook-form": "^7.49.2",
"react-hot-toast": "^2.4.1",
"react-icons": "^4.12.0",
"react-router-dom": "^6.20.1",
"recharts": "^2.10.3",
"sweetalert2": "^11.10.2",
"swiper": "^11.0.5"
}{
"express": "^4.18.2",
"cors": "^2.8.5",
"dotenv": "^16.3.1",
"jsonwebtoken": "^9.0.2",
"mongodb": "^6.3.0"
}- Node.js (v16 or higher)
- MongoDB Atlas account
- Firebase project
- ImgBB API key
- Stripe account
- Clone the repository
git clone https://github.com/omarabir/TicketBari-server
cd ticketbari-server- Install dependencies
npm install- Create
.envfile
MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret_key
PORT=5000- Run the server
npm start
# or for development
npm run devServer will run on http://localhost:5000
- Clone the repository
git clone https://github.com/omarabir/TicketBari-client
cd ticketbari-client- Install dependencies
npm install- Create
.env.localfile
VITE_API_URL=http://localhost:5000
VITE_FIREBASE_API_KEY=your_firebase_api_key
VITE_FIREBASE_AUTH_DOMAIN=your_firebase_auth_domain
VITE_FIREBASE_PROJECT_ID=your_firebase_project_id
VITE_FIREBASE_STORAGE_BUCKET=your_firebase_storage_bucket
VITE_FIREBASE_MESSAGING_SENDER_ID=your_firebase_messaging_sender_id
VITE_FIREBASE_APP_ID=your_firebase_app_id
VITE_IMGBB_API_KEY=your_imgbb_api_key
VITE_STRIPE_PUBLISHABLE_KEY=pk_test_your_stripe_key- Run the development server
npm run devApplication will run on http://localhost:5173
β
Search Functionality - Search tickets by From/To location
β
Filter by Transport Type - Filter by Bus, Train, Launch, Plane
β
Sort by Price - Low to High and High to Low sorting
β
JWT Token Protection - All API routes are secured
β
Pagination - 9 tickets per page with navigation
β
Dark/Light Mode - Complete theme toggle functionality
β
PDF Ticket Download - Generate and download tickets after payment
β
React Hook Form - Used in all forms for better validation
β
Swiper.js - Beautiful hero slider on homepage
β
TanStack Query - Efficient data fetching and caching
β
Recharts Integration - Interactive revenue charts for vendors
- β Mobile (375px - 767px)
- β Tablet (768px - 1023px)
- β Desktop (1024px and above)
- Environment variables for sensitive data
- JWT token authentication
- Firebase security rules
- Role-based access control
- Protected API routes
- Input validation and sanitization
- XSS protection
- Modern Design: Clean and professional interface
- Consistent Theme: Unified color scheme (Primary: #3B82F6, Secondary: #8B5CF6)
- Smooth Animations: Fade-in effects and transitions
- Loading States: Skeleton loaders and spinners
- Error Handling: User-friendly error messages
- Toast Notifications: Real-time feedback for actions
- Responsive Images: Optimized for all screen sizes
- Dark Mode: Eye-friendly theme for night usage
{
name: String,
email: String,
photoURL: String,
role: String, // 'user' | 'vendor' | 'admin'
isFraud: Boolean, // for vendors
createdAt: Date
}{
ticketTitle: String,
fromLocation: String,
toLocation: String,
transportType: String, // 'Bus' | 'Train' | 'Launch' | 'Plane'
price: Number,
ticketQuantity: Number,
departureDateTime: Date,
perks: [String],
image: String,
vendorName: String,
vendorEmail: String,
verificationStatus: String, // 'pending' | 'approved' | 'rejected'
isAdvertised: Boolean,
isHidden: Boolean,
createdAt: Date
}{
ticketId: ObjectId,
ticketTitle: String,
bookingQuantity: Number,
totalPrice: Number,
userId: String,
userName: String,
status: String, // 'pending' | 'accepted' | 'rejected' | 'paid'
createdAt: Date
}{
userId: String,
bookingId: ObjectId,
ticketId: ObjectId,
transactionId: String,
amount: Number,
ticketTitle: String,
paymentDate: Date
}- Card Number: 4242 4242 4242 4242
- Expiry: Any future date (e.g., 12/34)
- CVC: Any 3 digits (e.g., 123)
- ZIP: Any 5 digits (e.g., 12345)
- Push code to GitHub
- Connect repository to hosting platform
- Add environment variables
- Deploy
- Build:
npm run build - Connect GitHub repository
- Add environment variables
- Configure build settings:
- Build command:
npm run build - Publish directory:
dist
- Build command:
- Add
_redirectsfile for SPA:
/* /index.html 200
POST /jwt- Generate JWT tokenPOST /users- Create new userGET /users/:email- Get user by email
GET /tickets- Get all approved tickets (with search, filter, sort, pagination)GET /tickets/:id- Get single ticketGET /tickets/advertised/all- Get advertised ticketsGET /tickets/latest/all- Get latest tickets
POST /bookings- Create bookingGET /bookings/user- Get user bookingsPOST /payments- Process paymentGET /transactions- Get user transactions
POST /vendor/tickets- Add ticketGET /vendor/tickets- Get vendor ticketsPUT /vendor/tickets/:id- Update ticketDELETE /vendor/tickets/:id- Delete ticketGET /vendor/bookings- Get booking requestsPATCH /vendor/bookings/:id- Accept/Reject bookingGET /vendor/revenue- Get revenue stats
GET /admin/users- Get all usersPATCH /admin/users/:id/role- Update user rolePATCH /admin/vendors/:id/fraud- Mark vendor as fraudGET /admin/tickets- Get all ticketsPATCH /admin/tickets/:id/verify- Approve/Reject ticketPATCH /admin/tickets/:id/advertise- Toggle advertisement