---
stepsCompleted: ['step-01-init', 'step-02-discovery', 'step-02b-vision', 'step-02c-executive-summary', 'step-03-success', 'step-04-journeys', 'step-05-domain', 'step-06-innovation', 'step-07-project-type', 'step-08-scoping', 'step-09-functional', 'step-10-nonfunctional', 'step-11-polish']
classification:
  projectType: saas_b2b
  domain: fintech
  complexity: high
  projectContext: brownfield
inputDocuments:
  - '_bmad-output/planning-artifacts/product-brief-l-ami-fiduciaire-2026-03-10.md'
  - '_bmad-output/planning-artifacts/research/market-fiduciary-saas-morocco-research-2026-03-10.md'
  - '_bmad-output/planning-artifacts/research/domain-moroccan-fiduciary-operations-research-2026-03-10.md'
  - '_bmad-output/planning-artifacts/research/ecosystem-partners-morocco-fiduciary-research-2026-03-10.md'
  - '_bmad-output/planning-artifacts/research/cloud-adoption-saas-trends-future-outlook-research-2026-03-11.md'
  - '_bmad-output/planning-artifacts/research/domain-moroccan-tax-regulation-digital-compliance-research-2026-03-10.md'
  - '_bmad-output/project-context.md'
  - 'docs/index.md'
  - 'docs/project-overview.md'
  - 'docs/architecture.md'
  - 'docs/development-guide.md'
  - 'docs/source-tree-analysis.md'
workflowType: 'prd'
documentCounts:
  briefs: 1
  research: 5
  brainstorming: 0
  projectDocs: 5
  projectContext: 1
---

# Product Requirements Document - L'Ami Fiduciaire

**Author:** Saad
**Date:** 2026-03-11

## Executive Summary

L'Ami Fiduciaire is a cloud-native practice management SaaS platform purpose-built for Moroccan fiduciary and accounting firms. It fills a critical gap in a fragmented market: while firms rely on Sage/JBS for accounting, SIMPL/Damancom for government filings, and WhatsApp/Excel for everything else, no tool orchestrates the day-to-day practice -- tracking deadlines across dozens of clients, coordinating team workload, managing client document exchange, and ensuring nothing falls through the cracks.

The platform targets Morocco's ~20,000+ small-to-mid-size fiduciary firms (majority under 10 staff) that cannot afford custom solutions but desperately need structured workflow management. A confirmed partnership with Experio (AI-powered pre-accounting automation) provides a distribution channel into 500 firms already modernizing their operations, with a target of 100-150 paying firms in Year 1.

The product is actively in development (pre-production) with a Laravel 12 + Vue 3 + Inertia.js stack. The existing foundation includes multi-tenant workspaces, client management, a folder/dossier system, client portal with token-based access, document exchange, messaging, email notifications, 2FA, and activity logging. The MVP roadmap adds 5 phases: role system foundation, dashboard separation (command center for owners, scoped views for workers), collaboration/nudge features, workflow efficiency (bulk operations, advanced filtering), and a full archive system.

The long-term vision extends beyond practice management. As Experio owns the accounting automation layer, L'Ami Fiduciaire will evolve to own the **juridique layer** -- becoming the single portal where firms handle company creation, modifications statutaires, AGO preparation, and all legal/administrative workflows for their clients. The strategic split: Experio = comptabilite, L'Ami Fiduciaire = juridique + practice orchestration.

Revenue model is B2B SaaS subscription (per-workspace, not per-user): Starter at 199 MAD/month, Professional at 499 MAD/month, Enterprise at 999 MAD/month. No free tier -- 14-day full-feature trial instead.

### What Makes This Special

1. **Only practice management SaaS built for Moroccan fiduciaries.** French-native, Moroccan fiscal calendar (TVA by 20th, CNSS by 10th, IS quarterly), local compliance understanding. No global competitor (TaxDome, Karbon, Financial Cents) serves this market -- they're English-only, built for US/UK tax systems, and priced in USD.

2. **Complement, don't replace.** The "use alongside Sage" positioning eliminates adoption friction. Firms keep their existing accounting tools; L'Ami Fiduciaire orchestrates the practice around them.

3. **Zero-friction client portal.** External clients interact via token links without creating accounts -- matching the low-tech reality of Moroccan TPE/PME clients who run their businesses from their phones.

4. **The "aha moment" is structural clarity.** A firm owner opens the platform and sees, for the first time, that zero deadlines were missed and every client dossier is accounted for in one place. Not a single tool did everything; but one tool finally orchestrated everything.

5. **Experio partnership creates a moat.** Together they form a complete modernization stack (pre-accounting + practice orchestration) that no single competitor provides, with a path toward deep product integration.

