Automatically extract and organize expenses from bank statements (PDFs/images) into Google Sheets using AI, n8n, and a modern web interface. One-command Docker setup.
AI Expense Tracker is a low-code automation built with n8n that leverages OpenAI, Google Drive, and Google Sheets to automate personal finance tracking.
Two ways to use it:
- π Web App β Upload receipts and bank statements (PDFs or images) via a simple Next.js interface
- π Google Drive β Drop files into a folder and let automation handle the rest
Just upload your bank statement PDF or receipt image, and the workflow will:
- Extract the data using AI (supports PDFs and images).
- Categorize each expense intelligently.
- Append the results to a structured Google Sheet dashboard.
Inspired by "El Hombre MΓ‘s Rico de Babilonia" and "La Bolsa o la Vida", this project promotes financial awareness and digital independence through automation.
- π³ Docker Support β One-command setup with Docker Compose. Works on any machine.
- π Web App Interface β Upload receipts and bank statements via a simple web UI (supports PDFs and images).
- Google Drive Integration β Drop your bank statement PDFs into a folder, and the system takes it from there.
- AI-Powered Parsing β Uses GPT-4o to read and structure your expenses into JSON.
- Categorization Agent β Classifies expenses into fixed categories (Supermarket, Gastronomy, etc.).
- Automatic Google Sheets Sync β Generates a new "Expenses {Month}" tab and appends all transactions.
- Open Source β Fully local, no external servers, and zero maintenance cost.
The easiest way to get started is with Docker Compose. This will set up both the n8n automation engine and the web app in one command.
- Docker and Docker Compose installed.
- A Google Cloud Project with:
- Google Drive API enabled.
- Google Sheets API enabled.
- A Google Sheet based on the provided template (
/templates/balance.xlsx).
-
Clone the repository
git clone https://github.com/matiasvallejosdev/ai-expense-tracker-n8n.git cd ai-expense-tracker-n8n -
Configure environment variables
cp .env.example .env
Edit
.envand add your Google Sheets dashboard URL:NEXT_PUBLIC_DASHBOARD_URL=https://docs.google.com/spreadsheets/d/YOUR_SPREADSHEET_ID/edit
-
Create the n8n volume
docker volume create n8n_data
-
Start all services
docker-compose up -d
-
Access the applications
- Web App: http://localhost:3000 (Upload PDFs and images of receipts/statements)
- n8n Dashboard: http://localhost:5678 (Configure workflows and credentials)
-
Configure n8n credentials
- Go to http://localhost:5678
- Import the workflow from
/n8n/ai-expense-tracker-n8n.json - Set up Google Drive OAuth2 and Google Sheets OAuth2 credentials
- Use the redirect URI:
http://localhost:5678/rest/oauth2-credential/callback
-
Upload your first expense
- Go to http://localhost:3000
- Upload a bank statement PDF or receipt image (JPG, PNG)
- Watch it automatically appear in your Google Sheet!
π Need help with Docker? Check out the Docker Guide for detailed explanations.
# Stop all services
docker-compose down
# View logs
docker-compose logs -f
# View logs for specific service
docker-compose logs -f web-app
docker-compose logs -f n8n
# Restart services
docker-compose restart
# Rebuild and restart (after code changes)
docker-compose up --build -d
# Stop and remove everything (including volumes - β οΈ deletes n8n data)
docker-compose down -vIf you prefer to run n8n manually without Docker:
- n8n installed locally.
- A Google Cloud Project with:
- Google Drive API enabled.
- Google Sheets API enabled.
- A Google Sheet based on the provided template (
/templates/balance.xlsx).
- Clone the repository
git clone https://github.com/matiasvallejosdev/ai-expense-tracker-n8n.git cd ai-expense-tracker-n8n - Import the workflow
- Go to your local n8n dashboard.
- Import
/n8n/ai-expense-tracker-n8n.json.
- Configure credentials
- In n8n β Credentials, create:
Google Drive OAuth2Google Sheets OAuth2
- Use the redirect URI:
http://localhost:5678/rest/oauth2-credential/callback - Follow Googleβs guide for OAuth setup: Create OAuth Client ID
- In n8n β Credentials, create:
- Connect your template
- Upload the provided
/templates/balance.xlsxto your Google Drive. - Rename it if you wish, but keep a tab named βExpenses Modelβ.
- Upload the provided
- Set your folder trigger
- In the workflow, edit the node Google Drive Trigger and replace the folder ID with your own.
- Run it
- Upload a PDF statement into that folder.
- Watch your Google Sheet auto-populate with parsed transactions!
This is where you should upload your bank statement PDFs. π Open the Drive Folder
Each file you drop there (e.g. statement_visa.pdf) will trigger the workflow and automatically process it.
All categorized data will be appended automatically to this Google Sheets template: π Open the Google Sheets Template
Or click Make a Copy to create your own editable version.
Backend (n8n Workflow)
- n8n workflow automation
- OpenAI GPT-4o for text extraction and categorization
- Google Drive API
- Google Sheets API
Frontend (Web App)
- Next.js 16 (React 19)
- TypeScript
- Tailwind CSS 4
- Shadcn/ui components
- React Hook Form + Zod validation
- Docker multi-stage builds
-
Customize Agents
AI Agentβ parses raw text from PDF/image.AI Agent β Structure Dataβ converts it into a valid JSON array.
-
Processing Flow
- Web Upload/Google Drive Trigger β Download File β Extract Text (OCR for images) β AI Parse β JSON Normalize β Filter Transactions β Append to Sheet.
-
Script Filters
- Automatically ignores tax lines (
IVA,Percepciones,Impuesto de Sellos, etc.) and USD duplicates.
- Automatically ignores tax lines (
-
Web App Development
cd web-app npm install npm run devThe app will be available at http://localhost:3000
-
Output Schema
Field Type Description Monthstring Month extracted from transaction date Datestring ISO date (YYYY-MM-DD) Conceptstring Transaction detail Payment_Methodstring Credit Card / Debit Card / Cash Categorystring Expense category Amountnumber Value of transaction Currencystring ARS / USD
Fixed Taxonomy
| Currency | Payment Method | Expense Categories | Income Categories |
|---|---|---|---|
| ARS, USD | Credit Card, Debit Card, Cash | Supermarket, Gastronomy, Services, Fashion, Transport, Technology, Home, Education, Sports, ... | Salary, Freelancing, Investment, Business, Extra |
You can extend these categories directly in the AI prompts or in the Google Sheet data validation lists.
Option 1: Web App (Next.js)
- User uploads file via web interface (http://localhost:3000)
- File sent to n8n webhook endpoint
- n8n processes the file
Option 2: Google Drive Trigger
- User drops file in Google Drive folder
- n8n watches folder and detects new files
- n8n downloads and processes the file
- File Input β Web upload or Google Drive trigger
- Extract File Data β Converts PDF/image to text using OCR and AI
- Data Parser & Cleaner β Formats the raw text
- AI Agent (GPT-4o) β Extracts transactions from text
- AI Agent β Structure Data β Converts to JSON array
- Parse JSON Output β Validates structure
- Aggregate β Duplicate Sheet β Append to Sheet β Final output in your balance template
Everything runs locally on your machine through Docker β your data stays 100% private.
- n8n (port 5678) β Workflow automation engine
- web-app (port 3000) β Next.js frontend for file uploads
Both services communicate over a Docker bridge network.
- Open the web interface at http://localhost:3000
- Upload your expense document:
- β Bank statement PDFs
- β Receipt images (JPG, PNG)
- β Ticket photos from your phone
- Wait for AI processing (usually 5-10 seconds)
- Check your Google Sheet β new transactions appear automatically!
-
Upload PDF β Wait for execution β Open your Google Sheet.
-
The system auto-creates a new sheet for each month:
Expenses Oct 2025 -
Filter, analyze, or connect to dashboards.
-
Works perfectly with the included balance template dashboard.
Contributions are welcome! If you want to improve parsing logic, add new categories, optimize the workflow, or enhance the web app:
- Fork the repository.
- Create a feature branch.
- Make your changes:
- n8n workflows: Edit JSON files in
/n8n/ - Web app: Edit files in
/web-app/ - Docker setup: Update
docker-compose.ymlorDockerfile
- n8n workflows: Edit JSON files in
- Test your changes with Docker:
docker-compose up --build
- Commit and push your changes.
- Open a Pull Request.
Guidelines:
- Include a redacted PDF/image example if your update changes extraction logic
- Test both input methods (web app and Google Drive) if modifying the processing pipeline
- Update the README if you add new features or change setup steps
If you have questions, suggestions, or want to collaborate:
- Name: MatΓas Vallejos
- π matiasvallejos.com
- π @mativallejosdev
This project is open source and available under the MIT License.
βControl your money, or your money will control you.β β La Bolsa o la Vida
βStart thy purse to fattening.β β El Hombre MΓ‘s Rico de Babilonia