[ SaaS Product ]

Garnet CRM

Multi-tenant CRM for field sales and collections teams

THE CHALLENGE

Field sales teams record visits, orders, deliveries, and cash across many people and areas. The numbers pass through several hands, and when someone asks who changed a balance, there is often no answer. I wanted one system where each level of a company sees only what it should, the money follows normal accounting rules, and every change leaves a trail.

ROLE:Full-Stack Developer
YEAR:2026
TYPE:SaaS Product
STATUS:In Development

TECH STACK

Next.jsTypeScriptPrismaSupabaseResendnext-intlTailwind CSS
I

Engineering Approach

Organization Structure as the Model

Modeled a company as regions, areas, and teams, with regional and area managers, salespeople, and collectors. Roles are assigned by the level above, and each area manager gets separate daily reports from sales and collections.

Permission Engine with Access Levels

Each person has one access level, either a prepared role or a custom checklist of permissions. Only owners create and edit access levels, and the most sensitive permissions are limited to the owner and accountant.

Tenant Isolation by URL

Every organization lives under its own URL, and a person sees only the organizations they belong to. Onboarding is by invitation.

Design Before Code

Wrote a design document and worked through the rules first: credit limits, payment allocation, post-dated cheques, returns, and who can approve what. The code then enforces decisions that were already made.

II

Key Technical Decisions

The choices that shaped the architecture and how easy it is to maintain.

Scoped visibility, money never edited, everything audited

Three promises, fixed before building.

WHY

When people hand over cash, trust has to come from the system. Fixing these rules early means every later feature has to respect them.

One access level per person

Customizing an access level means saving a new one, with no per-person exceptions.

WHY

Exceptions pile up until nobody can explain who can do what. One level per person keeps permissions explainable.

The system does not issue invoices

Receipts carry whatever invoice or VAT numbers each company enters on its own form.

WHY

Invoicing rules differ by company and country, so the product stays general and out of that scope.

A credit limit is the only order block

Overdue amounts are shown, but only the credit limit stops an order.

WHY

One predictable rule is easier to work with than several overlapping holds.

III

Challenges & Solutions

[ CHALLENGE ]

The first organization model was too flat. Real teams have regions above areas and several collectors per area.

[ SOLUTION ]

Reworked the structure to regions, areas, and teams before building on top of it.

[ CHALLENGE ]

Password reset by email needed a custom sender and a verified domain.

[ SOLUTION ]

Set up Resend as the sender with a custom reset email template, so reset works end to end in production.

[ CHALLENGE ]

The preview deployment kept failing even though the code was fine.

[ SOLUTION ]

The environment variables, including the direct database URL, were set for production but not for the preview environment. Setting them there fixed it.

IV

Outcomes

Garnet CRM has working sign-in, organization isolation by URL, a permission engine, a team page with invitations, email password reset, and Arabic and right-to-left support, deployed on Vercel.

3
Fixed promises: scoped, never edited, audited
2
Languages, with right-to-left support

KEY TAKEAWAYS

Writing the rules down first made the code simpler. The permission engine only had to enforce decisions that were already made, instead of inventing them as it went.