ChristmasSALE
--
Days
--
Hours
--
Minutes
--
Seconds
Book a call
ChristmasSALE
--
Days
--
Hours
--
Minutes
--
Seconds
Book a call
GLITCH40% OFF
Christmas Offer40% OFF
--
Days
--
Hours
--
Minutes
--
Seconds
Claim 40% Off
GLITCH40% OFF
Christmas Offer40% OFF
--
Days
--
Hours
--
Minutes
--
Seconds
Claim 40% Off
All articles

How to Build an AI-Powered Expense Tracker Using Gemini, n8n and Supabase

Brittni Fernando 17 min read
How to Build an AI-Powered Expense Tracker Using Gemini, n8n and Supabase

Introduction

Managing personal expenses is one of those tasks that seems simple until you actually have to do it consistently. Every purchase needs to be recorded, categorized and organized. Some transactions come from online orders, others arrive as email receipts, and many are forgotten before they ever make it into a spreadsheet.

Now imagine being able to enter an expense in a sentence, such as "Uber ride to the office, 10 USD", and have an application automatically identify the merchant, extract the amount, assign a category and save everything in the right place.

This is where AI-powered application development becomes interesting.

With large language models (LLMs), developers can build applications that understand everyday language and turn unstructured information into data that software can work with. When combined with workflow automation and a database, these capabilities can be used to solve practical problems without requiring every interaction to be handled manually.

In this article, we explore how to build an AI-powered expense tracker using React, Supabase, n8n and Google's Gemini API. We will look at how the different technologies work together, how AI extracts information from everyday expense descriptions, and how the application can be extended to process receipt emails automatically.

The project comes from Metana's free How to Build Your Own AI Agent workshop. You can watch the full recorded workshop and get the starter code and a step-by-step PDF guide there, then use this article as a companion that explains how each part fits together.

What Is an AI-Powered Expense Tracker?

A traditional expense tracker usually requires users to enter information into predefined fields. You might need to select a category, enter the amount, choose a date and provide a description for every transaction.

An AI-powered expense tracker takes a different approach. Instead of requiring structured input, it allows users to describe an expense naturally and uses an AI model to identify the relevant information.

For example, consider the following entry:

User input: "Bought groceries for $35 yesterday."

The application can send this description to Gemini and ask it to extract the relevant details.

FieldExtracted information
MerchantNot specified
Amount35
CurrencyUSD
DateYesterday
CategoryShopping or Groceries
DescriptionGrocery purchase

The AI converts the original sentence into structured information that can be stored in a database.

This is particularly useful because people do not always describe transactions in the same way. One person might write "Lunch at a restaurant, $12", while another might enter "Spent twelve dollars on lunch". A language model can interpret both descriptions without requiring users to follow a strict input format.

The same idea can be extended beyond manual entries. Receipt emails can also be collected, processed and converted into expense records automatically.

The goal is not simply to add a chatbot to an expense tracker. It is to make the application more capable of understanding and processing the information users already have.

The Technology Stack Behind the Project

Building an application like this requires more than an AI model. Each technology has a specific responsibility, and the application depends on these components communicating correctly.

Here is the technology stack used in the project.

TechnologyPurpose in the application
ReactProvides the frontend where users enter and view expenses
SupabaseStores expense records in a PostgreSQL database
n8nConnects services and manages automated workflows
Google Gemini APIExtracts structured information from expense descriptions
GmailProvides receipt and billing emails as an additional input source

Let's look at why each component matters.

React: Creating the User Interface

React is used to build the frontend of the application. It provides the interface where users can enter expenses and view the information after it has been processed.

The frontend is responsible for collecting user input and displaying the results. It does not need to handle the AI processing itself. Instead, it communicates with Supabase, which stores the submitted information.

This separation keeps the user interface focused on its main purpose while the backend services handle data processing and automation.

Supabase: Managing the Expense Database

Supabase provides the database layer for the application. It uses PostgreSQL to store information in structured tables.

