Invoice Pilot is a terminal-based automation tool built with Ratatui that searches for invoices and banks/brokerage/exchanges statements on Gmail and store on Drive. This project is completely free to use, modify, and distribute under the MIT License.
42
stars
19
commits
Rust
primary language
Mar 14, 2026
updated
Invoice Pilot is a fully automated invoice and bank statement management tool built with Rust. This project is completely free to use, modify, and distribute under the MIT License.

✅ Fetches invoices and bank statements from Gmail
✅ Automatically detects financial institutions (banks, brokerages, exchanges, payment processors)
✅ Downloads document attachments (PDF, CSV, XLS, DOC, etc.) — skips images
✅ Organizes files by institution in Google Drive with proper capitalization
✅ Creates smart filenames with sender names (e.g., langfuse-gmbh-invoice-12345.pdf)
✅ Catches up missing months by detecting gaps on Google Drive and backfilling automatically
✅ Prevents duplicates by checking existing files
✅ Email notifications on processing completion via Gmail API
✅ Runs manually or on schedule
cargo install just@1.43.0You need TWO Google Cloud projects (or one project with two OAuth2 clients):
https://www.googleapis.com/auth/gmail.readonlyhttps://www.googleapis.com/auth/drive.file# Clone the repository
git clone https://github.com/adolfousier/invoicepilot.git
cd invoice-pilot
# Build and run the project
just run
# The binary will be at target/release/invoice-pilot
If you prefer not to use just, you can build manually:
cargo build --release
./target/release/invoice-pilot
Copy the example environment file to the docker directory:
cp .env.example docker/.env
Important: The .env file must be placed inside the docker/ directory for the database and application to work correctly.
Edit docker/.env and fill in your credentials:
# Gmail account credentials (Account A)
GOOGLE_GMAIL_CLIENT_ID=your-gmail-client-id.apps.googleusercontent.com
GOOGLE_GMAIL_CLIENT_SECRET=your-gmail-client-secret
# Drive account credentials (Account B)
GOOGLE_DRIVE_CLIENT_ID=your-drive-client-id.apps.googleusercontent.com
GOOGLE_DRIVE_CLIENT_SECRET=your-drive-client-secret
# Drive folder path (will be created if it doesn't exist)
GOOGLE_DRIVE_FOLDER_LOCATION=billing/all-expenses/2025
# Day of month to fetch invoices (1-31)
FETCH_INVOICES_DAY=5
# Keywords to search for (comma-separated)
TARGET_KEYWORDS_TO_FETCH_AND_DOWNLOAD="invoice, invoices, fatura, faturas, statement, bank, extrato, movimientos, financial, fiscal, tributary"
# Email notifications (optional)
SEND_NOTIFY_EMAIL=false
NOTIFY_EMAIL=your-email@example.com
🚀 Default Mode: The interactive TUI is now the default and recommended way to use Invoice Pilot. Simply run cargo run with no arguments.
The interactive TUI (Terminal User Interface) provides a user-friendly, guided experience for managing your invoice processing:
cargo run
# or explicitly:
cargo run -- tui
| Key | Action |
|---|---|
Tab / Shift+Tab | Switch between panels |
Enter | Open configuration popup for current panel |
Esc | Close popup or quit application |
Q | Quit application |
? | Show help or setup guide |
Manual Processing Panel:
Enter: Start processing or configure datesC: Catchup missing months (detects gaps on Drive and processes them)R: Reset dates and resultsAuthentication Panel:
G: Authenticate Gmail accountD: Authenticate Google Drive accountR: Reset all authentication tokensScheduled Mode Panel:
Enter: Configure scheduled processing dayS: Trigger manual scheduled runActivity Log Panel:
just dev (or cargo run if you don't have just installed).env file exists, press ? for the setup guide.env fileG to authenticate GmailD to authenticate Google DriveEnter to set date rangeTab to switch between start/end datesEnter in Manual Processing panel to startThe TUI provides a complete, professional interface for invoice processing with guided setup, real-time feedback, and comprehensive error handling.
For scripting or automation, the original CLI mode is still available:
On first run, you'll need to authorize both accounts:
cargo run -- manual
This will:
~/.config/invoice-pilot/cargo run -- manual
cargo run -- manual --date-range 2024-09-01:2024-10-12
Run on a schedule using systemd timer or cron:
cargo run -- scheduled
This will only execute if today matches FETCH_INVOICES_DAY from .env.
cargo run -- auth gmail
cargo run -- auth drive
cargo run -- auth reset
langfuse-gmbh-invoice-12345.pdf)2025/, 2024/)Stripe/, Wise/, Coinbase/)If FETCH_INVOICES_DAY is set in your .env file, Invoice Pilot can run automatically on the specified day of each month. The scheduled command will automatically spin up a Docker container to execute the job, ensuring isolation and reliability.
In automated mode, cached OAuth tokens are used, so no user interaction or browser opening is required. The job runs in a container with mounted volumes for configuration and tokens.
To use automated execution:
cd docker && docker-compose buildcargo run -- scheduled (or ./target/release/invoice-pilot scheduled)If you prefer external scheduling, you can still set up systemd timers or cron jobs as described below.
Create the service file /etc/systemd/system/invoice-pilot.service:
[Unit]
Description=Invoice Pilot
[Service]
Type=oneshot
User=your-username
WorkingDirectory=/path/to/invoice-pilot
ExecStart=/path/to/invoice-pilot/target/release/invoice-pilot scheduled
Environment="PATH=/usr/local/bin:/usr/bin:/bin"
Create the timer file /etc/systemd/system/invoice-pilot.timer:
[Unit]
Description=Invoice Pilot Monthly Check
[Timer]
OnCalendar=*-*-{FETCH_INVOICES_DAY}
Persistent=true
[Install]
WantedBy=timers.target
Replace {FETCH_INVOICES_DAY} with your configured day (e.g., 05 for the 5th of each month).
Enable and start the timer:
sudo systemctl daemon-reload
sudo systemctl enable invoice-pilot.timer
sudo systemctl start invoice-pilot.timer
# Check status
sudo systemctl status invoice-pilot.timer
Add to your crontab (crontab -e):
# Run on the configured day of each month at 9 AM
0 9 {FETCH_INVOICES_DAY} * * cd /path/to/invoice-pilot && /path/to/invoice-pilot/target/release/invoice-pilot scheduled >> /var/log/invoice-pilot.log 2>&1
Replace {FETCH_INVOICES_DAY} with your configured day (e.g., 5 for the 5th of each month).
The OAuth callback uses port 8080. If it's in use:
lsof -ti:8080 | xargs kill -9If you get authorization errors:
cargo run -- auth resethttp://localhost:8080 in Google Cloud ConsoleTokens auto-refresh, but if you encounter issues:
cargo run -- auth reset
cargo run -- manual
# Run all tests
cargo test
# Run with output
cargo test -- --nocapture
src/
├── auth/ # OAuth2 authentication
│ ├── oauth.rs # Base OAuth2 logic
│ ├── gmail_auth.rs # Gmail-specific auth
│ └── drive_auth.rs # Drive-specific auth
├── gmail/ # Gmail API client
│ ├── client.rs # HTTP client
│ ├── search.rs # Email search with bank detection
│ ├── attachment.rs # Attachment download with sender/bank extraction
│ └── notify.rs # Email notifications via Gmail API
├── drive/ # Google Drive API client
│ ├── client.rs # HTTP client
│ ├── folder.rs # Folder management & subfolder listing
│ └── upload.rs # File upload
├── process/ # Processing logic
│ └── jobs.rs # Manual & catchup processing jobs
├── scheduler/ # Scheduling logic
│ └── runner.rs # Date calculations
├── config/ # Configuration
│ └── env.rs # .env parsing
├── cli/ # CLI interface
│ └── args.rs # Argument parsing
├── test/ # Unit tests
│ └── app_tests.rs # App state & helper tests
└── main.rs # Application entry point
.env file or tokens to version control~/.config/invoice-pilot/ with user-only permissionsWe welcome contributions from everyone! This is an open-source project, and we value any help you can provide.
git checkout -b feature/amazing-featuregit commit -m 'feat: add amazing feature'git push origin feature/amazing-featuregit clone https://github.com/adolfousier/invoicepilot.gitcargo buildcargo testcargo build && cargo testThank you for contributing to Invoice Pilot! 🚀
This project is licensed under the MIT License - see the LICENSE file for details.
This software is completely free to use, modify, and distribute for any purpose.
For issues, questions, or contributions, please open an issue on GitHub.
19 commits
Rust
90.7%
Shell
5.5%
PowerShell
2.6%
Just
1.0%
Invoice Pilot is a terminal-based automation tool built with Ratatui that searches for invoices and banks/brokerage/exchanges statements on Gmail and store on Drive. This project is completely free to use, modify, and distribute under the MIT License.
42
stars
19
commits
Rust
primary language
Mar 14, 2026
updated
Invoice Pilot is a fully automated invoice and bank statement management tool built with Rust. This project is completely free to use, modify, and distribute under the MIT License.

