Sultan Kautsar

Building a Personal CRM on Cloudflare's Free Plan

The paperwork for my own clients lived in a small Python invoice app. It knew my clients, quotes, invoices, and payments, but it had no deals, no tasks, and no mail, so the story of each project lived in my inbox and my head.

Between November 14 and 22 I built a CRM to hold all of it, moved the invoice app's data in, and retired the old app. This note covers the stack, the order I built it in, how the invoices kept their exact totals and numbers, what the free plan ruled out, and what is still open.

5 min read

What It Holds

Leads, contacts, companies, deals on a pipeline board, and tasks, each with notes and an activity timeline. On top of that: a product catalog, quotes and invoices with payments, files on any record, an inbox that sends and receives mail, a calendar, reports, custom fields per record type, and CSV import and export. There is one user, me, so it has no sign-up, no teams, and no billing.

Stack

  • Interface: React 19, TypeScript under strict settings, and Vite, with coss ui components on Base UI and Tailwind CSS v4, set in Geist and Geist Mono.
  • Routing and data: TanStack Router for typed routes with filters in the URL, TanStack Query for server state, and TanStack Table for lists.
  • Server: one Cloudflare Worker that serves the built interface and a Hono API on /api.
  • Storage: D1 through Drizzle for records, and R2 for attachments.
  • Sign-in: Cloudflare Access with an owner-only policy. The API verifies the Access token itself and fails closed.

It is a single-page app with no server rendering. Everything sits behind a login and nothing needs to be indexed, so rendering on the server would only add parts to maintain. coss ui has no data table, kanban board, or chart, so I built those on its primitives with TanStack Table, dnd-kit, and Recharts.

  1. Browser React and coss ui, filters kept in the URL
  2. Cloudflare Access Owner-only sign-in in front of every request
  3. Worker Hono API, token check, inbound mail handler
  4. D1 and R2 Records and their history in D1, files in R2

Building It in Phases

The roadmap had ten phases, and each one ended with the full check passing and a review before the next began. In broad steps:

  1. Screens first, on mock data. Every screen went through a Repository interface backed by localStorage, so I could click through and review the whole app before any backend existed.
  2. Then the real backend. The D1 adapter implements the same interface, and the same browser tests run against both the API and the mock build.
  3. Then integrations. Quotes, attachments, mail, the calendar, reports, and CSV came next, followed by invoices.
  4. Then real data. I removed the demo seed and its “Reset demo data” button. Once the database holds real clients and invoices, a button that loads fake data over them is a hazard. The tests build their own small dataset instead.

The browser tests run every route on desktop and mobile, in light and dark, with an accessibility check from axe. That check is what found muted text in the dark theme failing contrast, so the theme adjusts it away from the coss default.

Matching the Old Invoices

The CRM could only replace the invoice app if old documents fit without loss and new ones came out the same. That meant porting its rules, not approximating them:

  • Money is calculated in the old order: round each line, subtract the discount (never below zero), then add each tax on the discounted amount, each rounded. Amounts are integer minor units, and the unit tests recompute all eight old documents.
  • Numbering is INV-2026-001 and QUO-2026-001, restarting each year, so imported numbers continue without a gap.
  • Each document keeps a copy of the sender and the client as they were. Drafts refresh that copy on every save, and sent documents keep what they were sent with.
  • The print template is a port of the old one, with labels in six languages. I checked a printed invoice page by page against the PDF the old app made.
  • Imported quotes and invoices keep their original PDFs as attachments.

Importing and Retiring the Old App

npm run import:invoice reads the old app’s JSON files and PDFs and maps them onto the CRM. By default it is a dry run that prints the documents, totals, and payments it would create. It refuses to run if a document number or company already exists, so it cannot import twice. Every paid invoice is checked: its payments must equal the old app’s paid amount and leave nothing due, or the import stops. With --apply, it uploads the PDFs to R2 and then writes everything to D1 in one SQL file.

The old app had no deals, so I wrote them by hand in a small JSON file: which company, which quotes and invoices, and the date each stage was reached. The importer builds the pipeline and a dated timeline from it and refuses unknown companies, documents used twice, or stage dates out of order.

Locally that meant 2 companies, 2 quotes, 6 invoices, and 5 original PDFs, with every paid amount matching. The same import ran against production. On November 22 the old app’s folder was deleted and kept as an archive with its git history.

Staying on the Free Plan

The CRM runs on Workers Free, D1, the R2 free tier, Zero Trust Free for Access, and Email Routing. The one paid piece would be sending mail to clients, which the free plan does not allow: the send_email binding delivers only to verified addresses in the account. So the inbox sends only to me, and Reply on a received message opens my mail app. Receiving mail costs nothing, so a message to the CRM’s address lands in the inbox and links itself to a contact by address.

Deploys run from GitHub Actions on every push to main: the full check, then D1 migrations, then wrangler deploy. A second workflow exports the database every day and keeps the export for 90 days.

Limitations

  • Lists load whole collections and filter in the browser. That is fine at my scale but needs server paging past a few thousand rows.
  • CSV import creates one row per request, up to 2,000 rows a file, and deals and tasks are export only.
  • Dashboard totals count only deals in the default currency. There is no conversion.
  • Outgoing mail is plain text with no attachments, and inbound mail over 5 MB is rejected.
  • If deleting a file from R2 fails after its database row is gone, the object is left behind. The order is chosen so the reverse, a row pointing at a missing file, cannot happen.

Lessons

Build the screens before the backend
Reviewing every screen on mock data caught layout and flow problems while they were cheap. Swapping in the API was one module, and the same tests proved both worked.

Remove demo data before real data arrives
A seed and a reset button are handy in week one and dangerous once the database holds real invoices. I deleted both before the import, not after.

Match the old system’s rules exactly
Porting the rounding order and numbering meant imported totals and numbers matched exactly, and the old PDFs stayed a reference I could check against.

Let the plan’s limits shape the feature
I kept outbound mail to my own address instead of paying for a feature my normal mail app already covers.

Next step

Have a project in mind? Let's talk.

See how I work and what it costs, or email me. I usually reply within one working day.

Write to Me

Tell me about your project or idea. I usually reply within one working day.