The project uses an expenses table containing fields such as:

  • id: A unique identifier for each expense.
  • raw_input: The original text submitted by the user or received through email.
  • merchant: The merchant or service associated with the transaction.
  • amount: The transaction amount.
  • currency: The currency used.
  • expense_date: The date of the transaction.
  • category: The assigned expense category.
  • description: A description of the purchase.
  • source: Where the information originated, such as manual entry or email.
  • status: Whether the expense is pending, completed or requires review.
  • confidence: The AI's confidence in its extraction.
  • needs_review: Whether the record should be checked manually.

An important design decision here is to store the original input before processing it.

When a user submits an expense, the application first saves the original description in raw_input. Gemini processes this information afterwards, and the extracted details are added to the same record.

This preserves the original information and makes it easier to review the AI's interpretation if something goes wrong.

n8n: Automating the Workflow

n8n is the automation layer that connects the different services.

It allows developers to create workflows using individual nodes, with each node performing a particular action. For example, one node can receive a webhook, another can send information to Gemini, and another can update a database record.

Instead of manually writing a separate backend integration for every service, developers can use n8n to organize these operations into workflows. Our roundup of the best AI automation tools compares n8n with the alternatives.

In this project, it handles both manual expense processing and the collection of receipt emails.

Google Gemini: Extracting Information From Text

Gemini is the language model responsible for understanding the expense descriptions.

It receives the original text and extracts the information required by the application. Rather than returning a general explanation, it is instructed to produce structured JSON containing the relevant expense fields.

This makes the model's response easier for the automation workflow to process and store.

The important distinction is that Gemini handles interpretation, while the surrounding application handles validation, storage and updates.

How the AI Expense Tracker Works

The application follows a straightforward architecture. Information enters through the frontend or Gmail, gets stored in Supabase, passes through an automated workflow and is processed by Gemini.

The overall process can be understood through five stages.

1. Capturing the Original Expense

The process begins when a user enters an expense through the React interface.

For example:

"Uber ride to office, 10 USD."

When submitted, the application creates a new record in the Supabase expenses table. The original description is stored in the raw_input field, while the extracted information is left for the AI workflow to populate.

This gives the system a consistent starting point, regardless of how the user describes the transaction.

2. Triggering the Workflow With a Webhook

Once a new expense record is inserted, a Supabase Database Webhook sends a notification to n8n.

A webhook allows one application to notify another when a particular event occurs. In this case, the event is the creation of a new expense record.

The notification tells n8n that there is new information to process.

This is more efficient than repeatedly checking the database to see whether another expense has been added.

3. Using Gemini to Structure the Information

The n8n workflow sends the original expense description to Gemini through the Google Gemini node's Message a Model operation.

The prompt tells Gemini which fields to extract and how the response should be formatted.

For example, it can request:

  • Merchant name
  • Transaction amount
  • Currency
  • Expense date
  • Category
  • Description
  • Confidence score
  • Whether the entry needs review

The model is also instructed to use predefined categories and return JSON only.

This matters because the workflow expects a consistent response. If Gemini returns a paragraph explaining the expense instead of the requested data, the next stage cannot reliably process it.

The prompt also establishes rules for incomplete information. For example, the model should not invent missing details, and unclear entries should be flagged for review.

4. Parsing and Validating the Response

Gemini's response is returned as text, so it needs to be converted into data that the application can use.

An n8n Code node handles this process. It removes unnecessary Markdown formatting, parses the JSON and checks that the amount is a valid number.

It also retrieves the original database record's ID from the webhook information.

This is important because the workflow needs to update the correct expense rather than accidentally creating another record.

The workflow then determines whether the entry can be marked as completed or should be flagged as needs_review.

This introduces an important principle in AI application development: an AI response should not automatically be treated as valid just because the model returned an answer. The application still needs to check the output before using it.

5. Updating the Database and Displaying the Result

Once the information has been parsed, n8n sends it back to Supabase.

The workflow uses the original expense ID to update the existing record with the extracted details.

The React application can then display the completed expense, including its merchant, amount, category and date.

The user does not need to manually enter each field. The application takes the original description and handles the rest of the process.