✅ Fetches invoices and bank statements from Gmail
✅ Automatically detects financial institutions (banks, brokerages, exchanges, payment processors)
✅ Downloads document attachments (PDF, CSV, XLS, DOC, etc.) — skips images
✅ Organizes files by institution in Google Drive with proper capitalization
✅ Creates smart filenames with sender names (e.g., langfuse-gmbh-invoice-12345.pdf)
✅ Catches up missing months by detecting gaps on Google Drive and backfilling automatically
✅ Prevents duplicates by checking existing files
✅ Email notifications on processing completion via Gmail API
✅ Runs manually or on schedule
cargo install just@1.43.0You need TWO Google Cloud projects (or one project with two OAuth2 clients):
https://www.googleapis.com/auth/gmail.readonlyhttps://www.googleapis.com/auth/drive.file# Clone the repository
git clone https://github.com/adolfousier/invoicepilot.git
cd invoice-pilot
# Build and run the project
just run
# The binary will be at target/release/invoice-pilot
If you prefer not to use just, you can build manually:
cargo build --release
./target/release/invoice-pilot
Copy the example environment file to the docker directory:
cp .env.example docker/.env
Important: The .env file must be placed inside the docker/ directory for the database and application to work correctly.
Edit docker/.env and fill in your credentials:
# Gmail account credentials (Account A)
GOOGLE_GMAIL_CLIENT_ID=your-gmail-client-id.apps.googleusercontent.com
GOOGLE_GMAIL_CLIENT_SECRET=your-gmail-client-secret
# Drive account credentials (Account B)
GOOGLE_DRIVE_CLIENT_ID=your-drive-client-id.apps.googleusercontent.com
GOOGLE_DRIVE_CLIENT_SECRET=your-drive-client-secret
# Drive folder path (will be created if it doesn't exist)
GOOGLE_DRIVE_FOLDER_LOCATION=billing/all-expenses/2025
# Day of month to fetch invoices (1-31)
FETCH_INVOICES_DAY=5
# Keywords to search for (comma-separated)
TARGET_KEYWORDS_TO_FETCH_AND_DOWNLOAD="invoice, invoices, fatura, faturas, statement, bank, extrato, movimientos, financial, fiscal, tributary"
# Email notifications (optional)
SEND_NOTIFY_EMAIL=false
NOTIFY_EMAIL=your-email@example.com
🚀 Default Mode: The interactive TUI is now the default and recommended way to use Invoice Pilot. Simply run cargo run with no arguments.
The interactive TUI (Terminal User Interface) provides a user-friendly, guided experience for managing your invoice processing:
cargo run
# or explicitly:
cargo run -- tui
| Key | Action |
|---|---|
Tab / Shift+Tab | Switch between panels |
Enter | Open configuration popup for current panel |
Esc | Close popup or quit application |
Q | Quit application |
? | Show help or setup guide |
Manual Processing Panel:
Enter: Start processing or configure datesC: Catchup missing months (detects gaps on Drive and processes them)R: Reset dates and resultsAuthentication Panel:
G: Authenticate Gmail accountD: Authenticate Google Drive accountR: Reset all authentication tokensScheduled Mode Panel:
Enter: Configure scheduled processing dayS: Trigger manual scheduled runActivity Log Panel:
just dev (or cargo run if you don't have just installed).env file exists, press ? for the setup guide.env fileG to authenticate GmailD to authenticate Google DriveEnter to set date rangeTab to switch between start/end datesEnter in Manual Processing panel to startThe TUI provides a complete, professional interface for invoice processing with guided setup, real-time feedback, and comprehensive error handling.
For scripting or automation, the original CLI mode is still available:
On first run, you'll need to authorize both accounts:
cargo run -- manual
This will:
~/.config/invoice-pilot/cargo run -- manual
cargo run -- manual --date-range 2024-09-01:2024-10-12
Run on a schedule using systemd timer or cron:
cargo run -- scheduled
This will only execute if today matches FETCH_INVOICES_DAY from .env.
cargo run -- auth gmail
cargo run -- auth drive
cargo run -- auth reset
langfuse-gmbh-invoice-12345.pdf)2025/, 2024/)Stripe/, Wise/, Coinbase/)If FETCH_INVOICES_DAY is set in your .env file, Invoice Pilot can run automatically on the specified day of each month. The scheduled command will automatically spin up a Docker container to execute the job, ensuring isolation and reliability.
In automated mode, cached OAuth tokens are used, so no user interaction or browser opening is required. The job runs in a container with mounted volumes for configuration and tokens.
To use automated execution:
cd docker && docker-compose buildcargo run -- scheduled (or ./target/release/invoice-pilot scheduled)If you prefer external scheduling, you can still set up systemd timers or cron jobs as described below.
Create the service file /etc/systemd/system/invoice-pilot.service:
[Unit]
Description=Invoice Pilot
[Service]
Type=oneshot
User=your-username
WorkingDirectory=/path/to/invoice-pilot
ExecStart=/path/to/invoice-pilot/target/release/invoice-pilot scheduled
Environment="PATH=/usr/local/bin:/usr/bin:/bin"
Create the timer file /etc/systemd/system/invoice-pilot.timer:
[Unit]
Description=Invoice Pilot Monthly Check
[Timer]
OnCalendar=*-*-{FETCH_INVOICES_DAY}
Persistent=true
[Install]
WantedBy=timers.target
Replace {FETCH_INVOICES_DAY} with your configured day (e.g., 05 for the 5th of each month).
Enable and start the timer:
sudo systemctl daemon-reload
sudo systemctl enable invoice-pilot.timer
sudo systemctl start invoice-pilot.timer
# Check status
sudo systemctl status invoice-pilot.timer
Add to your crontab (crontab -e):
# Run on the configured day of each month at 9 AM
0 9 {FETCH_INVOICES_DAY} * * cd /path/to/invoice-pilot && /path/to/invoice-pilot/target/release/invoice-pilot scheduled >> /var/log/invoice-pilot.log 2>&1
Replace {FETCH_INVOICES_DAY} with your configured day (e.g., 5 for the 5th of each month).
The OAuth callback uses port 8080. If it's in use:
lsof -ti:8080 | xargs kill -9If you get authorization errors:
cargo run -- auth resethttp://localhost:8080 in Google Cloud ConsoleTokens auto-refresh, but if you encounter issues:
cargo run -- auth reset
cargo run -- manual
# Run all tests
cargo test
# Run with output
cargo test -- --nocapture
src/
├── auth/ # OAuth2 authentication
│ ├── oauth.rs # Base OAuth2 logic
│ ├── gmail_auth.rs # Gmail-specific auth
│ └── drive_auth.rs # Drive-specific auth
├── gmail/ # Gmail API client
│ ├── client.rs # HTTP client
│ ├── search.rs # Email search with bank detection
│ ├── attachment.rs # Attachment download with sender/bank extraction
│ └── notify.rs # Email notifications via Gmail API
├── drive/ # Google Drive API client
│ ├── client.rs # HTTP client
│ ├── folder.rs # Folder management & subfolder listing
│ └── upload.rs # File upload
├── process/ # Processing logic
│ └── jobs.rs # Manual & catchup processing jobs
├── scheduler/ # Scheduling logic
│ └── runner.rs # Date calculations
├── config/ # Configuration
│ └── env.rs # .env parsing
├── cli/ # CLI interface
│ └── args.rs # Argument parsing
├── test/ # Unit tests
│ └── app_tests.rs # App state & helper tests
└── main.rs # Application entry point
.env file or tokens to version control~/.config/invoice-pilot/ with user-only permissionsWe welcome contributions from everyone! This is an open-source project, and we value any help you can provide.
git checkout -b feature/amazing-featuregit commit -m 'feat: add amazing feature'git push origin feature/amazing-featuregit clone https://github.com/adolfousier/invoicepilot.gitcargo buildcargo testcargo build && cargo testThank you for contributing to Invoice Pilot! 🚀
This project is licensed under the MIT License - see the LICENSE file for details.
This software is completely free to use, modify, and distribute for any purpose.
For issues, questions, or contributions, please open an issue on GitHub.
19 commits
Rust
90.7%
Shell
5.5%
PowerShell
2.6%
Just
1.0%