LeadHub CRM
A B2B sales CRM whose pipeline and lead-scoring rules live in one TypeScript domain layer shared by client and server.
- TypeScript
- React
- Node.js
- Express
- SQLite (Turso / libSQL)
- Docker
The problem
LeadHub is a sales CRM for teams that sell custom software, AI solutions and technology consulting: capture leads, qualify them, run the pipeline, send proposals and close deals in one place. Pipeline value, win rate and lead scores have to give the same answer on the dashboard and on the server.
Architecture
How LeadHub is put together
Browser
- React app, screens loaded on demand
- Public inquiry form
shared/, used by client and server
- model.ts: stages and statuses
- calc.ts: weighted pipeline, win rate, scoring
- schemas.ts: Zod schema for every write
Express 5 server
- Sessions, scrypt hashing and roles
- CSP, headers and rate limits
- Business rules, activity log, duplicate checks
SQLite via Turso (libSQL)
- Versioned, append-only migrations
- Foreign keys guard deletes
Key decisions
- One source of truth for the rules.
- Every calculation lives in shared/calc.ts and every write’s validation in shared/schemas.ts, so the dashboard and the server always agree: the server enforces the schemas, the client shows the same field errors.
- The database refuses bad deletes.
- A company cannot be deleted while it has leads, opportunities or invoices, and a lead’s primary contact cannot be deleted. The server also rejects a lead whose contact belongs to a different company.
- Migrations only move forward.
- Schema changes are appended to a list in server/db.ts, and each runs once, inside a transaction.
- Status follows the work.
- Logging the first call moves a lead to Contacted and booking discovery moves it to Discovery Scheduled; leads only move forward, and every change is written to the record’s timeline.
Proof
Weighted pipeline, win rate and qualification score
Zod schemas shared by client and server
Versioned migrations and transactions
End-to-end API tests: lifecycle, permissions, concurrent writes
CI: type checks, tests, build and a Docker smoke test
What it doesn’t do yet
- It does not send email, calendar invites or push notifications yet; reminders stay in the app.
- Proposal documents are not generated, and their views are not tracked.
- There is no CSV import or export, and one installation serves one organisation.
- The live CRM holds a real team’s data, so sign-in is by invitation; the public inquiry form is open to try.