01 / Context
What this project is solving
Faktoura is an invoicing tool built for how Moroccan freelances actually work: French and Arabic documents, gapless numbering, the mandatory CGI article 145 mentions and the auto-entrepreneur article 91 mention, per-line VAT, discounts, deposits, and credit notes. Amounts stay correct by construction — the free-tier limits and the numbering sequences are enforced in the database, not in the UI. Invoices go out as PDF over WhatsApp or email, recurring drafts and automatic email reminders keep the follow-up moving, and an accountant pack (UBL 2.1 export plus a per-period ZIP) closes the loop with the comptable. Subscriptions run through Lemon Squeezy or bank transfer, and the stack — Next.js on Vercel, self-hosted Supabase on Docker — mirrors the SAWL setup.
02 / Architecture
How the system is arranged
app/
Next.js App Router: dashboard, builders, clients, articles, expenses, recurring rules, settings, Pilotage (owner admin inside the app), and API routes
lib/
Invoice math (totals, per-line VAT, discounts, RAS withholding, EUR conversion), UBL 2.1 builder, accountant-pack builder, reminder rules, and the AI draft assistant
supabase/
Postgres with Row Level Security: gapless numbering RPCs per business, free-tier gates enforced in the database, per-owner advisory locks
Multi-société & sharing
One account, several businesses with separate profiles and numbering; read-only folder sharing for accountants and collaborators
Payments
Lemon Squeezy for card subscriptions (299 MAD/year) plus bank transfer (35 MAD/month or 299 MAD/year), verified by signed webhooks
ops
Self-hosted Supabase on Docker (Oracle Cloud VM), Vercel deployments, 30-minute watch checks, Brevo email sending
03 / Shipped
What made it into the build
- CGI-compliant invoices, quotes, deposits, and credit notes with gapless numbering
- French and Arabic documents with amount in words in both languages
- Per-line VAT, discounts, RAS withholding, and EUR billing with frozen FX rates
- Expenses with a monthly net-result view
- UBL 2.1 export and a per-period accountant ZIP, free for every user
- Automatic email reminders for overdue invoices, with real amounts
- Multi-société and read-only folder sharing
- Excel/CSV import for clients and articles
- AI assistant that drafts invoices from a sentence — never issues, never invents prices
- WhatsApp and email sending with the real PDF
- Pro subscriptions via Lemon Squeezy or bank transfer