A React application for tracking and splitting expenses among travelers during trips. Simplify group travel finances with easy expense tracking, automatic currency conversion, and settlement calculations.
- Travel Expense Tracker
- Multiple Tour Support: Create and manage multiple tours (e.g., Philippines Tour, Malaysia Tour)
- Traveler Management: Add custom travelers for each tour
- Multi-Currency Support: Add currencies with custom exchange rates
- Automatic Currency Conversion: Expenses in different currencies are automatically converted to the base currency
- Expense Tracking: Track expenses with date, amount, currency, and description
- Expense Categorization: Categorize expenses for better analysis
- Split Expenses: Split expenses equally or with custom amounts
- Payment Tracking: Record payments between travelers
- Settlement Calculation: Calculate who owes whom with minimum transactions
- Trip Planning: Create and manage tasks for your trip with priorities, assignments, and costs
- Visual Analytics: View expense distribution by category
- Cloud Data Storage: Store data in Supabase for global access
- Export to Excel: Export tour data to Excel for record-keeping
- Responsive Design: Works on desktop, tablet, and mobile devices
- Progressive Web App (PWA): Install on mobile devices for offline access and native app-like experience
- Node.js (v16 or higher)
- npm or yarn
- Supabase account (free tier works fine)
-
Clone the repository:
git clone https://github.com/yourusername/travel-expense-tracker.git cd travel-expense-tracker
-
Install dependencies:
npm install
-
Create a
.env
file in the root directory based on the.env.example
file:VITE_SUPABASE_URL=your_supabase_url VITE_SUPABASE_ANON_KEY=your_supabase_anon_key
-
Replace
your_supabase_url
andyour_supabase_anon_key
with your actual Supabase project URL and anonymous key, which you can find in your Supabase project settings under API.
The application is configured as a Progressive Web App (PWA) using Vite PWA plugin. The configuration is in the vite.config.ts
file:
-
Make sure the PWA plugin is installed:
npm install vite-plugin-pwa -D
-
The PWA configuration includes:
- App name and short name
- Theme colors and icons
- Service worker strategy
- Offline fallback page
-
To customize the PWA settings, edit the
pwa
section invite.config.ts
:VitePWA({ registerType: "autoUpdate", includeAssets: ["favicon.ico", "apple-touch-icon.png", "masked-icon.svg"], manifest: { name: "Travel Expense Tracker", short_name: "ExpenseTracker", theme_color: "#1976d2", icons: [ // ... icon configurations ], }, workbox: { // Workbox options }, });
-
Make sure to include appropriate icons in different sizes in the
public
directory for the PWA to use.
- Create a Supabase account at https://supabase.com if you don't have one
- Create a new project
- Go to the SQL Editor in your Supabase dashboard
- Run the SQL commands from the
travel-expense-tracker-db-setup.sql
file to create all necessary tables, functions, and initial data
Note: The
travel-expense-tracker-db-setup.sql
file contains all the necessary SQL commands to set up the complete database structure in one go. This is the recommended approach for new installations.
For existing installations: If you've previously used
supabase-setup.sql
andsupabase-update.sql
files, you can continue using those, but the comprehensive file is recommended for new installations as it includes all the latest schema changes.
The application uses the following tables:
-
tours: Stores tour information
id
: UUID (primary key)name
: Textbase_currency_code
: Textcreated_at
: Timestampupdated_at
: Timestamp
-
travelers: Stores traveler information
id
: UUID (primary key)tour_id
: UUID (foreign key to tours)name
: Text
-
currencies: Stores currency information
tour_id
: UUID (foreign key to tours)code
: Textname
: Textexchange_rate
: Numeric- Primary key: (tour_id, code)
-
expense_categories: Stores expense categories
id
: Text (primary key)name
: Textcolor
: Text
-
expenses: Stores expense information
id
: UUID (primary key)tour_id
: UUID (foreign key to tours)description
: Textamount
: Numericcurrency_code
: Textbase_amount
: Numericbase_currency_code
: Textdate
: Timestamppaid_by_id
: UUID (foreign key to travelers)category_id
: Text (foreign key to expense_categories)created_at
: Timestamp
-
expense_splits: Stores how expenses are split among travelers
expense_id
: UUID (foreign key to expenses)traveler_id
: UUID (foreign key to travelers)amount
: Numericbase_amount
: Numeric- Primary key: (expense_id, traveler_id)
-
payments: Stores payment information
id
: UUID (primary key)tour_id
: UUID (foreign key to tours)from_traveler_id
: UUID (foreign key to travelers)to_traveler_id
: UUID (foreign key to travelers)amount
: Numericcurrency_code
: Textdate
: Timestampdescription
: Textcreated_at
: Timestamp
-
planning_tasks: Stores trip planning tasks
id
: UUID (primary key)tour_id
: UUID (foreign key to tours)title
: Textcost
: Numeric (optional)currency_code
: Text (optional)location
: Text (optional)date
: Timestamppriority
: Text (LOW, MEDIUM, HIGH)travelers
: Text[] (array of traveler IDs)assigned_to
: Text[] (array of traveler IDs)completed
: Booleancreated_at
: Timestamp
-
Start the development server:
npm run dev
-
Open your browser and navigate to
http://localhost:5173
(or the port shown in your terminal) -
The application will automatically connect to your Supabase project using the credentials in your
.env
file
To build the application for production:
npm run build
The built files will be in the dist
directory and can be served by any static file server.
-
Create an account on Netlify
-
Install the Netlify CLI:
npm install -g netlify-cli
-
Login to Netlify:
netlify login
-
Build your project:
npm run build
-
Deploy to Netlify:
netlify deploy --prod
-
Set up environment variables in the Netlify dashboard:
- Go to Site settings > Build & deploy > Environment
- Add the following environment variables:
VITE_SUPABASE_URL
VITE_SUPABASE_ANON_KEY
-
Create an account on Vercel
-
Install the Vercel CLI:
npm install -g vercel
-
Login to Vercel:
vercel login
-
Deploy to Vercel:
vercel --prod
-
Set up environment variables in the Vercel dashboard:
- Go to Project settings > Environment Variables
- Add the following environment variables:
VITE_SUPABASE_URL
VITE_SUPABASE_ANON_KEY
- On the home page, enter a name for your tour (e.g., "Thailand Trip 2023")
- Select a base currency (this will be used for settlements)
- Click "Create Tour"
- The base currency should be the currency most commonly used during your trip
- Select your tour from the dropdown in the top navigation bar
- Navigate to the "Travelers" page
- Click "Add Traveler"
- Enter the traveler's name
- Click "Add"
- You can edit or delete travelers using the action buttons
- Navigate to the "Currencies" page
- Click "Add Currency"
- Enter the currency code (e.g., "USD"), name, and exchange rate relative to your base currency
- For example, if your base currency is BDT and 1 USD = 124.64 BDT, enter 124.64 as the exchange rate
- Click "Add"
- Add all currencies you'll use during your trip
- Navigate to the "Expenses" page
- Click "Add Expense"
- Fill in the expense details:
- Description
- Select the currency (the equivalent amount in base currency will be shown automatically)
- Enter the amount
- Select the date
- Select who paid
- Choose a category
- Split the expense:
- Use "Equal" to divide evenly among all travelers
- Or use "Custom" to enter specific amounts for each traveler
- Click "Save"
- The expense will appear in the list, grouped by date
The Planning page helps you organize tasks and activities for your trip:
- Navigate to the "Planning" page
- Click "Add Task" to create a new task
- Fill in the task details:
- Title (required)
- Cost (optional)
- Currency (defaults to base currency)
- Location (optional)
- Date (required)
- Priority (High, Medium, Low)
- Travelers involved
- Assigned to (who's responsible)
- Click "Save"
- Tasks will appear in the list, grouped by date
- You can:
- Mark tasks as complete by clicking the circle icon
- Edit tasks by clicking the edit icon
- Delete tasks by clicking the delete icon
- Expand tasks to see more details
- Use the search and filter options at the top to find specific tasks
The Settlements page provides a comprehensive overview of the financial state of your tour:
- Tour Summary: Shows basic information about your tour
- Expense Distribution by Category: A pie chart showing how expenses are distributed across categories
- Expense Totals by Traveler: Shows each traveler's total expenses and payments
- Settlement Plan: Shows who should pay whom to settle all debts
The Settlement Plan works like this:
- The system calculates each traveler's balance based on:
- Expenses they paid for
- Their share of all expenses
- Payments they've made or received
- Travelers with negative balances owe money
- Travelers with positive balances are owed money
- The system creates a simplified plan where:
- The person with the highest positive balance (main creditor) receives payments from everyone who owes money
- This minimizes the number of transactions needed to settle all debts
- For each payment in the plan, you'll see:
- Who needs to pay
- Who should receive the payment
- The exact amount
- Current balance information for both travelers
To record a payment:
- Click "Record Payment" next to a settlement
- The payment form will be pre-filled with the suggested amount and travelers
- You can adjust the details if needed
- Click "Save" to record the payment
- The settlement plan will automatically update based on the new payment
- On the "Settlements" page, click "Export to Excel"
- The application will generate an Excel file with all tour data
- The file includes separate sheets for:
- Tour information
- Travelers
- Currencies
- Expenses
- Expense splits
- Payments
- Settlements
The Travel Expense Tracker is a Progressive Web App (PWA), which means you can install it on your mobile device and use it like a native app:
- Visit the app in Safari
- Tap the Share button (the square with an arrow pointing upward)
- Scroll down and tap "Add to Home Screen"
- Give the app a name (or keep the default)
- Tap "Add" in the top-right corner
- The app icon will appear on your home screen
- Visit the app in Chrome
- Tap the three-dot menu in the top-right corner
- Tap "Add to Home Screen" or "Install app"
- Follow the prompts to install
- The app icon will appear on your home screen
- Access the app directly from your home screen
- Use the app in full-screen mode without browser navigation bars
- Faster loading times after the first visit
- Some offline functionality (basic app structure will load even without internet)
- Automatic updates when new versions are released
The application handles currency conversion automatically:
-
When you add an expense in a non-base currency, it's converted to the base currency using the formula:
baseAmount = amount * exchangeRate
-
For example, if you add an expense of 93 Peso and the exchange rate is 2.17 BDT per Peso:
baseAmount = 93 * 2.17 = 201.81 BDT
-
Both the original amount and the base amount are stored in the database
-
All calculations for settlements use the base amounts to ensure accuracy
-
The application displays both the original amount and the equivalent base amount for clarity
To add a new currency with a custom exchange rate:
- Navigate to the "Currencies" page
- Click "Add Currency"
- Enter the following information:
- Currency Code: The 3-letter ISO code (e.g., USD, EUR, JPY)
- Currency Name: The full name (e.g., US Dollar, Euro, Japanese Yen)
- Exchange Rate: The rate relative to your base currency
The exchange rate should represent how much of your base currency equals 1 unit of the currency you're adding.
For example:
- If your base currency is BDT and 1 USD = 124.64 BDT, enter 124.64 as the exchange rate for USD
- If your base currency is BDT and 1 EUR = 134.92 BDT, enter 134.92 as the exchange rate for EUR
- If your base currency is BDT and 1 PHP = 2.17 BDT, enter 2.17 as the exchange rate for PHP
You can find current exchange rates from sources like:
Remember to update exchange rates periodically if they change significantly during your trip.
- Set up all currencies with accurate exchange rates before adding expenses
- Add expenses as soon as possible to keep track of all spending
- Use categories consistently to get meaningful analytics
- Export data regularly as a backup
- Record payments as they happen to keep settlements up to date
- Use the Planning page to organize your trip activities and assign responsibilities
- Change the base currency after adding expenses (this can cause calculation issues)
- Delete travelers who have expenses associated with them
- Modify exchange rates frequently (only update them if there's a significant change)
- Use the same tour for multiple trips (create a new tour for each trip)
- Check your Supabase credentials in the
.env
file - Ensure you've run the SQL setup scripts correctly
- Check the browser console for any errors
- Verify your internet connection
- Make sure all currencies have correct exchange rates
- Remember that exchange rates are relative to the base currency
- If you update an exchange rate, existing expenses won't be automatically recalculated
- Verify that all expenses have been correctly split
- Check that all payments have been recorded
- Ensure all currencies have correct exchange rates
- App not installing: Make sure you're using a supported browser (Chrome, Edge, Safari, etc.)
- Offline access not working: The app requires an initial load with internet connection to cache resources
- Data not syncing:
- When you regain internet connection, refresh the app to sync pending changes
- If changes aren't appearing, try closing and reopening the app
- App not updating:
- Clear the browser cache for the site
- Uninstall and reinstall the PWA from your home screen
- Storage issues:
- PWAs have limited storage on some devices
- If you encounter storage errors, try clearing the site data in your browser settings
This project is licensed under the MIT License - see the LICENSE file for details.