Build Invoice Ninja
YESreplaces $14/mosaves $168/yrback to the verdict
A small invoicing app for one freelancer: clients, invoices with line items and tax, numbers that never repeat, a snapshot frozen at send time so a sent invoice can never silently change, a clean PDF, email delivery, optional Stripe payment links, and a CSV your accountant can use. If you want the whole platform, Invoice Ninja itself is open source; this is the lighter option.
Before step 1
Everything below is assumed from the first step. Tick each one when you actually have it, not when you plan to.
- installfree
Why Everything in this build runs on it: the server, the scripts, the tests.
Get it Download the LTS installer from nodejs.org, or install with your package manager (brew install node, or nvm install 22). Restart the terminal afterwards. open ↗
Verify
node --version prints v22 or higher - installfree
Why Every step below is a command you type or a file you edit.
Get it VS Code (code.visualstudio.com), Cursor or Zed. Open a folder for the project and use the editor's built-in terminal. open ↗
Verify
You can open a folder and run a command in its terminal - installfree
Why History for your code, and the way most hosts deploy.
Get it Install from git-scm.com or with your package manager, then run git init in the project folder once it exists. open ↗
Verify
git --version prints a version - have readyfree
Why Every PDF carries them: legal name, address, tax id if any, bank or payment details, payment terms, and a logo file.
Get it Write them into config/business.json; a PNG or SVG logo at least 400px wide.
- installfree, 170 MB of disk
Why PDF rendering needs a browser. npm install puppeteer downloads it; on a small server you may need extra system libraries.
Get it npm install puppeteer downloads Chromium. On Ubuntu servers install the libraries Puppeteer's troubleshooting page lists. open ↗
Verify
node -e "require('puppeteer').launch().then(b=>b.close())" exits without error - API keyfree tiers exist
Why Phase 5 emails the PDF to clients.
Get it Fastmail, Postmark or your mail host: host, port, user, password as an app password.
- API keyfree; fees per payment
Why Phase 6 puts a pay-online link on each invoice.
Get it dashboard.stripe.com > Developers > API keys. Use test mode until the flow works. open ↗
- decidefree
Why This app does arithmetic on rates you type in; it does not know your jurisdiction. Decide the rates and the invoice number format now.
Get it Write down the VAT or sales tax rates you charge and the prefix format, e.g. INV-2026-001.
Data model
Create these before the first phase that stores anything. Changing a table later is the expensive kind of change.
- `clients`: id, name, email, address, currency, default_rate_cents, notes
- `invoices`: id, number (unique), client_id, issue_date, due_date, currency,
status ('draft' | 'sent' | 'paid' | 'void'), notes, terms, sent_at, paid_at,
stripe_link, snapshot (JSON)
- `line_items`: id, invoice_id, position, description, quantity, unit_price_cents,
tax_rate
`snapshot` is not optional. When an invoice is sent it must freeze the client's
name, address and every line as they were at that moment. Editing a client's
address must never change what a sent invoice says · that is a document you gave
someone, and silently rewriting history is the bug that ends in a dispute.Environment variables
These go in a .env file the app reads at startup. The pack's .env.example is this table as a file · copy it, never commit the filled-in version.
| Variable | Needed | Example | Where the value comes from |
|---|---|---|---|
PORT | required | 4840 | Bound to 127.0.0.1. |
DATABASE_PATH | required | ./data/invoices.db | SQLite file. |
PDF_DIR | required | ./data/pdf | Generated PDFs, kept forever. |
SMTP_URLsecret | required | smtps://user:pass@smtp.fastmail.com:465 | From your SMTP provider. |
MAIL_FROM | required | 'You' <billing@yourdomain.com> | From address on invoice emails. |
STRIPE_SECRET_KEYsecret | optional | sk_test_... | Stripe dashboard, test mode first. Empty disables payment links. |
INVOICE_PREFIX | required | INV | Prefix for numbers: INV-2026-001. |
The build, in order
Clients
Clients with currency and rate, and a delete that refuses to orphan invoices.
clients (id, name, email, address, currency, default_rate_cents, notes), invoices (id, number unique, client_id, issue_date, due_date, currency, status, notes, terms, sent_at, paid_at, stripe_link, snapshot JSON), line_items (id, invoice_id, position, description, quantity, unit_price_cents, tax_rate).
terminalmkdir invoices && cd invoices && git init && npm init -y && npm pkg set type=module npm install express@4 better-sqlite3@13 mkdir -p data/pdf config && cp .env.example .env
done when · tick each as it passesInvoices and line items
Totals to the cent and numbers that never collide or reuse.
Subtotal, tax and total in integer cents, rounding once at the end.
INV-2026-001 style, never reused after a delete; gaps are fine, duplicates are not.
done when · tick each as it passesStatus and the snapshot
Sending freezes the document; editing after requires a revision.
Copy the client's name, address and every line into snapshot; render sent invoices from it only.
The only way to change a sent invoice.
done when · tick each as it passesPDF
A clean one-page PDF from your template, byte-identical when regenerated.
Logo, business details, line table, totals, terms and payment details from config/business.json.
Files
templates/invoice.htmlterminalnpm install puppeteer@23
Reuse one browser instance; close pages in finally.
done when · tick each as it passesEmail
Sent means sent; failure leaves it a draft with the error visible.
- terminal
npm install nodemailer@6
done when · tick each as it passesPayment links
A Stripe link per invoice, paid marked by hand.
- terminal
npm install stripe@17
done when · tick each as it passesDashboard and books
What is unpaid, and an export your accountant can use.
The export is what makes this handover-able to an accountant.
done when · tick each as it passesBackup and deploy
Database and PDFs backed up together, one restore performed.
- terminal
tar czf backups/invoices-$(date +%F).tgz data/
The numbering rule, where PDFs live, and the tax disclaimer in plain language.
Files
README.md
done when · tick each as it passesOperate it like a productproduct builder
Only for the product-builder path: know when the invoicing app is down, never lose the database, and keep the server patched.
Answer 200 with the build id and a quick database read. Point a free uptime monitor (or your own, from the Healthchecks entry on this site) at it so an outage is noticed before a user notices.
One JSON line per request: method, path, status, duration, no raw IPs. Rotate weekly with logrotate, keep eight.
SQLite's .backup command makes a consistent copy while the app runs. Copy it to object storage or a second machine; then, once, restore it into a fresh checkout and confirm the app reads it.
terminalsqlite3 data/app.db ".backup '/tmp/app-$(date +%F).db'" rclone copy /tmp/app-$(date +%F).db remote:backups/
Firewall allowing only 22, 80 and 443; unattended security updates on; the app running as an unprivileged user under systemd with Restart=on-failure.
done when · tick each as it passes
That is the whole plan for Invoice Ninja. What it deliberately does not cover is below · check the gaps before you call it a replacement.
- Quotes, expenses, multi-user, a client portal: that is the platform, free to self-host.
- Automatic payment reconciliation.
- Tax compliance. This does arithmetic on rates you type; it is not e-invoicing compliant anywhere.
- managed hosting
- upgrades
- backups
- support
- payment setup convenience
- reduced ops risk
- Recurring invoices generated on a schedule
- A read-only client link to view and pay an invoice
Need the files? The project pack on the verdict page hands your agent the whole brief · more finance & accounting.