6. **Positioned for the profession's transformation.** As AI eliminates 60-80% of manual bookkeeping by 2028-2030 and e-invoicing becomes mandatory in 2026, fiduciaries must evolve from data-entry shops to advisory practices. L'Ami Fiduciaire is the platform that enables that transition.

## Project Classification

- **Project Type:** SaaS B2B -- multi-tenant platform with role-based access, subscription tiers, and dashboard-driven workflows
- **Domain:** Fintech (fiduciary/accounting practice management) -- regulated industry with Moroccan tax law, CNSS/CIMR obligations, CNDP data protection, and upcoming e-invoicing mandate
- **Complexity:** High -- multiple user types (firm owner, worker, external client, platform admin), regulatory compliance requirements, integration with government platforms (SIMPL, Damancom), data sovereignty under Law 09-08
- **Project Context:** Brownfield -- active codebase with 7 Eloquent models, 16 migrations, 31 Vue pages, and core features already operational

## Success Criteria

### User Success

| Persona | Success Indicator | Measurement |
|---|---|---|
| **Karim (Owner/Manager)** | Zero missed deadlines across all clients in a month | % of declarations filed before deadline across workspace |
| **Karim (Owner/Manager)** | Full visibility into firm operations from a single screen | Daily login to command center dashboard |
| **Karim (Owner/Manager)** | No surprises -- problems surfaced proactively via alerts | Priority alerts acted on before deadline escalation |
| **Fatima (Worker)** | No declarations falling through the cracks | % of assigned dossiers with up-to-date status |
| **Fatima (Worker)** | Reduced time chasing clients for documents | Document requests sent via portal vs. WhatsApp |
| **Fatima (Worker)** | Clear daily task prioritization without mental overhead | Scoped dashboard used as primary work driver |
| **Hassan (Client)** | Fast, frictionless document submission | Time from receiving token link to completing action (target: < 5 minutes) |
| **Hassan (Client)** | No account creation friction | 100% of client interactions via token-based links |

### Business Success

| Timeframe | Metric | Target |
|---|---|---|
| **Pre-launch** | All 5 MVP phases complete + landing page live | Feature-complete, production-deployed |
| **Month 1-3** | New workspace registrations | 10-20 firms/month |
| **Month 1-3** | Trial-to-paid conversion rate | > 30% |
| **Month 1-3** | Onboarding completion rate | > 70% of signups complete setup |
| **Month 3-12** | Monthly Recurring Revenue (MRR) | 30,000 - 60,000 MAD/month |
| **Month 3-12** | Workspace churn rate | < 5%/month |
| **Year 1** | Total paying firms | 100-150 |
| **Year 1** | Primary acquisition via Experio channel | 20-30% conversion of Experio's 500 clients |

**Leading indicators (predict future success):**
- Daily active users per workspace (real adoption vs. shelfware)
- Number of dossiers managed per workspace (depth of usage)
- Client portal actions completed per month (end-client value delivery)

### Technical Success

- Platform runs in production with real firm data without critical bugs
- Reliable uptime -- no data loss, no failed critical operations (document uploads, status changes, email notifications)
- Page loads feel responsive for users on standard Moroccan internet connections
- Multi-tenant isolation -- no workspace data leakage between firms
- CNDP-compliant data handling (EU-hosted to avoid cross-border transfer authorization)

### Measurable Outcomes

The MVP is successful when:
1. **Deployable:** Production environment operational with zero critical bugs
2. **Adoptable:** A firm can sign up, create a workspace, add team, import clients, and start managing declarations within 1 hour
3. **Valuable:** Owner sees all clients' declaration statuses on one dashboard; workers see their scoped task list
4. **Functional:** Full declaration lifecycle works end-to-end: create -> assign -> notify client -> receive documents -> update status -> close -> auto-archive
5. **Collaborative:** Nudge system works -- Owner tags Worker, Worker gets notification with direct link
6. **Efficient:** Bulk creation lets firms create 20+ declarations in one action

## Product Scope & Development Strategy

### MVP Approach

**Philosophy:** Complete-product MVP -- all 5 phases are non-negotiable before first paying customer. The fiduciary market expects tools that work reliably from day one; a half-built practice management tool would damage credibility with the Experio channel and the OEC professional community.

**Resources:** 2 developers (Saad + Ilyas Benhsine) augmented by AI coding agents. Timeline: under 1 month to MVP completion.

**Brownfield Foundation (~40% already built):**
- Multi-tenant workspace model with session-based resolution
- User authentication with 2FA (Fortify)
- Client management (CRUD, import)
- Declaration (folder/dossier) system with statuses
- Client portal with token-based access
- Document upload/download via Spatie Media Library
- In-declaration messaging
- Email notifications (5 types)
- Activity logging (Spatie Activity Log)
- Basic workspace settings

