Skip to content
Own product · Web · 2026

Rah CRM

The system where I run my software business: clients, proposals, contracts, hours, invoices, servers and the AI agents that work with me, all in one place.

Role
Product, architecture and development
When
September 2026 to date
Team
Solo, with AI agents on the code
Status
Live and in daily use
Rah CRM home dashboard with a greeting, receivables, overdue amounts, monthly hours and this week's deadlines
CRM home on a phone with a greeting and cards for receivables and overdue amounts
Today screen on a phone with overdue items and today's tasks
01. Context

Five Tools Doing the Job of One

Rah CRM links deals, proposals, contracts, projects, hours and invoices; a phone shows a paid invoice alongside 31 phases in production.
From first contact to paid invoice, in a single CRM.

Working with several clients at once, the business was scattered: contacts on WhatsApp, proposals in a document, hours in Kimai, tasks in Planka, invoices in a spreadsheet and passwords somewhere else. Checking whether a client was up to date meant opening five tabs.

Off-the-shelf CRMs cover sales and stop there. None of them connects the commercial side with technical delivery: hours that become invoices, contracts that become projects, servers that need attention and the AI agents that now write a good part of the code.

The challenge

Build, alone and quickly, a system that holds client data, contracts and money, with the security of a paid product and without turning into a pile of screens nobody uses.

02. Decisions

The Choices That Held Up the Growth

  1. 01

    Docs Before Code

    Every phase starts with a PRD, a journey and a prompt for each screen. A screen only becomes code after its image is approved, and the result is compared against it. That is what let 31 phases ship without the system becoming a patchwork.

  2. 02

    Rules on the Server, UI in Next

    The FastAPI backend owns every business rule. Next.js 16 only draws the interface and talks to the API through a client generated from OpenAPI. If the contract changes and the client does not, the pipeline blocks the deploy.

  3. 03

    Paid-product Security

    Database-backed sessions with a protected cookie, CSRF and mandatory two-factor authentication, following OWASP ASVS level 2. Sensitive actions, such as creating an API token, ask for the password and code again.

  4. 04

    A Queue Inside Postgres

    Reminders, Kimai sync, alerts and AI routines run on a queue that lives in Postgres itself (Procrastinate). One less piece to maintain, no Redis, and no lost jobs when the server restarts.

  5. 05

    AI That Helps, Not Decides

    AI drafts proposals, builds contracts from the clause library and summarizes the day. Prices never come from it, and whatever it suggests stays flagged until someone confirms. External agents reach the CRM through MCP, with a token and per-tool permissions.

  6. 06

    A Workspace on Every Row

    Every table has had a workspace since day one. Only I use it today, but the path to a multi-customer product is already in the database, not in a future refactor.

  7. 07

    WhatsApp on a Third-party Engine, with Our Own Screens

    Conversations run on Chatwoot behind the scenes, through its API only: it connects the numbers (official and unofficial) and stores the messages, while every screen belongs to the CRM. An adapter of our own isolates the vendor, the webhook arrives signed with HMAC and a repeated message is never duplicated. There are chatbot flows with handoff to a human. It is live, waiting for the first number to be connected.

  8. 08

    Proposals and Contracts That Build Themselves

    Proposals are made of blocks, with a preview of the real PDF, versions, a public link and acceptance with optional items. An accepted proposal becomes a contract with clauses from the library and a signing link. AI drafts the contract from a plain request and revises the whole document block by block, showing the diff so each change can be accepted one at a time.

  9. 09

    An AI Hub Built for Continuous Improvement

    Every agent has a purpose and a health record (context, quota, failures). Every skill has a score for adherence and problem rate, and the system opens signals by itself: unused skill, expensive index, missed opportunity, skill that underperforms. Each fix goes to an improvement board with before and after measured.

  10. 10

    Several AI Providers Behind a Single Door

    Anthropic, OpenAI, Gemini, Groq and OpenRouter come in through the same contract. Each feature on screen picks its connection and model, respects the daily quota and the monthly cap, falls back to a backup when the main one fails and records the cost. On OpenRouter, the request already carries free backup models.

03. On mobile

The Business in Your Pocket

