No. 79Backend8 min read2,140 words
How to build a custom CRM: your team will actually use
How to build a custom CRM: when it beats HubSpot or Salesforce, the MVP feature set, a Postgres data model, permissions, imports, email sync and cost drivers.
- Written by
- Lazy Devs
- Published
- Updated
- Sources
- Cited inline

Key takeaways · 05
The short version
- 01Build a custom CRM only when your pipeline, data or follow-up rules genuinely do not fit off-the-shelf tools. If your sales process is ordinary, buy one.
- 02A CRM MVP is contacts, companies, deals with your own stages, activity logging, a pipeline view and instant search. Ship that to a few reps before building reports or automation.
- 03The data model is the product. Plan for contacts changing companies, deals involving several people, merges and an activity timeline that stays fast with hundreds of entries.
- 04Build record ownership in from day one, even if everyone can see everything at first. Retrofitting permissions onto a CRM that assumed open data is a painful migration.
- 05Imports with de-duplication and two-way email sync are each projects in their own right. Budget for them deliberately, and consider a BCC-to-log address before full sync.
On this page · 11
Build a custom CRM when your sales process genuinely does not fit HubSpot, Salesforce or Pipedrive, and start small: contacts, companies, deals with your own stages, activity logging, a pipeline view and instant search. Get the data model and record ownership right early, and treat data imports and email sync as the separate projects they are.
Most teams do not need "a CRM". They need the three or four things their sales process does every day, done in a way that matches how they actually work. The big platforms can do almost everything, which is exactly why reps rarely enjoy opening them. A custom CRM wins when your pipeline, your data and your follow-up rules are unusual enough that off-the-shelf software fights you more than it helps.
What a CRM is, and when custom makes sense
A CRM (customer relationship management system) is the system of record for the people and companies you sell to, and the conversations that move them toward a deal. Reports, automations and dashboards are all built on top of that record.
The one job it must do well: make it faster to update a deal than to not. A CRM that reps skip is worse than no CRM, because now your data lies to you. Every design decision flows from that rule.
Build or buy?
| Signal | Buy a hosted CRM | Build a custom CRM |
|---|---|---|
| Sales process | Standard lead, opportunity, close | Multi-party approvals, unusual stages, regulated steps |
| What a "customer" is | A person at a company | Households, clinics, sites, vehicles, projects |
| Data you need to join | Sales data only | Your own product, billing, operations or field data |
| Reps' behaviour | Happy to log in the CRM | Living in spreadsheets because the CRM is too slow or wrong |
| Integrations | Covered by the marketplace | Internal systems with no off-the-shelf connector |
| Budget priority | Lowest cost now | Fit and adoption over years |
If most of your answers are in the left column, buy one and move on. We give that advice regularly. Our build vs buy comparison and the post on internal tools: build vs buy go deeper on the trade-off, including the hidden costs of both routes. If your "customers" are really clients, matters or engagements, custom software for professional services firms covers the systems that usually sit next to the CRM.
The CRM MVP feature set
Build the smallest thing a real rep can run their week on.
Build first
- Contacts and companies, with a clean relationship between them.
- Deals that move through stages you define, attached to a company, the people involved and an owner.
- Activity logging. Notes, calls, emails and tasks, all timestamped and linked to a contact, a deal or both.
- A pipeline view. A board or list where a rep sees what is theirs and what needs attention today.
- Instant search. Reps look things up constantly, and slow search kills adoption faster than any missing feature.
- Record ownership, even if everyone can see everything for now.
That is a CRM. Ship it, get a few reps using it daily, then build phase two from what they complain about.
Build later
Email and calendar sync, follow-up sequences, reporting dashboards, lead scoring, granular permissions, quoting, and integrations with billing or support tools. All useful, all easier to scope once you have real usage instead of guesses. Resist building reporting before anyone has entered a deal.
The data model is the product
CRMs look like simple CRUD apps. They are not. A contact changes jobs and now belongs to a different company, but you still want their history. A deal involves three people at two companies. A company is acquired and its record has to merge with another. Activity needs to attach to a contact, a deal or both. Get the schema wrong and every feature after it gets harder.
A starting point worth stealing:
create table companies (
id uuid primary key default gen_random_uuid(),
name text not null,
domain text,
owner_id uuid references users(id),
created_at timestamptz not null default now()
);
create table contacts (
id uuid primary key default gen_random_uuid(),
company_id uuid references companies(id) on delete set null,
full_name text not null,
email text,
phone text,
owner_id uuid references users(id),
created_at timestamptz not null default now()
);
create table deals (
id uuid primary key default gen_random_uuid(),
company_id uuid references companies(id),
owner_id uuid references users(id),
title text not null,
stage text not null default 'new',
amount_cents bigint,
currency char(3) not null default 'USD',
closed_at timestamptz,
created_at timestamptz not null default now()
);
-- a deal usually involves more than one person
create table deal_contacts (
deal_id uuid not null references deals(id) on delete cascade,
contact_id uuid not null references contacts(id) on delete cascade,
role text, -- champion, decision maker, finance...
primary key (deal_id, contact_id)
);
create table activities (
id uuid primary key default gen_random_uuid(),
contact_id uuid references contacts(id) on delete cascade,
deal_id uuid references deals(id) on delete cascade,
user_id uuid references users(id),
kind text not null, -- note | call | email | task
body text,
due_at timestamptz, -- for tasks
created_at timestamptz not null default now(),
check (contact_id is not null or deal_id is not null)
);
create index on deals (owner_id, stage);
create index on activities (contact_id, created_at desc);
create index on activities (deal_id, created_at desc);A few choices worth explaining:
- Money is stored as integer minor units with a currency code, never as floating point.
- The
deal_contactsjoin table lets one deal involve several people with roles, which is how real B2B deals work. - The
checkconstraint stops orphaned activities that belong to nothing. - The indexes serve the timeline, the screen reps look at all day. It gets slow the moment a customer has a few hundred interactions, so indexing it from day one is the feature, not premature optimisation. Our guide to database indexing for application developers explains how to choose them.
Pipeline stages: a table, not a string
The example uses a text stage for brevity. In a real build, stages usually live in their own table with an order, a probability and a "won" or "lost" flag, so sales managers can rename and reorder them without a deploy. Keep a stage history table too: when a deal entered each stage is what powers every useful pipeline report later.
Permissions get political fast
"Can a rep see another rep's deals?" sounds like a checkbox. It is actually a question about how your company sells, and the answer changes when you hire a manager, add a region or split a deal that someone else sourced.
A sensible progression:
- Day one: every record has an owner, and everyone can see everything.
- When a team grows: reps edit their own records and see the rest read-only.
- When regions or partners arrive: visibility by team or territory, with managers seeing their team's records.
Enforce the rules in one place on the server, not scattered across UI components. Postgres row-level security is one option for enforcing visibility inside the database itself. Retrofitting ownership onto a CRM that assumed open data is a painful migration, which is why the owner column is in the MVP.
Imports, duplicates and merges
Your data is coming from a spreadsheet, an old CRM or both, and it is messy: duplicate companies, half-filled contacts, deals with no owner. A good import flow is often more work than the pipeline view, and skipping it means reps lose trust in the data in week one.
What a decent import and merge flow includes:
- Column mapping with a preview before anything is written.
- Matching on email address and company domain, plus fuzzy matching on names. The Postgres pg_trgm extension handles similarity search well and also speeds up partial-name search.
- A review queue for likely duplicates, rather than silent auto-merging.
- A merge tool that moves activities, deals and notes onto the surviving record and keeps an audit trail.
- The ability to undo an import batch.
Plan the switch-over carefully. The week reps move from the old system is the riskiest week of the project. Clean and validate the import, and run both systems in parallel for a short period if you can.
Email and calendar sync
Two-way email sync, where a rep's threads appear on the contact automatically, is genuinely valuable and genuinely expensive. It involves OAuth, mailbox permissions, change notifications, rate limits, threading and a lot of edge cases.
- Gmail supports push notifications for mailbox changes, and Microsoft 365 offers the equivalent through Microsoft Graph change notifications.
- Reading Gmail content uses restricted scopes, and Google's restricted scope verification process can include a third-party security assessment. Factor that into the timeline before promising the feature.
- You also need rules for what not to log: personal email, internal threads and anything sensitive.
A lighter first step gets most of the value: a BCC or forwarding address that logs any email sent to it against the matching contact. Ship that, see whether reps use it, and build full sync as its own phase if they do. This is typical automation and integrations work, and it is where much of a custom CRM's value ends up living.
The stack we would reach for
Nothing exotic, because a CRM lives or dies on reliability and speed, not novelty.
- Next.js and TypeScript for the app and API. Server Components with small client islands keep the pipeline and timeline fast without a heavy single-page app.
- Postgres for the data. Its relational model, constraints and search features are exactly what a CRM needs.
- A hosted auth provider or proven library, with SSO if you sell to larger teams internally.
- A background job queue for email sync, reminders, imports and scheduled reports.
- An audit log of who changed what, which sales managers will ask for sooner than you expect.
The frontend is the easy part. The value is in the data model and the integrations.
What drives the cost
We do not quote numbers for a CRM we have not scoped. The main cost drivers:
| Component | Relative effort | Notes |
|---|---|---|
| Contacts, companies, deals, activities, pipeline, search | Moderate | The MVP; a matter of weeks |
| Imports, de-duplication and merges | Moderate to high | Depends on how messy your current data is |
| Roles and visibility rules | Moderate | Cheap if ownership exists from day one |
| Reporting and dashboards | Moderate | Easier with stage history recorded from the start |
| BCC-to-log email capture | Low to moderate | Most of the value of email sync for a fraction of the work |
| Two-way email and calendar sync | High | OAuth, provider review, edge cases, ongoing maintenance |
| Sequences and automation | High | Scheduling, sending limits, unsubscribe handling |
The honest framing: a custom CRM rarely beats off-the-shelf on raw cost. It beats it on fit, and fit is what gets your team to actually use it.
Common mistakes to avoid
- Building for the org chart instead of the rep. Managers want dashboards. Reps want to log a call in two seconds. Optimise for the rep's daily flow first, or the dashboards will be empty anyway.
- Treating it as a one-time build. A CRM grows with your sales process: new stages, fields, integrations and rules. Plan for ongoing iteration.
- Underestimating data migration. Bad imports erode trust permanently.
- Over-customising the data model. Forty custom fields per record helps nobody. Add a field when a rep can name the decision it helps them make.
- Skipping the audit trail. When a deal value changes, someone will want to know who changed it and when.
A CRM often grows into neighbouring tools. Many of the teams we talk to next want a B2B quoting tool that turns a deal into a priced proposal, or a customer portal where clients see their own orders and documents. Designing the CRM's data model with those in mind saves a rewrite later.
Where to start
- Write down your real pipeline stages and what moves a deal between them.
- List what a "customer" is in your business and how records relate.
- Build the MVP data model, pipeline view, activity logging and search.
- Import a clean subset of real data and put a few reps on it.
- Let their complaints decide phase two: imports, permissions, email capture or reporting.
A custom CRM is worth it when your sales process is genuinely yours and off-the-shelf tools make your team work around them. This is exactly the kind of system we build: data-heavy, integration-heavy and only useful if people adopt it. If you are weighing whether to buy or build, talk to us and we will give you the honest answer, even when it is "just buy a hosted CRM".
FAQ · 05 questions
Frequently asked questions
Is it worth building a custom CRM?
It is worth it when your sales process, data shape or integrations make off-the-shelf CRMs a constant workaround, and when reps avoid logging activity because the tool does not fit. If your process is standard, a hosted CRM is cheaper and faster. A custom CRM rarely wins on raw cost. It wins on fit and adoption.
How long does it take to build a CRM?
A focused first version with contacts, companies, deals, activities, a pipeline view and search is a matter of weeks for a small senior team. Imports and merge tooling, permissions, reporting and email or calendar sync each add meaningful time, and email sync is usually the largest single item.
Can I build a CRM on top of a spreadsheet or no-code tool?
You can prototype one that way, and it is a good way to learn what your team really needs. It tends to break down on permissions, data integrity, performance with large activity histories and integrations, which is usually the point where teams move to a custom build or a hosted CRM.
What database is best for a CRM?
A relational database such as Postgres. CRM data is full of relationships between people, companies, deals and activities, and you need constraints, transactions and flexible queries for reporting. Postgres also handles full-text and fuzzy search, which helps with lookup and duplicate detection.
How do I sync emails into a custom CRM?
The full approach connects each rep's mailbox through the Gmail API or Microsoft Graph with OAuth, listens for change notifications and matches messages to contacts by email address. A lighter first step is a BCC or forwarding address that logs any email sent to it against the matching contact.