### MVP Phases

**Pre-Phase: Foundation Change**
- "Folders" → "Declarations" terminology migration across UI, codebase, and database -- tackled first to avoid compounding rename debt across all 5 phases

**Phase 1: Role System Foundation** -- Fixed roles (Owner, Manager/Chef de Mission, Worker), per-workspace permission toggle matrix, team management page

**Phase 2: Dashboard Separation** -- Single shell with role-driven sidebar, Owner/Manager command center (active clients, declarations by status, priority alerts), scoped worker dashboard, SaaS owner platform dashboard, issue/support inbox

**Phase 3: Collaboration Features** -- Quick tag & nudge system, inline nudge on declaration rows, employee notification center with direct links

**Phase 4: Workflow Efficiency** -- Bulk declaration creation (multi-client, type selection, date setting), bulk notification scheduling, advanced filtering system (persistent across views), quick search, practicality-first UI pass

**Phase 5: Archive System** -- Auto-archive on close, full history preservation, archive as top-level nav item, hybrid filters + search, archive detail page (read-only snapshot), in-app document preview, re-open with audit trail, bulk ZIP download, visual distinction, 10-year retention policy

All 6 documented user journeys are fully supported by MVP -- no journey is deferred.

### Growth Features (Post-MVP)

| Priority | Feature | Impact |
|---|---|---|
| High | Landing page with pricing, feature overview, and signup flow | Public acquisition channel (soft launch via Experio doesn't require it) |
| High | Experio integration (referral flow + potential data sync) | Distribution channel activation |
| High | Billing automation (CMI, bank transfer, CashPlus) | Automate revenue collection (manual billing acceptable for first 10-20 firms) |
| Medium | WhatsApp document intake | Meets clients where they communicate |
| Medium | Deadline calendar with Moroccan fiscal calendar pre-loaded | Automatic deadline awareness per client type |
| Medium | E-invoicing readiness (DGI platform API when available) | Compliance positioning |
| Low | Kanban view for declaration pipeline | Visual workflow option |
| Low | Client-initiated declarations | Reverse-flow for proactive clients |

### Vision (Future)

- **Juridique portal:** Company creation, modifications statutaires, AGO preparation, depot legal -- the single platform for all legal/administrative workflows
- **Deep Experio integration:** Bi-directional data flow between pre-accounting automation and practice orchestration
- **Mobile app:** Native mobile experience for firm users and clients
- **Arabic UI support:** Broader market accessibility
- **AI features:** Document classification, anomaly detection, auto-categorization
- **E-invoicing integration:** Direct connection with DGI e-invoicing platform

### Risk Mitigation

| Category | Risk | Mitigation |
|---|---|---|
| **Technical** | Declaration rename touches entire codebase | Tackle first before building new features -- prevents compounding changes |
| **Technical** | 5 phases in <1 month is aggressive | Brownfield foundation covers ~40%; AI agents accelerate; 2-dev parallel workstreams |
| **Technical** | Archive system (Phase 5) is most complex new feature | Well-scoped requirements; can parallelize with Phase 4 |
| **Market** | First firms need hand-holding during onboarding | Saad available for direct support; small initial cohort via Experio |
| **Market** | Billing not automated at launch | Manual billing acceptable for first 10-20 firms |
| **Resource** | 2-person team, tight timeline | AI agent augmentation; well-defined phases prevent scope creep |
| **Resource** | One developer unavailable | Both devs have full codebase context; phases can be worked independently |

## User Journeys

### Journey 1: Karim (Owner) -- First Setup & The Morning Dashboard

**Opening Scene:** Karim runs a 7-person cabinet in Casablanca. It's Sunday evening and he's dreading Monday morning -- 120+ client dossiers tracked across Excel sheets, WhatsApp threads, and verbal updates from his team. Last month, two TVA declarations were filed late because Fatima was sick and nobody picked up her clients. The 5% penalty notices arrived at his desk. He heard about L'Ami Fiduciaire through Experio's newsletter.

**Rising Action:** Karim signs up for the 14-day trial from the landing page. He creates his workspace, sets up the firm name, and lands on the Team page. He invites his 3 collaborateurs and his chef de mission Rachid as Manager. He assigns roles -- Rachid gets Manager permissions (can see all clients, assign work, nudge workers), the collaborateurs get Worker roles. He imports his client list and creates the first batch of TVA declarations using bulk creation -- 45 clients, all TVA Mensuel, deadline March 20th. What used to take an afternoon takes 10 minutes.

**Climax:** Monday morning, 8:15 AM. Karim opens L'Ami Fiduciaire and sees his command center. Three red alerts: Client Benani hasn't uploaded bank statements (due in 2 days), Client Tazi's TVA is overdue by Fatima (she's on leave), and 12 declarations are on track. He nudges Rachid on the Tazi dossier with one click. Rachid reassigns it to another worker within minutes. For the first time in 12 years, Karim sees his entire firm's status on one screen. Nothing will surprise him this month.

