StockCRM

An inventory and operations platform for small retail businesses in Morocco. Multi-tenant SaaS, built alone, running in production.

status
in production
api
18 route groups · 30+ tables
access
4 roles · 50+ permissions
team
just me — every layer

what it is

StockCRM is where small Moroccan shops run their stock, sales, customers, and money — all in one place. It started as a stock tracker and grew into a small SaaS: multi-tenant, role-based, with its own billing. The interesting parts are not the CRUD. They are the AI order agent, the auto-generated landing pages, the public storefront API for partner shops, and a billing model that fits how Moroccan businesses really pay.

StockCRM dashboard
operations dashboardfig. 1

the ai order agent

A partner sends a message — or a photo of a handwritten daily ledger — and the AI drafts the order. Nothing is saved until a human confirms it.

01

Draft

The agent reads the message, searches products, matches the customer, and returns a draft. The draft is signed — no database write yet.

02

Confirm

A human approves. The server checks the signature, then writes the order. If anything was changed in between, it gets rejected.

03

Audit

AI-made orders get an AGNT- tag, the loop has a hard cap, and refused replies are rephrased and retried automatically.

what’s inside

products
Stock, photo gallery, cost, value.
orders
Full lifecycle, price snapshots, profit per order.
customers
Loyalty points, store credit, history.
suppliers
Rating, balance, sourced products.
leads
Pipeline, plus one-click convert to customer.
expenses
Approval flow, category breakdowns.
deliveries
Assignments and proof of delivery.
analytics
Eight reports and anomaly alerts.
landing pages
AI-generated pages that capture leads.
storefront api
Per-shop keys, rate limits, audit log.
Customers and loyalty
customers & loyaltyfig. 2

stack

Bun · TypeScript · Express 5 · PostgreSQL · Drizzle ORM · Zod · Redis · JWT · Groq · Cloudinary · R2

choices i’m happy with

draft first, save later
The AI can search products and ask questions without leaving half-made orders in the database. The draft is signed, so tampering between draft and confirm gets caught.
no stripe
Customers in Morocco pay by bank transfer. So billing is manual by design — it matches how people actually pay here.
one header, not subdomains
Switching between organizations is one request header, not a re-login.
agnt- tag on ai orders
Every order the AI creates is tagged. One query answers: what did the AI do today?

talk about it