Going Beyond Manual Entries: Automating Expenses Through Gmail

Manual entry is only one way to collect expense information.

Think about how many purchases already generate digital records. Online shopping platforms send order confirmations, subscription services send billing notifications, and businesses often send invoices and receipts directly to your inbox.

Instead of asking users to enter all this information again, the expense tracker can collect relevant emails automatically.

This is where the second n8n workflow comes in.

How the Gmail Integration Works

The project uses two separate workflows.

Workflow 1: Email Intake

This workflow handles incoming emails.

  • A Gmail Trigger checks for newly received messages.
  • The Get a message node retrieves the email content.
  • The workflow creates a new record in Supabase, storing the email subject and receipt details in raw_input.

The record is marked as an email source and given a pending status.

Workflow 2: AI Processing

This is the same workflow used for manual expense entries.

  • A Supabase Webhook detects the new record.
  • Gemini receives the email content.
  • A Code node parses the response.
  • Supabase updates the original expense record.

The advantage of this design is that both manual entries and email receipts use the same AI processing logic.

There is no need to create a completely different extraction process for every input source.

Filtering Emails Before Processing

One challenge with email automation is that not every incoming message is a receipt.

If the Gmail Trigger processes every new email, newsletters, promotional messages and unrelated conversations could also become expense records.

The workflow can be configured with Gmail search filters that look for terms such as receipt, invoice, bill and payment confirmation.

A more controlled approach is to create a Gmail label, such as Expenses, and configure Gmail filters to apply it to messages from known billing sources. The n8n workflow can then process only emails carrying that label.

Even with filtering, some unrelated messages may still get through. This is another reason to retain the original email content and include a review status in the database.

Important Design Decisions When Building AI-Powered Applications

The expense tracker demonstrates several ideas that are useful beyond this particular project.

These are not just implementation details. They are decisions that help make an AI-powered application more reliable and easier to maintain. They are also the kind of skills employers now look for, as our guide to the AI skills worth learning explains.

Keep the Original Input Separate From AI-Generated Data

One of the most useful decisions is storing the original expense description before processing it.

AI models can misunderstand information, especially when the input is incomplete or ambiguous. Keeping the original text makes it possible to compare the model's interpretation against what the user actually submitted.

It also gives the application a record of the original information if the AI-generated fields need to be corrected.

Use Structured Output Instead of General Responses

A language model can generate detailed explanations, but that does not mean those explanations are suitable for every application.

In this project, Gemini is instructed to return JSON with predefined fields.

This gives the workflow a consistent structure to work with and makes it easier to validate the response before saving it.

When building applications that depend on AI-generated information, the output format should be designed around what the rest of the system actually needs.

Separate Input Collection From AI Processing

The project uses one workflow for Gmail intake and another for AI processing.

This keeps the responsibilities separate. The email workflow collects information, while the processing workflow interprets and structures it.

The same processing workflow can then be reused by multiple input sources.

This is a useful approach when building applications that may eventually receive information from different services, forms or messaging platforms.

Prevent Unnecessary Workflow Loops

There is another technical detail worth paying attention to when connecting Supabase to n8n.

The database webhook should listen for new record insertions only.

If it also listens for updates, the workflow could trigger itself again when Gemini's extracted information is written back to the database. This can create repeated executions and unnecessary API usage.

Configuring the webhook to listen only for inserts prevents this particular loop.

Include Human Review Where Necessary

AI extraction is useful, but it is not guaranteed to be correct.

The project includes a confidence field and a needs_review flag so that uncertain entries can be identified.

This is particularly important when processing emails, where the content may include incomplete information or details that are not actually related to an expense.

A good AI application should make it clear when information needs human attention rather than treating every model response as accurate.

What Could You Build on Top of This Project?

Once the basic expense tracker is working, it can become the foundation for more advanced features.

The database already contains structured expense information, and the automation workflow provides a way to process new data. These capabilities can be extended in several directions.

1. Receipt Recognition With Image and PDF Uploads

Instead of relying only on text descriptions and emails, users could upload photographs or PDF copies of receipts.