**Resolution:** End of month -- zero missed deadlines. Karim didn't work a single 12-hour day. He converts to the Professional plan on day 11 of the trial. He tells two firm owners at the OEC networking event: "You need to try this."

**Capabilities revealed:** Workspace creation, team management, role assignment, bulk declaration creation, command center dashboard, priority alerts, nudge system, trial-to-paid conversion flow.

---

### Journey 2: Rachid (Manager/Chef de Mission) -- Team Coordination

**Opening Scene:** Rachid is Karim's chef de mission. He supervises 3 collaborateurs who collectively manage 90 client dossiers. His current coordination method: a daily WhatsApp group message asking "where are you on X client?" and a shared Google Sheet that's always out of date. During bilan season, he spends more time coordinating than doing actual work.

**Rising Action:** Karim sets Rachid up as Manager in L'Ami Fiduciaire. Rachid sees the same command center as Karim -- all clients, all declarations, all statuses. But his daily focus is different: he checks which workers are overloaded, which clients are behind on document submissions, and which deadlines are approaching this week. He notices that Amina has 18 active declarations while Youssef only has 9. He reassigns 4 of Amina's clients to Youssef directly from the dashboard.

**Climax:** Karim nudges Rachid about the Tazi TVA dossier (Fatima is on leave). Rachid gets the notification, clicks the direct link, sees the dossier status, and reassigns it to Youssef -- all in under 2 minutes. No WhatsApp thread, no phone call, no "did you see my message?"

**Resolution:** Rachid stops being a message relay and becomes an actual team lead. Coordination time drops dramatically. He can manage 90 dossiers across his team because the platform shows him exactly where attention is needed, instead of him having to ask.

**Capabilities revealed:** Manager dashboard (same as owner view), worker workload visibility, client/declaration reassignment, nudge receiving and acting, declaration detail view with quick actions.

---

### Journey 3: Fatima (Worker) -- The Daily Grind

**Opening Scene:** Fatima manages 45 client dossiers. It's the 12th of the month -- TVA declarations are due on the 20th, and she still hasn't received bank statements from 8 clients. She used to scroll through WhatsApp looking for which clients responded and which didn't, then manually text each one again. Her Excel tracker says "relance envoyee" for Client Mounir, but she can't remember if that was this month or last month.

**Rising Action:** Fatima logs into L'Ami Fiduciaire and sees her scoped worker dashboard. It shows only her 45 assigned clients. The dashboard is clear: 8 declarations are flagged "waiting for client documents" with days remaining until deadline. She selects all 8 and triggers a bulk notification -- each client gets an email with their personal token link to upload documents. She moves on to the 5 declarations that have documents ready and starts updating statuses as she works through them in Sage.

**Climax:** By 3 PM, 3 of the 8 clients have uploaded documents via the portal. She didn't chase anyone on WhatsApp. Client Mounir uploaded his bank statement directly from his phone -- she can see the upload timestamp and download the file from the declaration detail page. She sends Mounir a message through the in-declaration messaging system confirming receipt. Full audit trail, no WhatsApp screenshot needed.

**Resolution:** By the 19th, Fatima has filed all 45 TVA declarations. Zero missed. During bilan season, she manages 60 dossiers instead of 45 because the platform handles the coordination she used to do manually. She gets home by 7 PM even in March.

**Capabilities revealed:** Scoped worker dashboard, declaration status tracking, bulk notification sending, client portal document receipt, in-declaration messaging, declaration status updates, document download.

---

### Journey 4: Fatima (Worker) -- Edge Case: Declaration Goes Wrong

**Opening Scene:** Fatima created a TVA declaration for Client Bouzidi, but realized she selected the wrong type -- it should have been TVA Trimestrielle, not TVA Mensuelle. The client has already been notified and uploaded a document to the wrong declaration.

**Rising Action:** Fatima edits the declaration type from the declaration detail page. The uploaded document is still attached -- nothing is lost. She updates the deadline date to reflect the quarterly schedule. She sends a message to Client Bouzidi through the portal explaining the correction.

**Climax:** Later, Rachid notices the declaration was modified and sees the edit in the activity log -- who changed what, when. No mystery, no finger-pointing.