The CRM is responsive end to end. On the phone you can see what is overdue, mark an invoice as paid, move a deal through the pipeline and keep an eye on the AI between meetings.

  1. 01 Home. The same dashboard on the phone, in cards that fit the screen.

  2. 02 Today. Today brings together what is overdue and what is due now, from invoices to tasks.

  3. 03 Pipeline. The whole pipeline on the phone too, with totals at the top.

  4. 04 Invoice. An overdue invoice: send a reminder on WhatsApp or record the payment right there.

  5. 05 Receivables. What comes in, when, and who is late, at a glance.

  6. 06 AI hub. AI agent usage, tracked from anywhere.

04. On desktop

From First Contact to Paid Invoice

On the desktop the CRM covers the whole cycle: sales pipeline, proposal, weekly hours, cash forecast and the hub that tracks the server AI agents.

Home. Home shows what needs attention: money coming in this month, what is late, hours and this week's deadlines.
Pipeline. The pipeline as a board, with total and weighted value per stage and a flag on deals with no next step.
Proposal. A proposal starts from the deal, with text, items and terms. Then it becomes a PDF, an acceptance link and a contract.
Hours. Weekly hours by project, with a timer, Kimai import and a weekly cap for each contract.
Receivables. Six-month cash forecast, separating what was invoiced, what was paid and what is still only in the contract.
AI hub. The AI hub tracks the agents working on the server: which skills they read, how much they use and where they fail.

* Screenshots from a local environment running the production version with fictional data. No company, person or amount shown here is real.

05. Engineering

Under the Hood

A system with contracts, client passwords and money cannot rely on hidden buttons. The protections live in the API, and each one is tested.

Stack

  • Python 3.14
  • FastAPI
  • SQLAlchemy 2
  • PostgreSQL
  • Procrastinate
  • Next.js 16
  • React 19
  • TypeScript
  • Tailwind CSS 4
  • TanStack Query
  • MinIO
  • MCP
  • Docker
  • Azure DevOps
OpenAPI contract, two-factor authentication, 1,053 API tests, 391 E2E tests and 103 migrations before the API is replaced in Azure DevOps.
API safeguards, real database tests and migrations before deploy.

Safeguards

  • Mandatory two-factor authentication, with code reuse blocked and throttling per account and per IP
  • Password and code asked again to create an API token or change the AI hub
  • Links with a password or key pasted in the wrong field are rejected before reaching the database
  • Attachments go straight to MinIO through signed URLs, with the file type checked by its first bytes
  • Integration credentials encrypted with AES-GCM and external addresses checked against SSRF
  • Insert-only audit trail, enforced by a trigger in the database itself
  • CSV export protected against formula injection, and gitleaks blocking secrets at commit time

Tests and Quality

  • pytest
  • Testcontainers
  • Hypothesis
  • mypy
  • Vitest
  • Testing Library
  • MSW
  • Playwright
  • axe
  • API tested with pytest against a real Postgres in a container, mypy in strict mode and property tests with Hypothesis
  • UI tested with Vitest, Testing Library and MSW, with request types generated from the API contract
  • Full journeys in Playwright with accessibility checks by axe, which already caught real contrast issues that got fixed
  • Azure DevOps pipeline that checks the contract, runs only the side that changed and applies the migration before swapping the API
06. Inside the code

What You Would Find in the Repository

The code is private, so here is what is inside it: the practices, where they live and a number to check. Feel free to ask about any of them.

Architecture

  • Feature folders

    api: 40 modules · web: 39 features

    Each business topic is one folder with route, service, schema and model together, in the API and in the UI. Changing contracts does not mean opening ten folders.

  • Rules live in the API

    docs/01-arquitetura/adr/ · 7 ADRs

    Next.js only renders: no Server Actions, no API routes, no database access. The decision is recorded in an ADR, with the reasoning.

  • Ports and adapters where vendors change

    agents/llm/port.py · 5 adapters

    AI and WhatsApp sit behind interfaces of our own. Swapping Chatwoot for another engine, or adding an AI provider, touches no screen and no business rule.

  • Monorepo with the contract in the middle

    apps/api · apps/web · packages/api-client · e2e

    API, UI, generated client and E2E in one repository, so a contract change moves on both sides together.

