A modern, full-stack flight booking application built with Next.js, Supabase, and Flutterwave payment integration.
π Migration Update: This project has been migrated from MySQL to Supabase. See the SUPABASE_MIGRATION_GUIDE.md file for details about the migration process and troubleshooting Row Level Security (RLS) issues.
- Flight Search & Booking - Search flights by route, date, passengers, and class
- Real-time Flight Tracking - Track flights using unique tracking numbers
- PDF Ticket Generation - Automatic ticket generation after successful payment
- Multi-currency Support - EUR, USD, GBP with real-time conversion
- Flutterwave Payment Gateway - Secure payment processing
- Server-side Payment Verification - Enhanced security with transaction validation
- Payment Status Tracking - Real-time payment status updates
- Automatic Booking Updates - Database updates on successful payments
- Flight Management - CRUD operations for flights, airlines, and locations
- Payment Configuration - API key management for payment gateways
- Revenue Analytics - Real-time revenue tracking and statistics
- User Management - Role-based access control
- Row Level Security (RLS) - Database-level security
- Role-based Access Control - Admin and user roles
- Server-side Payment Processing - No client-side API keys
- Input Validation - Comprehensive data validation
- Frontend: Next.js 15, React 19, TypeScript, Tailwind CSS
- Backend: Appwrite (Database, Auth, Storage)
- Payment: Flutterwave API
- State Management: Zustand
- Styling: Tailwind CSS with custom design system
- Node.js 18+
- npm or yarn
- Appwrite account
- Flutterwave account (for payments)
git clone https://github.com/your-username/flight-booking-app.git
cd flight-booking-app
npm install
Create a .env.local
file in the root directory:
# Appwrite Configuration
NEXT_PUBLIC_APPWRITE_ENDPOINT=https://cloud.appwrite.io/v1
NEXT_PUBLIC_APPWRITE_PROJECT_ID=your_project_id
NEXT_PUBLIC_APPWRITE_DATABASE_ID=your_database_id
NEXT_PUBLIC_APPWRITE_BUCKET_ID=your_bucket_id
# Appwrite Collection IDs
NEXT_PUBLIC_APPWRITE_USERS_COLLECTION_ID=users_collection_id
NEXT_PUBLIC_APPWRITE_FLIGHTS_COLLECTION_ID=flights_collection_id
NEXT_PUBLIC_APPWRITE_AIRLINES_COLLECTION_ID=airlines_collection_id
NEXT_PUBLIC_APPWRITE_BOOKINGS_COLLECTION_ID=bookings_collection_id
NEXT_PUBLIC_APPWRITE_LOCATIONS_COLLECTION_ID=locations_collection_id
NEXT_PUBLIC_APPWRITE_PAYMENTS_COLLECTION_ID=payments_collection_id
NEXT_PUBLIC_APPWRITE_CURRENCIES_COLLECTION_ID=currencies_collection_id
NEXT_PUBLIC_APPWRITE_USER_PREFERENCES_COLLECTION_ID=user_preferences_id
# Application Configuration
NEXT_PUBLIC_BASE_URL=http://localhost:3000
- Create a new project in Appwrite
- Set up authentication (Email/Password)
- Create a database with the required collections
- Create storage buckets for files
For detailed setup instructions, refer to APPWRITE_SETUP_COMPLETE.md
# Run migration helper script
node appwrite-migration-helper.js
# Start development server
npm run dev
# Visit test page
open http://localhost:3000/test-appwrite
- Go to
/admin/integrations
in your app - Add your Flutterwave API keys:
test_secret
(for development)live_secret
(for production)
- Save the configuration
npm run dev
Visit http://localhost:3000 to see the application.
users
- User accounts with rolesflights
- Flight information with tracking numbersbookings
- User bookings with payment statusairlines
- Airline informationlocations
- Airport/city datacurrencies
- Multi-currency supportpayment_gateways
- Payment configurationuser_preferences
- User settings
-
Create the Database
- Go to MySQL Databases in cPanel
- Create a new database named
united_airline
(or your preferred name) - Create a new database user with a strong password
- Add the user to the database with ALL PRIVILEGES
-
Import Database Structure
- Navigate to phpMyAdmin from cPanel
- Select your newly created database
- Click on the "Import" tab
- Upload and execute the comprehensive SQL file:
united_airline_complete_database.sql
- Creates all tables, relationships, and adds sample data
-
Verify Database Setup
- Check that all tables were created successfully (should see 10 tables)
- Verify sample data was imported correctly (locations, airlines, currencies)
- Test the database connection with your application
- User selects flight β Booking created
- User clicks "Pay Now" β Payment initiated via
/api/payment/initiate-v2
- User redirected β Flutterwave payment page
- Payment completed β Redirected to
/payment-success
- Payment verified β Booking updated via
/api/payment/verify
- PDF ticket generated β Stored in Supabase Storage
POST /api/payment/initiate-v2
- Create paymentPOST /api/payment/verify
- Verify paymentGET /api/payment/test-keys
- Check payment configurationGET /api/payment/debug-bookings
- Debug bookings
GET /admin/dashboard
- Admin dashboardGET /admin/flights
- Flight managementGET /admin/integrations
- Payment configuration
Use Flutterwave test cards:
- Visa: 4000000000000002
- Mastercard: 5204730000002514
- Verve: 5061000000000000000
http://localhost:3000/api/payment/test-keys
- Check payment setuphttp://localhost:3000/api/payment/debug-bookings
- View recent bookingshttp://localhost:3000/test_amount_conversion.html
- Test amount conversion
We've prepared detailed instructions for deploying this application to Truehost cPanel in the CPANEL_DEPLOYMENT.md file.
Quick Overview of Truehost cPanel Deployment:
- Create MySQL Database in Truehost cPanel's MySQL Database tool (note the username prefix)
- Import SQL Files using phpMyAdmin with the single
united_airline_complete_database.sql
file - Upload Application Files via Truehost File Manager (compressed ZIP recommended)
- Configure Environment Variables in a
.env
file with your Truehost database credentials - Set Up Node.js Application using Truehost's Setup Node.js App tool in cPanel
- Configure Domain and SSL for secure access to your application
See the complete step-by-step guide specifically tailored for Truehost in CPANEL_DEPLOYMENT.md
flights/
βββ src/
β βββ app/ # Next.js App Router
β β βββ api/ # API routes
β β βββ admin/ # Admin pages
β β βββ components/ # Shared components
β β βββ ...
β βββ lib/ # Utility libraries
β βββ services/ # External services
βββ supabase/ # Database migrations
βββ public/ # Static assets
βββ ...
- API Keys: Stored securely in database, not in client code
- RLS Policies: Database-level security for all tables
- Payment Verification: Server-side validation of all payments
- Input Validation: Comprehensive validation on all inputs
-
Payment Verification Fails
- Check API keys in
/admin/integrations
- Verify Flutterwave account is active
- Check server logs for detailed errors
- Check API keys in
-
Database Connection Issues
- Verify Supabase credentials
- Check RLS policies
- Run database migrations
-
Amount Conversion Issues
- Use debug endpoint:
/api/payment/debug-amount
- Check currency conversion logic
- Verify Flutterwave amount format
- Use debug endpoint:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Next.js - React framework
- Supabase - Backend as a service
- Flutterwave - Payment processing
- Tailwind CSS - CSS framework
For support, please:
- Check the troubleshooting section
- Review server logs for error details
- Create an issue with detailed information
Built with β€οΈ using Next.js and Supabase