**Resolution:** The declaration proceeds correctly. The audit trail captured every change. When Karim reviews the workspace activity feed, he sees the correction logged transparently.

**Capabilities revealed:** Declaration editing, activity logging/audit trail, document persistence across edits, in-declaration messaging for corrections, manager visibility into changes.

---

### Journey 5: Hassan (Client) -- The 3-Minute Upload

**Opening Scene:** Hassan owns a small SARL in Ain Sebaa. He's driving back from a supplier meeting when his phone buzzes -- an email from his fiduciary firm. Subject: "Documents requis -- Declaration TVA Janvier." He used to ignore these until his accountant called him three times, but this email has a blue button that says "Voir la demande."

**Rising Action:** Hassan taps the button from his phone. A clean, mobile-friendly page opens -- no login, no account creation. It shows exactly what's needed: "Veuillez telecharger votre releve bancaire de janvier 2026." There's one upload button. Hassan takes a photo of the bank statement from his glove compartment, uploads it. The page confirms: "Document recu. Merci."

**Climax:** 30 seconds later, Fatima sees the upload notification in her dashboard. She downloads the file, it's legible, and she begins the saisie. No WhatsApp back-and-forth. No "did you get my message?" No lost document in a group chat.

**Resolution:** Hassan never thinks about it again -- which is exactly what he wants. At the end of the quarter, zero penalty notices arrive. He tells his friend who runs a restaurant: "Switch to my fiduciary, they have this system where you just click and upload, it's amazing."

**Capabilities revealed:** Email notification with token link, mobile-friendly client portal, single-action upload page, no-account-required interaction, upload confirmation, real-time notification to firm worker.

---

### Journey 6: Saad (Platform Admin) -- Monitoring the SaaS

**Opening Scene:** Saad is the L'Ami Fiduciaire platform owner. It's been 2 months since launch. 35 workspaces have been created. He needs to understand platform health, identify support issues, and ensure no workspace is experiencing problems.

**Rising Action:** Saad logs into the SaaS owner dashboard. He sees platform metrics: 35 active workspaces, 142 total users, 2,847 declarations created, 12.4 GB storage used. He checks the issue/support inbox -- 3 tickets this week. One firm reports they can't upload files larger than 10 MB. Another asks how to re-open an archived declaration. A third reports a display issue on Safari.

**Climax:** Saad resolves the upload limit issue (configuration change), responds to the archive question with instructions, and logs the Safari bug for the development backlog. He notices one workspace has 0 active declarations after 3 weeks -- a churn risk. He makes a note to reach out personally.

**Resolution:** Saad uses the platform dashboard as his operational command center. He can monitor health, identify at-risk workspaces, and handle support without needing external tools. As the platform grows to 100+ workspaces, the dashboard scales with him.

**Capabilities revealed:** SaaS admin dashboard (workspace count, user count, storage, system health), issue/support inbox, workspace-level activity monitoring, user management.

---

### Journey Requirements Summary

| Journey | Key Capabilities Revealed |
|---|---|
| **Karim (Owner - Setup & Dashboard)** | Workspace creation, team management, role assignment, bulk declaration creation, command center, priority alerts, nudge system |
| **Rachid (Manager - Coordination)** | Manager dashboard, workload visibility, reassignment, nudge receiving/acting, declaration detail |
| **Fatima (Worker - Daily Grind)** | Scoped dashboard, status tracking, bulk notifications, portal document receipt, messaging, document download |
| **Fatima (Worker - Edge Case)** | Declaration editing, activity logging, document persistence, audit trail, correction messaging |
| **Hassan (Client - Upload)** | Email notifications, token-based portal, mobile-friendly upload, no-account interaction, upload confirmation |
| **Saad (Admin - Platform Monitoring)** | SaaS dashboard, support inbox, workspace monitoring, user management |

**Coverage:** All 5 user types covered (Owner, Manager, Worker, Client, Platform Admin). Happy paths and edge cases included. Onboarding covered within Karim's journey.

## Domain-Specific Requirements

### Compliance & Regulatory

**Data Protection (CNDP -- Law 09-08):**
- Personal client data (CIN numbers, financial information, company details) must comply with Morocco's CNDP data protection framework
- EU hosting is the pragmatic choice -- avoids the cross-border transfer authorization process required for US data centers
- Data retention policies must align with legal minimums (10-year accounting record retention per Moroccan law)
- User consent mechanisms for data processing

**Tax & Fiscal Compliance Context:**
- The platform manages declaration workflows but does NOT perform accounting calculations or file declarations directly -- it orchestrates the process
- Declaration types tracked must align with Moroccan fiscal calendar: TVA (monthly/quarterly), IS (annual + quarterly acomptes), IR (monthly withholding + annual Etat 9421), CNSS (monthly via Damancom)
- Penalty awareness: the platform's value proposition is directly tied to avoiding 5-20% late filing penalties

