AI agents and AI coding assistants have changed how we approach software development, making it easier to turn ideas into functional applications.
For software developers, one of the best ways to improve your skills and demonstrate your abilities is by building projects that solve real-world problems and have practical use cases.
In this tutorial, you'll learn how to build a modern invoicing application that allows businesses to set up their profiles, create beautifully customized invoices, and send them directly to their clients' email addresses.
I'll also walk you through setting up Firebase for user authentication, real-time database operations, and file storage, and then share the AI prompts for designing and building the entire application with Claude Code, giving you a practical starting point for developing modern, full-stack web applications with AI agents.
Prerequisites
You don’t need prior experience with React or Next.js to build this application. However, having a basic understanding of React and Next.js will help you follow the code and understand how the different parts of the application work.
We will use the following tools and services to build the project:
- Firebase: A Backend-as-a-Service (BaaS) platform that provides the services we need for the application, including Firebase Authentication for user authentication, Cloud Firestore for storing and managing application data, and Cloud Storage for uploading and storing files.
- jsPDF: A JavaScript library for generating PDF documents. We’ll use it to generate PDF versions of invoices.
- Zernio Email API: An email API for sending invoices directly to clients’ email addresses, with the generated PDF invoices included as attachments.
App Overview
Before we start building, let’s look at how the invoicing application works and what users can do with it.
- Create an account: Users visit the application homepage and click the call-to-action button to create an account using their business email address or personal email address (for freelancers).
- Set up a business profile: After registering, users provide their business information, including their business name, logo, address, default currency, and payment details.
- Create invoices: Once their business profile is set up, users are redirected to the dashboard, where they can add customers and create customized invoices using any of the pre-built invoice templates. Each invoice includes the issuer’s and client’s addresses, invoice subject, line items, payment details, total amount, and any additional notes for the recipient.
- Send or download invoices: Users can send invoices directly to their clients’ email addresses from the application. Alternatively, they can download the invoices as PDFs, send them manually, or print copies for their clients.
- Track invoices and payments: The dashboard provides an overview of invoices sent, including total amounts grouped by currency and payment history organised by customer or invoice status. Users can track invoices marked as paid, outstanding, overdue, or draft. When a customer makes a payment, users can manually update the invoice’s payment status.
Below is a video walkthrough of the application, showing its interface and key features:
Setting Up Firebase
Firebase is a Backend-as-a-Service (BaaS) platform that provides the infrastructure and services for building web and mobile applications. It handles essential backend functionality, including database management, user authentication, and file storage, so developers can focus on building their applications without having to manage all the underlying server infrastructure.
For our invoicing application, we'll use three Firebase services:
- Cloud Firestore: To store and manage application data, including business profiles, customer information, and invoices.
- Firebase Authentication: To handle user registration and sign-in using email/password and Google authentication.
- Cloud Storage: To upload and store files, such as business logos and printable invoices.
To integrate Firebase into your Next.js application, follow the steps below.
Step 1: Create a new Firebase project
Visit the Firebase Console and sign in with your Google account. Click Create a new Firebase project to get started.
Enter a name for your project and click Continue. On the next screen, you can choose whether to enable Google Analytics for your project. Analytics is optional, so you can disable it if you don't need it.
If you choose to enable Analytics, select an existing Google Analytics account or create a new one. Once you've configured these settings, click Create project and wait for Firebase to finish setting up your project.
Step 2: Add a web app to your Firebase project
From your Firebase project dashboard, click Add app and select the Web (</>) icon to register a new web application.
Enter a nickname for your application and choose whether you want to set up Firebase Hosting. For this tutorial, we won't be using Firebase Hosting, so you can leave that option unchecked.
Click Register app to complete the registration process. Firebase will then generate a configuration object containing the credentials and project information required to connect your Next.js application to Firebase.
Keep this configuration; we'll need it when integrating Firebase into our application.
Step 3: Set up Firestore, Authentication, and Storage
Now that we've created our Firebase project and registered the web application, let’s enable the required Firebase services.
1. Set up Cloud Firestore
From the Firebase Console sidebar, navigate to Databases & Storage > Firestore and click Create database to create a new database for your invoicing application.
Select the Standard edition, choose a database location closest to your target users, and select Production mode when prompted to configure your initial security rules.
Click Create to finish setting up your database.
Note that Production mode initially denies read and write access from client applications. We'll need to configure the appropriate Firestore Security Rules soon.
2. Set up Cloud Storage
Next, navigate to Databases & Storage > Storage to configure file storage for your application.
Click Get started and follow the instructions to create your default storage bucket.
Important: Cloud Storage for Firebase currently requires your project to be on the Blaze (pay-as-you-go) plan. You'll need to link a Google Cloud Billing account and provide a payment method before you can create your storage bucket. Be aware that usage beyond applicable free allowances may incur charges.
3. Set up Firebase Authentication
Finally, navigate to Authentication from the Firebase Console sidebar and click Get started to configure user authentication.
Under the Sign-in method tab, enable the following authentication providers:
- Email/Password: Enable email and password authentication. Leave the Email link (passwordless sign-in) option disabled.
- Google: Enable Google authentication, select your email address as the project's support email, and save your changes.
Congratulations! You've successfully created your Firebase project and configured the essential services for your invoicing application.
Database Design for the Invoice App
In this section, you will learn how to structure the database for our invoicing application to ensure efficient data management and make it easier to create, retrieve, and manage invoices.
Before we proceed, it’s important to understand the three main entities in our application and how they relate to one another:
- User: Represents the business or individual issuing the invoices. Each user can manage multiple customers and create multiple invoices for them.
- Customer: Represents the recipient of an invoice. A customer can receive multiple invoices from the same business.
- Invoice: Represents an invoice issued by a business to a customer. Each invoice belongs to a user and is associated with a specific customer.
In addition to these records, we’ll use Firebase Storage to store files associated with the application, including business logos and generated PDF versions of invoices.
The diagram below shows how we’ll organize the data in Cloud Firestore, with the files stored in Firebase Storage.
Firebase Users Collection
When a user signs up or signs in to the application for the first time, a new document is created in the Firestore users collection using their Firebase Authentication UID as the document ID (users/{uid}). This document stores the user’s account information, business details, payment settings, and application preferences.
The document contains the following fields:
Field | Type | Description |
uid | string | Firebase Authentication UID, also used as the document ID. |
username | string | User’s display name provided during sign-up. |
string | User’s sign-in email address. | |
business | map | Business information (see BUSINESS). |
payment | map | Default payment information (see PAYMENT). |
zernio | map | Zernio Email API configuration (see ZERNIO). |
emailDesign | string | Default invoice email design, e.g. monolith. |
invoicePrefix | string | Prefix used when generating invoice numbers, e.g. INV-. |
invoiceCounter | number | Number of invoices created. The next invoice number is generated using the counter. |
defaultDueDays | number | Default payment term in days, e.g. 14. |
setupComplete | boolean | Indicates whether the user has completed the business setup process. |
createdAt | timestamp | Timestamp indicating when the user document was created, generated using Firebase server time. |
When a user first signs up, the business and payment maps are initially empty, while setupComplete is set to false. These fields are updated when the user completes the business setup process and provides their business and payment information.
The business, payment, and zernio maps hold the user’s business details, payment information, and Zernio Email API configuration, respectively. The emailDesign field stores the default email design used when sending invoices to customers.
Firebase Clients Collection
Since each user can have multiple clients, we’ll create a nested clients subcollection under each user’s document. This allows us to organise client records by business, making it easier to manage and retrieve the clients associated with a particular user.
The collection follows this structure in Firestore:
users/{uid}/clients/{clientId}
Here, {uid} represents the user’s Firebase Authentication UID and {clientId} represents the unique document ID assigned to each client. Each document in the clients subcollection stores information about an individual client.
The table below shows the fields we’ll store for each client:
Field | Type | Description |
clientId | string | Unique client document ID. |
name | string | Client’s name or company name. |
contactName | string | Name of the primary contact person. |
string | Billing email address, pre-filled when sending an invoice. | |
phone | string | Client’s phone number. |
address | map | Client’s address, including street, city, state, postalCode, and country. |
taxId | string | Client’s tax identification number or VAT number, displayed on invoices. |
currency | string | Default billing currency for the client. |
notes | string | Internal notes about the client, visible only to the business. |
invoiceCount | number | Total number of invoices created for the client. |
totalBilled | number | Cumulative value of the client’s invoices. |
createdAt | timestamp | Timestamp indicating when the client document was created, generated using Firebase server time. |
Firebase Invoices Collection
Similar to the clients collection, we’ll create a nested invoices subcollection under each user’s document. This ensures that every invoice created by a business is associated with the user who issued it.
The collection follows this structure in Firestore:
users/{uid}/invoices/{invoiceId}
Here, {uid} represents the business owner’s Firebase Authentication UID, while {invoiceId} represents the unique document ID assigned to each invoice. Each document stores the invoice details, including the associated client, business information, line items, payment details, and invoice status.
The table below shows the fields we’ll store for each invoice:
Field | Type | Description |
invoiceId | string | Unique invoice document ID. |
number | string | Formatted invoice number, e.g. INV-001. |
seq | number | Sequential invoice number: 1, 2, 3, etc. |
clientId | string | ID of the client associated with the invoice. |
clientOrderNumber | number | Sequential invoice count for the specific client, e.g. #001, #002. |
client | map | Snapshot of the client’s details when the invoice is issued. |
business | map | Snapshot of the business details when the invoice is issued. |
template | string | Invoice design or template used, e.g. standard. |
currency | string | Currency used for the invoice. |
issueDate | string | Date the invoice was created, formatted as YYYY-MM-DD. |
dueDate | string | Invoice payment due date, formatted as YYYY-MM-DD. |
items | array | Invoice line items (see LINE_ITEM). |
taxRate | number | Applicable tax percentage. |
shipping | number | Shipping amount. Stored in the document but not currently used in the invoice form. |
subtotal | number | Sum of all invoice line item amounts before tax and shipping. |
tax | number | Calculated tax amount. |
total | number | Final invoice amount due. |
payment | map | Payment information, including type (link or bank), link, and bank (copy of BANK). |
extra | map | Optional invoice subject and reference information. |
notes | string | Additional notes or instructions for the client. |
status | string | Invoice status: SAVED, SENT, or PAID. |
sentAt | timestamp | Timestamp indicating when the invoice was emailed, generated using Firebase server time. |
paidAt | timestamp | Timestamp indicating when the invoice was marked as paid, generated using Firebase server time. |
createdAt | timestamp | Timestamp indicating when the invoice document was created. |
updatedAt | timestamp | Timestamp indicating when the invoice was last updated. |
LINE_ITEM (each entry in the items array)
Each invoice contains an items array representing the individual products or services being billed to the client. Each entry follows this structure:
Field | Type | Description |
id | string | Unique identifier for the line item. |
description | string | Description of the product or service delivered. |
details | string | Optional additional information about the item. |
quantity | number | Quantity of items or number of hours billed. |
rate | number | Price per unit. The line item amount is calculated as quantity × rate. |
Using this data structure, each invoice is assigned a sequential number (seq) when it is created. This allows the application to generate unique invoice numbers, such as INV-001, INV-002, and INV-003.
The clientOrderNumber field also maintains a separate sequence for each client, making it easier to identify and organise the invoices issued to a particular customer.
Managing invoice statuses
Each invoice has a status field that tracks its progress through the invoicing process:
- SAVED: created and saved but has not yet been emailed to the client.
- SENT: sent to the client’s email address through the application.
- PAID: marked as paid by the business.
An invoice can also become OVERDUE when its payment due date has passed without being marked as paid. Unlike the other statuses, OVERDUE is calculated from the invoice’s dueDate and current payment status rather than stored directly in the status field.
When a user marks an invoice as paid, its status changes to PAID, and the paidAt field is updated with the corresponding timestamp.
Build an Invoice App with Claude Code
In this section, I’ll walk you through how to use Claude Code to build the invoicing application using a detailed prompt. The prompt covers the application’s architecture, user interface, Firebase integration, invoice management features, and email functionality.
Before we proceed, make sure you have Claude Desktop installed and configured on your computer. You’ll also need a Claude Pro subscription or higher to access Claude Code with the appropriate usage limits for this workflow.
Install Firebase CLI
First, install the Firebase CLI globally on your computer using the following command:
npm install -g firebase-tools The Firebase CLI allows you to interact with your Firebase projects from the terminal. We’ll use it to authenticate with Firebase and manage the project’s Firebase services during development.
Next, sign in to your Google account using the following command:
firebase login If you’ve previously authenticated and want to refresh your login credentials, you can use:
firebase login --reauth Once you’ve successfully signed in, you should see a confirmation message similar to the one below:
Build the application with Claude Code
Now that Claude Code and Firebase CLI are ready, you can now build the application.
Copy the prompts below into Claude Code to guide it through building the invoicing application, from the initial project setup to Firebase integration and implementation of its core features.
## TASK/DESIGN: I want you to build a modern, highly interactive invoicing application website for businesses and freelancers using Next.js, TypeScript, and Firebase, with a sleek user interface and smooth, engaging animations. Ensure that all pages are mobile-friendly and responsive across different screen sizes. The website should be production-ready, fully interactive, and user-friendly. Before writing any code, show me the designs for each page and wait for my approval before proceeding with the implementation. **You must present the designs first. I must approve them or request changes before you start writing any code.** ## PAGES: - `/` - A modern homepage with 5–7 sections, featuring engaging animations and strategically placed call-to-action buttons to convert visitors into users. - `/register` - User registration page supporting Google and Email/Password authentication. - `/login` - User sign-in page. - `/business/setup` - Business setup page where users can provide their business information, upload their business logo, and configure other relevant details. - `/dashboard` - Main dashboard for managing customers, invoices, and payments. - Other pages as required to support the application's functionality. ## ROLES and PERMISSIONS: Businesses should be able to add customers and create, read, update, and delete invoices associated with their customers. Businesses should also be able to send invoices as printable PDF attachments directly to their customers' email addresses using - jsPDF - Zernio Email API: https://docs.zernio.com/products/email ## CODE STRUCTURE - Use a `components` folder to organise reusable page components and individual page sections. - Import and reference these components within their respective pages. - Store images in an `images` folder at the root of the project. Use high-quality images wherever necessary. - Follow the DRY (Don't Repeat Yourself) principle to maintain clean, reusable, and readable code. - Create a `firebase.ts` file and a `firebase-actions` file to organise Firebase configuration and the various operations required to handle application data securely and efficiently. - You can also create a `styles` folder for reusable styles. Congratulations! You’ve successfully built your invoicing application. Check out the live demo to see it in action and explore the source code on GitHub.
Conclusion
In this tutorial, you’ve learnt how to build a modern, full-stack invoicing application using Next.js, TypeScript, Firebase, and Claude Code. You’ve also explored how to structure your Firestore database, implement user authentication, manage customers and invoices, generate printable PDF invoices, and send them directly to clients’ email addresses using the Zernio Email API.
With well-structured prompts and clear technical requirements, developers can use AI coding agents to plan application architecture, generate components, integrate backend services, implement features, and debug code. Rather than replacing the developer’s understanding of software engineering, these tools can accelerate development and help turn ideas into functional software products.
If you’d like to explore these technologies further, here are some helpful resources worth reading:
- Frontend to FullStack: Introduction to Firebase (Firebase v9)
- Build an Invoice Management System Using React & Firebase v9
- How to Build an AI Social Media Post Scheduler Using Gemini and Zernio API in Next.js
- Full Stack Software Development Projects
Thank you for reading!











