How We Built YeloInvoice: A Fiscal-Compliant Invoicing SaaS Built with AI Agents
YeloInvoice is an invoicing and point-of-sale platform for small and medium businesses in Tunisia: compliant invoices, credit notes, payments, stock, purchases, accounting reports, and an e-invoicing center, in French, Arabic, and English. OHY Labs built it with AI coding agents working from written specifications, and shaped its API so AI agents can connect through MCP as the next step. This is how it was done.
The Brief: Invoicing That Survives an Audit
Invoicing software is unforgiving. Numbers must be gap-free, totals must match the tax rules to the cent, a credit note must reference the document it corrects, and an issued invoice must never change. Add multi-user access, several fiscal years, and three languages with right-to-left support, and the surface for subtle bugs is large.
The goal was a product an accountant would trust, delivered by a small team at startup speed. That combination is exactly where AI-assisted engineering pays off, provided the process is disciplined.
- Draft, issue, and print invoices with gap-free numbering per series and fiscal year.
- Full and partial credit notes, payment recording, and derived payment status.
- Point of sale, purchases, stock, treasury, accounting reports, and bills of exchange.
- An e-invoicing center prepared for the national electronic invoicing flow.
- Roles for owner, sales, accountant, and viewer, with tenant isolation at every layer.
Architecture: One Tax Engine, Shared Everywhere
YeloInvoice is a pnpm monorepo. The API is NestJS with Prisma on Postgres and Redis. The web app is Next.js with the App Router and Tailwind, French by default, Arabic with right-to-left layouts, and English. A shared package holds the Zod schemas, domain enums, and a pure money and tax engine with no database or framework dependencies.
Because the tax engine is pure and shared, the invoice editor shows live totals in the browser that match what the API will persist, and the same code is unit tested in isolation. Issuing an invoice is protected by an idempotency key and produces an integrity hash, so a double click or a retry can never create two documents.
Concurrency is tested, not assumed
The end-to-end suite deliberately fires concurrent requests at the same Postgres instance for numbering, payments, and credit notes. Race conditions in invoicing are not theoretical, and catching them in CI is cheaper than explaining a duplicate number to an auditor.
Spec-Driven Development with AI Coding Agents
Every slice of YeloInvoice began as a design document: the fiscal core, PDF templates, extended taxation, accounting and reports, point of sale, admin, imports, and payment modes by business type. Each spec states the requirements, the compliance sources, and what is explicitly out of scope.
Specs are then broken into tasks. Each task gets a short brief that an AI coding agent implements, followed by a written report of what changed and what was verified. The repository holds more than a hundred of these brief-and-report pairs. A human reviews the diff, runs the tests, and decides. The agent does the typing; the specification does the thinking.
- Design specs as the single source of truth for scope and architecture.
- Small tasks with briefs and reports, so every change is explainable.
- Tests written alongside implementation, including end-to-end runs against a real database.
- A compliance document that separates what is implemented from what still needs an accountant’s confirmation.
Why this works better than prompting for a whole app
Asking an agent to “build an invoicing app” produces something plausible and wrong. Asking it to implement one task from a spec that names the tax rule, the numbering constraint, and the test to add produces something an accountant can verify. The quality of the specification, not the model alone, sets the ceiling.
Compliance and Security by Construction
Fiscal rules are documented with sources, and open questions are tracked separately until confirmed by an accountant. Rather than promising legal validation, the product states plainly that final fiscal validation stays with the business and its accountant, and it makes that job easy with clean, complete documents.
On the security side, three global guards enforce authentication, tenant membership, and permissions on every request. Tokens are short-lived with refresh in an httpOnly cookie. A security checklist in the repository tracks each control as done or still open, so nothing is assumed.
Designed MCP-Ready: The Path to AI Agents
YeloInvoice does not yet run an MCP server, but it was built so that adding one is a thin layer rather than a rewrite. Every capability is exposed through a documented OpenAPI 3 API with typed schemas. Permissions are fine-grained and checked per request. Writes that matter are idempotent. Those three properties are exactly what a safe MCP tool needs: a schema to describe it, a permission to gate it, and idempotency so an agent retry is harmless.
The planned MCP layer follows the model OHY Labs used on YeloScale. Read tools for invoices, clients, and payments come first. Creating a draft is a reversible write with an idempotency key. Issuing an invoice or recording a payment is a sensitive action that requires a prepare-and-confirm step with a human in the loop.
- An accounting agent that answers “which invoices are overdue this month” from live data.
- A sales agent that drafts an invoice from a confirmed order and asks a human to issue it.
- A reporting agent that compiles month-end summaries without exporting spreadsheets.
What the Business Gets
An SME gets compliant invoicing, POS, stock, and reports in their own language, with documents that are ready for their accountant and the e-invoicing flow. They also get a platform that is ready for the agent era: when they want an AI assistant handling reminders, drafts, or reporting, the API, permissions, and audit trail are already in place.
For OHY Labs, YeloInvoice shows that AI-assisted engineering can deliver software in a domain where mistakes are expensive, as long as specifications, tests, and human review stay in the loop.