**AML Context (Law 43-05):**
- L'Ami Fiduciaire itself is not directly subject to AML as a SaaS tool, but fiduciary firms using it are -- the platform should not impede their compliance obligations
- Activity logging and audit trails support firms' AML record-keeping requirements

### Technical Constraints

**Domain-Specific Security Context:**
- Client financial data (CIN numbers, bank statements, tax documents) requires encryption at rest -- these are not generic user files
- Multi-tenant isolation is existential: a firm seeing another firm's client data would be a business-ending event
- Token-based client portal serves non-technical users (TPE/PME owners) -- security must be invisible to them

**Morocco-Specific Infrastructure Context:**
- Standard Moroccan internet (ADSL in offices, 4G on mobile) is the baseline -- not fiber or US/EU broadband
- Peak platform usage aligns with Moroccan fiscal deadlines: 15th-20th monthly (TVA), end of month (CNSS), Jan-Mar (bilan season)
- Email delivery during these peaks is mission-critical -- a failed notification directly causes a missed filing

See Non-Functional Requirements for specific measurable targets.

### Integration Requirements

**Current (MVP):**
- Email delivery service (transactional emails for 5 notification types)
- File storage (Spatie Media Library -- already implemented)
- No direct API integrations with government platforms for MVP (SIMPL, Damancom, CIMR have no public APIs)

**Future:**
- DGI e-invoicing platform API (when available -- 2026-2027)
- Experio data sync (post-MVP partnership deepening)
- Potential WhatsApp Business API for document intake
- Bank statement import/parsing (when open banking matures in Morocco)

### Risk Mitigations

| Risk | Impact | Mitigation |
|---|---|---|
| **Data breach exposing client financial data** | Catastrophic -- regulatory penalties, trust destruction | EU hosting, encryption at rest, strict tenant isolation, 2FA, regular security audits |
| **Email delivery failure during deadline period** | High -- missed client notifications lead to missed deadlines | Reliable email provider (SES/Postmark), delivery monitoring, retry logic |
| **Workspace data leakage between tenants** | Catastrophic -- legal liability, immediate churn | Session-based workspace resolution (already implemented), authorization at every data access point, automated testing for tenant isolation |
| **Document loss or corruption** | High -- client financial records are irreplaceable | Reliable storage with backups, upload confirmation flow, document versioning |
| **Platform unavailable during bilan season (Jan-Mar)** | High -- peak usage period, firms depend on platform | Infrastructure scaling, monitoring, incident response plan |
| **CNDP non-compliance discovery** | Medium-High -- potential fines up to 600K MAD | EU hosting from day one, privacy policy, data processing agreements, retention policy enforcement |

## SaaS B2B Specific Requirements

### Multi-Tenancy Model

L'Ami Fiduciaire uses session-based workspace resolution via `current_workspace_id`. The tenancy model is role-dependent:

| Role | Workspace Access | Rationale |
|---|---|---|
| **Worker** | Single workspace only | A collaborateur works for one firm. No cross-workspace scenarios. |
| **Manager (Chef de Mission)** | Single workspace only | A chef de mission manages one firm's team. They don't span multiple cabinets. |
| **Owner** | May have multiple workspaces | An expert-comptable may own more than one cabinet (e.g., separate entities for audit vs. fiduciary, or franchise locations). Workspace switcher available for Owners only. |

**Workspace isolation is absolute:** Every database query is scoped to `current_workspace_id`. Authorization violations return 404 (not 403) to prevent information leakage about other tenants' existence.

### RBAC Permission Matrix

Three fixed roles with a per-workspace toggle-based permission matrix:

| Permission Area | Owner | Manager (Chef de Mission) | Worker |
|---|---|---|---|
| View all clients & declarations | Always | Yes | Own assigned only |
| Create/edit declarations | Yes | Yes | Own assigned only |
| Bulk declaration creation | Yes | Yes | No |
| Assign/reassign declarations | Yes | Yes | No |
| Nudge team members | Yes | Yes | No |
| Manage team (invite/remove) | Yes | Configurable | No |
| View command center dashboard | Yes | Yes | No (scoped dashboard) |
| Manage workspace settings | Yes | No | No |
| Manage billing/subscription | Yes | No | No |
| View activity logs | Yes | Configurable | Own actions only |
| Archive access | Yes | Yes | Own archived items |
| Client portal configuration | Yes | Configurable | No |

**Permission toggles:** Owners can grant/revoke specific Manager permissions per workspace (e.g., allow or disallow team management for a specific Chef de Mission). Worker permissions are fixed and scoped.