Supabase Storage could hold the uploaded files, while Gemini could be used to extract information from their contents.

The project already includes a receipt_path field in its database structure, which can be used to reference uploaded receipts.

This would make the application useful even when a digital receipt is not available in an email.

2. Build an AI Spending Assistant

Another extension would be to let users ask questions about their spending.

For example:

  • How much did I spend on food this month?
  • What was my biggest expense last week?
  • How much am I spending on subscriptions?
  • Which expense category accounts for the largest share of my spending?

An AI assistant could use the structured expense records to answer these questions in natural language.

This moves the application beyond recording transactions and toward helping users understand their spending patterns. If you want to go further and let the assistant choose its own tools, our guide to AI agents for developers explains how agents work.

3. Generate Automated Spending Summaries

The application could also generate weekly or monthly summaries.

These summaries might include total expenses, category breakdowns and changes in spending over time.

Using n8n, the system could schedule these summaries and send them through email or chat.

4. Add Personal Budgets and Custom Categories

Users could define their own expense categories and budget limits.

For example, someone might set a monthly dining budget and want the application to highlight when spending approaches that amount.

These rules could also be incorporated into the AI prompt to make categorization more relevant to individual users.

5. Connect More Input Sources

Gmail is only one possible source of expense information.

The same architecture could be extended to accept information from forms, other messaging services or additional integrations.

As long as the incoming information can be stored in the original input field and passed to the processing workflow, the existing AI extraction logic can be reused.

Security Considerations Before Using Real Financial Data

Although the workshop produces a working application, the initial setup is intended for learning and uses fictional expense data. It should not be used to store real financial information without additional security measures.

There are several important steps to complete before using it in a real environment.

Add authentication. Users should sign in through Supabase Authentication, and each expense should be associated with the relevant user through a user_id column.

Enable Row Level Security (RLS). RLS policies should restrict users to accessing their own expense records. This prevents one user from viewing another person's information.

Protect API keys. Secret keys should never be placed in frontend code or committed to a public GitHub repository. The Supabase service role key should remain securely stored in n8n.

Secure the webhook. A secret header should be added to the Supabase webhook and checked in n8n so that unauthorized requests cannot trigger the workflow.

Monitor workflow executions and API usage. The n8n Executions tab can help identify failed workflows, while Gemini API usage should be monitored to avoid unexpected limits or costs.

One important detail is that the Supabase service role key bypasses RLS. This means database permissions and the automation's access need to be configured carefully.

These measures are essential when moving from a workshop project to an application that handles real user information.

Frequently asked questions

Do You Need Coding Experience to Build an AI Expense Tracker?

You do not need extensive coding experience to follow the workshop. The project provides a React frontend, and much of the integration is handled through n8n's visual workflow builder.

However, understanding basic concepts such as APIs, databases, webhooks and JSON will make it easier to understand how the application works and troubleshoot problems.

Why Use n8n Instead of Writing the Entire Backend From Scratch?

n8n provides a visual way to connect services and automate tasks. Instead of writing separate integrations for Supabase, Gmail and Gemini, developers can configure individual nodes and connect them into workflows.

It is particularly useful for projects where the main requirement is connecting existing services and automating a sequence of operations.

What Is the Difference Between an AI Agent and an AI-Powered Workflow?

An AI-powered workflow follows a predefined sequence of operations. In this project, the workflow sends information to Gemini, processes the response and updates the database.

An AI agent generally has more autonomy. Depending on its design, it may decide which tools to use, choose between different actions and determine how to approach a task.

Although this project comes from a workshop about building AI agents, its expense-processing workflow uses a standard Gemini model interaction rather than an autonomous AI Agent node.

Can the Expense Tracker Process Receipt Images?

The workshop focuses on manual text entries and Gmail receipts. However, receipt image and PDF processing is a suggested extension.

The database includes a receipt_path field that can be used to reference uploaded files, and the project discusses using Gemini to extract information from those receipts.

Is the Workshop Version Ready to Store Real Financial Information?

No. The initial setup is designed for fictional data and leaves Row Level Security disabled.