Types and Validation, in Two Layers

  • Static types on both sides

    mypy strict · tsc strict

    Python with mypy in strict mode and TypeScript with strict on. A type error does not reach the commit.

  • Runtime validation at the edge

    schemas.py in every module

    Every API input goes through a Pydantic schema and comes back with the exact field that failed. The type says what should arrive; validation checks what did.

  • Frontend typed by the contract

    export_openapi.py --check

    Request types are generated from the API OpenAPI. If the contract changes and the client does not, pre-commit and the pipeline block it.

  • AI output is validated too

    contracts/ai.py · proposals/revise.py

    Whatever the AI returns goes through the same block validator: known types and variables only, limited size. Text from the user is reference material, not an instruction.

Tests

  • TDD where there is math

    docs/01-arquitetura/testes.md §7

    Hour value, balance, due dates and authentication were born with the test before the code: red, green, refactor.

  • API tested against real Postgres

    1,053 tests · pytest -n 3

    Tests start Postgres in a container, no fake database, and run in parallel in the pipeline. Property tests with Hypothesis catch the case nobody thought of.

  • Component tests for the UI

    893 cases in 134 files

    Vitest, Testing Library and MSW mocking the API, next to each screen.

  • End-to-end journeys

    391 tests in 48 specs

    Playwright walks the full flows in the browser and axe checks accessibility on every screen. It has already caught real contrast and focus bugs.

  • Migrations and AI are tested as well

    test_migrations.py · agents/evals/

    Each migration goes up, is compared with the models, goes down and up again. Agents are evaluated with a different model acting as judge, with weighted criteria.

Database

  • Versioned migrations

    103 migrations

    The schema only changes through Alembic migrations, and the pipeline applies them before swapping the API version.

  • Ready for many customers

    ADR 0005 · workspace_id

    Every table has the workspace since the first migration. Becoming a multi-customer product does not mean redoing the database.

  • Concurrency handled

    FOR NO KEY UPDATE · 21 files

    Row locks where two actions can collide, with the right kind of lock so it does not fight the audit foreign key. A repeated webhook hits a unique key and is not duplicated.

  • Fast search with no extra service

    p95 from 1.75 s to 122 ms

    Fuzzy search with pg_trgm inside Postgres, tuned until it fit the agreed time with 10,000 companies.

  • Rules in the database too

    CHECK in 79 migrations · partial index in 24

    Check constraints and partial indexes keep the rule even if the code gets it wrong, and the audit trail only accepts inserts, enforced by a trigger.

Delivery and Operations

  • A gate before every commit

    .pre-commit-config.yaml

    Ruff with security rules, mypy, ESLint, tsc, the affected tests, the API contract and gitleaks run on every commit.

  • A pipeline that tests only what changed

    azure-pipelines.yml

    In Azure DevOps, a UI-only change does not run the API suite, and the migration runs before the deploy. API, worker and server agent ship separately.

  • Lean containers, no root

    USER app · multi-stage

    Multi-stage images running as their own user, with memory and CPU caps on the server.

  • Logs you can query

    structlog · 43 files

    Structured JSON logs with the request context, instead of loose prints.

AI in the Development Process

  • Documents before code

    docs/03-fases · 37 folders

    Every phase has a PRD, a journey with a checklist and the prompt for each screen. AI writes code from a reviewed document, not from a loose request.

  • Several agents, each with its role

    BRIEFING.md per phase

    One agent plans, reviews and writes the backend and the end-to-end tests; another implements screens from a briefing; a third reads the screen designs. Every diff is reviewed before the commit.

  • Skills as practice guides

    ai/scores.py

    Agents load practice guides per task: security, tests, database, LLM evaluation. The CRM itself measures whether each guide is being used and whether it helps.

  • A second opinion on sensitive parts

    docs/01-arquitetura/seguranca.md

    The authentication design and code were reviewed by a different model, with a different bias: 13 findings in the design and 8 in the code, all fixed before going live.

07. Today

Where It Stands

The CRM is live and it is where I work every day: real clients, proposals, contracts, hour closings and invoices all go through it.

Next up are the lead funnel and campaigns (phases already written) and, further on, opening the system to other people with their own workspace.

Next step

Have a Similar Project in Mind?

I like problems with real people on the other side. Tell me what you need.