### Subscription Tiers

Per-workspace pricing (not per-user):

| Feature / Limit | Starter (199 MAD/mo) | Professional (499 MAD/mo) | Enterprise (999 MAD/mo) |
|---|---|---|---|
| Team members | Up to 3 | Up to 10 | Unlimited |
| Active clients | Up to 30 | Up to 100 | Unlimited |
| Storage | 5 GB | 20 GB | 100 GB |
| Client portal | Basic (upload only) | Full (messaging + upload) | Full + branded portal |
| Archive retention | 3 years | 10 years | 10 years + export |
| Bulk operations | Limited (10 at once) | Full | Full |
| Priority support | Email only | Email + chat | Dedicated support |
| API access | No | No | Yes (future) |

**Trial:** 14-day full-feature trial (Professional tier equivalent). No free tier. No credit card required for trial.

### Billing & Payment Methods

Morocco-specific payment infrastructure -- Stripe is not the primary channel:

| Payment Method | Priority | Implementation |
|---|---|---|
| **CMI (Centre Monetique Interbancaire)** | Primary | Moroccan card payment gateway -- supports local Visa/Mastercard issued by Moroccan banks |
| **Bank transfer (virement bancaire)** | Primary | Manual reconciliation initially, automated matching later |
| **CashPlus / Wafacash** | Secondary | Cash-based payment for firms that prefer it -- common in smaller cities |
| **Stripe** | Future/International | Only if expanding beyond Morocco or for international cards |

**Billing cycle:** Monthly billing with annual discount option (2 months free). Invoices generated in MAD with Moroccan tax compliance.


## Functional Requirements

### Workspace & Onboarding

- **FR1:** Owner can create a new workspace with firm name and basic configuration
- **FR2:** Owner can invite team members to the workspace via email
- **FR3:** Owner can assign roles (Manager/Chef de Mission, Worker) to team members
- **FR4:** Owner can configure per-workspace permission toggles for Manager roles
- **FR5:** Owner can manage workspace settings (firm details, firm logo, display name)
- **FR6:** New users can sign up for a 14-day trial without credit card

### Team & Role Management

- **FR7:** Owner can view, add, and remove team members from the workspace
- **FR8:** Owner can change a team member's role within the workspace
- **FR9:** Manager can invite, remove, and change roles of team members when permission is granted by Owner
- **FR10:** System enforces role-based access -- Workers see only assigned items, Managers/Owners see all
- **FR11:** Owner can switch between multiple owned workspaces

### Client Management

- **FR12:** Owner/Manager can create, view, edit, and deactivate client records
- **FR13:** Owner/Manager can import clients in bulk
- **FR14:** Worker can view and interact with their assigned clients only
- **FR15:** System associates each client with a workspace and enforces tenant isolation

### Declaration Lifecycle

- **FR16:** Owner/Manager can create individual declarations for a client (type, deadline, assignment)
- **FR17:** Owner/Manager can bulk-create declarations across multiple clients with type and deadline selection
- **FR18:** Owner/Manager/Worker can update declaration status through its lifecycle
- **FR19:** Owner/Manager can reassign a declaration to a different team member
- **FR20:** Worker can edit declarations assigned to them (type correction, deadline adjustment)
- **FR21:** System auto-archives declarations when marked as closed
- **FR22:** Owner/Manager can re-open an archived declaration with audit trail
- **FR23:** Users can view archived declarations in read-only mode with full history

### Dashboard & Visibility

- **FR24:** Owner/Manager can view a command center dashboard showing all clients, declaration statuses, and priority alerts
- **FR25:** Worker can view a scoped dashboard showing only their assigned clients and declarations
- **FR26:** Dashboard surfaces priority alerts (overdue declarations, approaching deadlines, missing client documents)
- **FR27:** SaaS Admin can view a platform-level dashboard (workspace count, user count, storage, system health)
- **FR28:** SaaS Admin can view and respond to support tickets via an issue/support inbox

### Collaboration & Notifications

- **FR29:** Owner/Manager can nudge a team member on a specific declaration with one action
- **FR30:** Team members receive notifications with direct links to the relevant declaration
- **FR31:** Users can view a notification center showing all received nudges and system alerts
- **FR32:** Owner/Manager can schedule bulk notifications to clients for document requests
- **FR33:** System sends email notifications for key events (document requests, nudges, status changes)

### Client Portal & Document Exchange

- **FR34:** System generates unique token-based links for client interactions (no account required)
- **FR35:** External clients can upload documents via token link from any device including mobile
- **FR36:** External clients receive confirmation after successful document upload
- **FR37:** Team members can download client-uploaded documents from the declaration detail page
- **FR38:** Team members can send messages to clients within a declaration context
- **FR39:** External clients can view messages from their fiduciary firm via the portal
- **FR40:** Token links expire according to configurable security policies