Before using real financial information, the application needs authentication, appropriate RLS policies, protected credentials and webhook security.

Take Your AI Software Engineering Skills Further With Metana

Building an AI-powered expense tracker is a practical introduction to how modern applications bring together frontend development, databases, APIs, language models and workflow automation. But this is only one example of what you can create when you understand how these technologies work together.

If you want to develop the skills to build applications like this from the ground up, Metana's AI Software Engineering Bootcamp provides a hands-on learning path covering JavaScript, React, backend development, databases, LLM APIs and RAG. Our guide on how to become an AI software engineer shows where projects like this fit on that path.

If you would rather build automations like this without writing code, the AI Automation Bootcamp teaches n8n, Zapier and Make in four weeks.

Through practical projects, you can learn how to connect different technologies, integrate AI capabilities into applications and develop the skills needed to build complete software products.

The best way to understand AI development is to put these concepts into practice. Start building, experiment with modern AI technologies and turn your ideas into working applications.

TopicsAI Automation
Brittni Fernando

Written by

Brittni Fernando

Brittni Fernando is a software developer with an interest in artificial intelligence and modern software engineering practices. Her work spans full-stack development, AI-assisted coding, and research into emerging AI technologies. Through her writing, she explores software development concepts, practical coding techniques, and the growing role of AI in building software, making technical topics easier to understand and apply.

You may also like

How To Become An AI Automation Specialist
AI & Machine Learning

How To Become An AI Automation Specialist

AI automation is no longer a buzzword, it is the engine driving digital transformation across industries. As companies race to integrate intelligent systems that cut costs and boost efficiency, the demand for AI automati

Metana EditorialOctober 13, 2025Read
ChatGPT alternatives
AI & Machine Learning

11 Alternatives to Use Instead of ChatGPT 5.1

ChatGPT isn’t the only powerful AI, moving into 2026. Claude Sonnet 4.5 leads in coding and reasoning, Gemini 3 Pro dominates multimodal tasks, and Perplexity AI excels at real-time research. Budget-friendly options like

Metana EditorialJanuary 14, 2026Read
AI Automation Bootcamp
AI & Machine Learning

17 Most Valuable Benefits of Attending an AI Automation Bootcamp

AI automation bootcamps go beyond teaching technical skills — they reshape how learners think and solve problems. Through structured, hands-on learning, participants tackle real-world challenges, gain experience with cut

Metana EditorialNovember 6, 2025Read
Google Antigravity vs Cursor AI
AI & Machine Learning

Google Antigravity vs Cursor: AI-Powered Coding IDEs Differences

Google Antigravity and Cursor are shaping the future of AI powered development. Antigravity leans into agent first automation with a central control system, while Cursor delivers fast, developer guided multi agent workfl

Metana EditorialJanuary 27, 2026Read
Types of cybersecurity
AI & Machine Learning

What are the General Types of Cybersecurity?

Cybersecurity is not one discipline. It is eight overlapping domains, each protecting a different layer of your organisation's digital environment. Ransomware targets endpoints. DDoS floods networks. Phishing exploits id

Metana EditorialMay 25, 2026Read
deep learning vs machine learning
AI & Machine Learning

What is the difference between deep learning and machine learning?

Machine learning and deep learning are both subsets of AI, each with distinct characteristics. Machine learning uses simpler algorithms and requires human intervention to select features, making it suitable for structure

Metana EditorialAugust 27, 2025Read
More AI & Machine Learning articles →

Talk to an advisor

Book a call with a real human before the next cohort fills.

Speak with an advisor. We'll map the right program to your goals - and lock in your enrollment offer.

20% off enrollment offer

20% OFF - limited-time enrollment offer.

Applied automatically when you book a call before the timer hits zero.

--
Days
--
Hours
--
Minutes
--
Seconds
  • Guarantee: Job or 100% money back
  • Expert-curated curriculum
  • On-demand mentor support
Advisor Elena RodriguezAdvisor Sarah JenningsAdvisor David Chen
Real advisors · reply within 2 hours

Book your call

Free