### Search, Filtering & Navigation

- **FR41:** Users can filter declarations by status, client, assignee, type, and deadline range
- **FR42:** Filter selections persist across views within a session
- **FR43:** Users can perform quick search across clients and declarations
- **FR44:** Archive section is accessible as a top-level navigation item with its own filters and search

### Archive System

- **FR45:** System preserves full declaration history upon archiving (documents, messages, status changes, activity log)
- **FR46:** Users can browse archived declarations with hybrid filters and search
- **FR47:** Users can view an archive detail page as a read-only snapshot of the complete declaration
- **FR48:** Users can preview documents in-app from archived declarations
- **FR49:** Users can bulk-download archived declaration documents as ZIP
- **FR50:** System visually distinguishes archived declarations from active ones
- **FR51:** System enforces 10-year retention policy for archived data

### Activity & Audit

- **FR52:** System logs all data modifications with actor, timestamp, and change details
- **FR53:** Owner can view the full activity log for the workspace
- **FR54:** Manager can view activity logs when permission is granted
- **FR55:** Worker can view activity logs for their own actions only

### Platform Administration

- **FR56:** SaaS Admin can view all workspaces and their usage metrics
- **FR57:** SaaS Admin can manage platform-level configuration (global settings, feature flags, storage limits, email templates)
- **FR58:** System enforces subscription tier limits (team members, clients, storage, features)

## Non-Functional Requirements

### Performance

- **NFR1:** Page loads and common user actions (navigation, status updates, filtering) complete within 2 seconds on standard Moroccan internet connections (ADSL/4G)
- **NFR2:** Bulk declaration creation (up to 50 declarations) completes within 10 seconds
- **NFR3:** Bulk notification scheduling (up to 50 clients) completes within 10 seconds
- **NFR4:** File uploads up to 10 MB complete within 60 seconds on 4G connections
- **NFR5:** Dashboard data (command center, worker view) renders within 3 seconds for workspaces with up to 200 active clients
- **NFR6:** Quick search returns results within 1 second

### Security

- **NFR7:** All data encrypted in transit (TLS 1.2+) and at rest (AES-256 for stored documents)
- **NFR8:** Multi-tenant data isolation enforced at every query -- no workspace can access another workspace's data under any circumstance
- **NFR9:** Authorization boundary violations return 404 (not 403) to prevent tenant existence leakage
- **NFR10:** Token-based client portal links are cryptographically secure, single-purpose, and expire after configurable duration
- **NFR11:** Two-factor authentication available for all firm users (TOTP-based)
- **NFR12:** All data modifications logged with actor, timestamp, and change details (audit trail)
- **NFR13:** CNDP (Law 09-08) compliant data handling -- EU-hosted infrastructure to avoid cross-border transfer authorization
- **NFR14:** Client financial documents accessible only to authorized workspace members and the specific client via their token link
- **NFR15:** Session management with secure cookie handling, CSRF protection, and session timeout after inactivity

### Scalability

- **NFR16:** System supports up to 200 concurrent workspaces while maintaining NFR1 page load targets and NFR5 dashboard render targets
- **NFR17:** System supports up to 1,000 total users across all workspaces
- **NFR18:** Individual workspace supports up to 500 active clients and 5,000 active declarations while maintaining NFR1 page load targets and NFR6 search response targets
- **NFR19:** File storage architecture supports growth to 1 TB total platform storage
- **NFR20:** System handles seasonal peak loads (bilan season Jan-Mar: 2-3x normal usage) while maintaining NFR1 page load targets, NFR5 dashboard render targets, and NFR21 uptime targets

### Reliability & Data Protection

- **NFR21:** Platform targets 99.5% uptime (max ~3.6 hours unplanned downtime per month)
- **NFR22:** Automated hourly database backups with 1-hour RPO (Recovery Point Objective)
- **NFR23:** Database binary/transaction logging enabled for point-in-time recovery up to last committed transaction
- **NFR24:** Backup restore procedure documented and tested -- full database restore achievable within 1 hour (RTO)
- **NFR25:** Backup retention: daily backups kept for 30 days, weekly backups kept for 6 months
- **NFR26:** Email notification delivery must achieve >99% delivery success rate with retry logic (up to 3 retries within 5 minutes) -- failed deliveries during deadline periods directly cause missed filings
- **NFR27:** Monitoring and alerting configured for system health, error rates, and resource utilization
- **NFR28:** Zero data loss tolerance for completed transactions (documents uploaded, status changes saved, messages sent)
