--- 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 releaseMode: 'phased' classification: projectType: 'SaaS Web Application (B2C & B2B)' domain: 'Productivity / Personal Knowledge Management' complexity: 'Medium' projectContext: 'brownfield' inputDocuments: - docs/fonctionnalites-ia.md - docs/gtm-pricing-strategy.md - docs/spec-document-qa.md - memento-note/docs/brainstorm-documentation.md - memento-note/docs/byok-billing-patch-v3.md - memento-note/docs/saas-deployment-prep.md workflowType: 'prd' --- # Product Requirements Document - Momento **Author:** User **Date:** 2026-05-14 ## Executive Summary Momento Note democratizes access to an AI-augmented digital memory for a dual audience: self-taught individuals and enterprise R&D departments. As a next-generation Personal Knowledge Management system, it transforms note-taking from passive storage into an active, intelligent partner. By integrating vector-based semantic search and an ecosystem of autonomous agents, Momento automatically surfaces hidden connections, remembers forgotten insights, and accelerates knowledge work. ### What Makes This Special Momento's true power lies in its seamless blend of advanced AI tools and innovative financial architecture: - **Autonomous Ecosystem:** Moving beyond a smart notepad, Momento acts as an autonomous "Second Brain." It deploys specialized agents (Scraper, Researcher, Monitor) and native productivity tools like Document Parsing (Chat-with-PDF) and Automated Task Extraction directly within the user's workspace. - **Collaborative Brainstorming:** A real-time, D3-powered radial graph canvas allows users to generate, expand, and structure AI-driven ideas collaboratively. - **Sustainable "Host-Pays" Billing & BYOK:** Memento resolves the SaaS AI cost paradox through intelligent smart routing (defaulting to highly optimized models like DeepSeek V4 Flash) and a Bring-Your-Own-Key (BYOK) architecture that eliminates AI costs for power users. The innovative Freemium "AI Discovery Pack" provides lifetime access limits rather than restrictive monthly quotas, delivering an immediate "Aha!" moment without friction. ## Project Classification - **Project Type:** SaaS Web Application (B2C & B2B) - **Domain:** Productivity / Personal Knowledge Management - **Complexity:** Medium (Managing complex state, real-time WebSockets, AI token routing, and subscription tier limits) - **Project Context:** Brownfield (Enhancing an existing note-taking app with a V3 monetization patch, collaborative brainstorming, and BYOK capabilities) ## Success Criteria ### User Success - **Activation (The "Aha!" Moment):** A high percentage of new free users must experience the product's core value rapidly by executing their first "Semantic Search" or joining a shared "Brainstorm Canvas" within 24 hours of sign-up. - **Immediate Utility:** Users must immediately feel the transition from passive note-taking to an active, AI-augmented digital memory. ### Business Success - **Core Engagement (Stickiness):** Strong Weekly Active Users (WAU) interacting specifically with advanced features (Chat-with-PDF, Task Extraction, or Autonomous Agents), proving the undeniable "Second Brain" value. - **Viral Acquisition (PLG):** A steady baseline of new users acquired organically through product-led growth loops, primarily via shared Brainstorm session links and exported PPTX/Slide watermarks. - **Strategic Positioning:** Achieving high engagement and product health metrics that position the platform as an undeniable acquisition target or lay the groundwork for massive marketing scaling. ### Technical Success - **Cost Architecture Viability:** Maintaining strict control over AI API costs through the "Host-Pays" billing architecture and intelligent smart routing (e.g., DeepSeek V4 Flash). - **BYOK Adoption:** Achieving a high adoption rate of the Bring Your Own Key (BYOK) feature among power users to effectively zero out API costs for the most demanding workloads. ### Measurable Outcomes - **Activation Rate:** % of new users completing a Semantic Search or joining a Brainstorm Canvas within 24h. - **WAU to MAU Ratio:** High ratio demonstrating strong stickiness around advanced AI features. - **K-Factor (Virality):** Number of new users acquired per active user via shared links. - **Margin Protection:** Average AI API cost per active user maintained strictly below the targeted baseline, offset by BYOK adoption. ## Product Scope ### MVP - Minimum Viable Product - Core note-taking interface with vector-based Semantic Search. - Real-time collaborative Brainstorm Canvas (D3 radial graph). - Document Parsing (Chat-with-PDF) and Automated Task Extraction natively integrated into the workspace. - Foundational "AI Discovery Pack" (Freemium lifetime limits). - The "Host-Pays" billing engine and BYOK configuration for power users. ### Growth Features (Post-MVP) - Advanced Autonomous Agents (Scraper, Researcher, Monitor). - Enhanced viral loops via branded PPTX/Markdown exports. ### Vision (Future) - A fully autonomous "Second Brain" ecosystem that anticipates user needs, automatically structures knowledge, and serves as the ultimate cognitive partner for both individuals and enterprise R&D departments. ## User Journeys ### 1. The Power User (BYOK & Autonomous Ecosystem) **Persona:** Alex, an independent data science researcher analyzing dense PDFs, frustrated by arbitrary SaaS API limits. **Opening Scene:** Alex discovers Momento through a watermark on a shared presentation. They sign up and are granted the Freemium "AI Discovery Pack." **Rising Action:** Alex uploads a complex 50-page PDF and uses the Chat-with-PDF feature to extract methodologies. The AI's responses are rapid and accurate. Because Alex is doing heavy research, they quickly exhaust their Discovery Pack token limits. **Climax (The "Aha!" Moment):** Instead of hitting a hard paywall that locks them out, Memento elegantly prompts them to input their own LLM API key (BYOK). Alex pastes their DeepSeek key, and instantly, they are back to querying at near-zero marginal cost, entirely avoiding a rigid $20/mo subscription. **Resolution:** Alex fully adopts Memento as their "Second Brain", deploying autonomous Scraper agents to monitor new Arxiv papers directly into their semantic search index. ### 2. The Enterprise Team Lead (Host-Pays Collaboration) **Persona:** Sarah, an R&D Lead struggling to synthesize team ideas using scattered static docs. **Opening Scene:** Sarah creates a new Memento Note, seeds it with a product architecture problem, and launches a "Brainstorm Canvas" session. She shares the session link with 4 team members. **Rising Action:** The team members join instantly with zero friction (no need to upgrade their own accounts). They begin generating "Disruptions" and "Analogies" on the D3 radial graph. **Climax:** The LLM Router seamlessly handles the concurrent requests using Sarah's Pro tier limits (the "Host-Pays" principle). Everyone experiences premium AI generation without hitting individual paywalls or errors. **Resolution:** The session yields a structured radial map of ideas. Sarah selects the best nodes and uses Automated Task Extraction to instantly generate actionable tickets. The team has their plan, and Memento has organically acquired 4 new engaged users. ### 3. The System Administrator (Cost & Limit Management) **Persona:** David, Memento's internal Ops Administrator protecting the AI API margins. **Opening Scene:** A sudden spike in AI token usage triggers an alert on David's dashboard. **Rising Action:** David investigates and identifies a shared Brainstorm session with heavy activity. He needs to verify that the system's margin isn't bleeding. **Climax:** David checks the hybrid Redis/PostgreSQL entitlement system via the admin panel. He confirms that the Host-Pays logic is functioning perfectly: the session host's AI Discovery Pack was exhausted, and the system correctly gracefully degraded the guests' capabilities or prompted the host to upgrade/use BYOK. **Resolution:** Margin is protected. David logs a successful automated defense against API abuse. ### Journey Requirements Summary These journeys reveal the following critical capabilities we must build: - **BYOK Management:** Secure UI for API key input (AES-256-GCM encryption) and dynamic LLM routing fallbacks. - **Entitlement & Quotas:** High-performance Redis-backed usage tracking for the AI Discovery Pack, with clear UI prompts upon exhaustion. - **Real-Time Collaboration:** Robust Socket.io session management, frictionless guest-join flows, and strict role-based "Host-Pays" billing logic. - **Agent Orchestration:** UI to configure, schedule, and view outputs of autonomous agents natively in the workspace. ## Domain-Specific Requirements ### Compliance & Regulatory - **Data Residency & Privacy:** Strict EU-only data storage options (or configurable regional storage). Strict zero-data-retention agreements must be enforced via APIs to ensure R&D IP is never used for LLM training. - **SOC2 Roadmap:** The architecture must be designed from day one with SOC2 Type II compliance in mind to pass enterprise vendor security assessments. ### Technical Constraints & Security - **BYOK API Key Security:** Users' personal LLM keys must be strictly encrypted at rest (e.g., AES-256-GCM) and securely transmitted only to the LLM Router. - **Real-Time State & Quotas:** Managing high-frequency WebSocket events (Brainstorm Canvas) alongside strict Redis-backed rate limiting to enforce the "Host-Pays" rules without dropping concurrent connections. ### Integration Requirements - **LLM Provider Agnosticism:** The AI Router must gracefully handle rate limits, downtimes, and differing token-counting methodologies across OpenAI, Google, DeepSeek, and MiniMax APIs. - **SSO / SAML Integration:** Mandatory support for enterprise identity providers (Okta, Azure AD, Google Workspace) for Business/Enterprise tiers. ### Risk Mitigations - **Comprehensive Audit Logging:** Workspace administrators must have access to full audit logs detailing who accessed which notes, and specifically what data was processed by which AI agent/provider. ## Innovation & Novel Patterns ### Detected Innovation Areas 1. **Financial Architecture (The "Host-Pays" + BYOK Model):** Momento solves the SaaS AI unit economics paradox. By shifting all collaborative AI generation costs exclusively to the session host's quotas—while simultaneously offering a zero-margin Bring-Your-Own-Key (BYOK) escape hatch—the platform eliminates the traditional per-seat LLM paywall friction that stifles viral growth. 2. **Autonomous Agent Ecosystem Native to PKM:** Integrating Scraper, Researcher, and Monitor agents directly into the note environment. Instead of users manually pulling data into their notes, the "Second Brain" actively structures and retrieves knowledge via vector-based semantic search. 3. **Radial Graph-Based AI Brainstorming:** Moving away from linear chat interfaces (like standard ChatGPT) to a multi-directional, real-time D3 radial graph, where ideas expand outwards in "Waves" (Variations, Analogies, Disruptions). ### Market Context & Competitive Landscape Traditional PKM tools (like Notion or Obsidian) either charge heavy flat-rate AI add-ons ($10-$20/mo) or require highly technical, fragile plugin setups for local models. Conversely, standard whiteboard tools (Miro, FigJam) offer AI generation but lack the deep semantic connection to a user's personal knowledge base. Momento occupies the blue ocean between an enterprise collaboration whiteboard and an autonomous research assistant. ### Validation Approach - **BYOK Adoption Rate:** Track the percentage of users who, upon exhausting their Freemium "AI Discovery Pack," successfully provision their own API key rather than churning. - **Viral Coefficient (K-Factor) from Host-Pays:** Measure the organic acquisition rate specifically generated by guests joining frictionless, Host-Pays Brainstorm sessions. ### Risk Mitigation - **Risk:** The Host-Pays model leads to rapid quota exhaustion for the host, causing frustration and churn. **Mitigation:** Clear, real-time UI indicators of token consumption during a shared session, and automatic graceful degradation (e.g., smart routing to cheaper models like DeepSeek V4 Flash) before a hard block. - **Risk:** Power users abuse the BYOK implementation to overload system databases. **Mitigation:** Strict server-side rate limiting on WebSocket connections and database writes, even for BYOK users, to protect infrastructure stability. ## SaaS Web Application Specific Requirements ### Project-Type Overview Momento is a B2B and B2C SaaS platform serving as a multi-tenant personal knowledge management system. It requires complex state synchronization, robust role-based access controls for collaborative sessions, and an advanced hybrid billing architecture. ### Technical Architecture Considerations - **Frontend:** React + Next.js App Router, using D3.js for the Brainstorm radial graph and React Query for state management. - **Backend & Database:** Node.js (Next.js API Routes) with PostgreSQL (managed via Prisma) for persistent data storage. - **Real-Time Layer:** A dedicated Socket.io server (port 3002) handling the low-latency collaborative Canvas. - **AI Infrastructure:** A custom LLM Router (`lib/ai/router.ts`) supporting BYOK (AES-256-GCM encrypted keys) and dynamic fallbacks across 13 independent providers (including OpenAI, Google Gemini, Anthropic, DeepSeek, OpenRouter, Mistral, Ollama, ZAI, LM Studio, MiniMax, etc.) to ensure zero vendor lock-in. ### Tenant Model & Data Residency - Users operate within isolated workspaces. - Enterprise tenants require strict EU-only data storage or configurable regional storage to meet data residency compliance. ### RBAC Matrix & "Host-Pays" Permissions - **Session Host (Owner):** Controls session initiation, AI token expenditure, and BYOK overrides. - **Collaborator (Guest):** Can interact and generate ideas, but AI queries are routed through the Host's quota or BYOK limits. - **Workspace Admin:** Access to comprehensive audit logs detailing user access and specific AI agent processing history. ### Subscription Tiers 1. **Basic (Free):** Includes the "AI Discovery Pack" (lifetime usage limits) to drive conversion without monthly paywalls. 2. **Pro:** Standard monthly limits for power individuals, with BYOK capabilities to bypass limits. 3. **Business / Enterprise:** Pooled token limits, SSO/SAML integration (Okta, Azure AD), and advanced data residency controls. ### Integration List - **Identity:** SSO / SAML (Okta, Azure AD, Google Workspace). - **Payment:** Stripe billing integration for Pro/Business tiers. - **AI Providers:** Extensive multi-model support featuring 13 independent providers (OpenAI, Anthropic, Gemini, DeepSeek, OpenRouter, local models via Ollama/LM Studio, etc.). ## Project Scoping & Phased Development ### MVP Strategy & Philosophy **MVP Approach:** Value-Driven PLG. The MVP focuses on delivering an immediate "Aha!" moment through the "Second Brain" core loop (Chat-with-PDF, semantic search, task extraction) and leveraging organic virality via the frictionless, "Host-Pays" Brainstorm Canvas. **Resource Requirements:** A lean cross-functional team consisting of Next.js/React frontend engineers, a D3.js visualization specialist, and a backend/AI integration engineer to handle the custom LLM Router and WebSocket infrastructure. ### MVP Feature Set (Phase 1) **Core User Journeys Supported:** - The Power User (BYOK & Semantic Search) - The Enterprise Team Lead (Host-Pays Collaboration) - The System Administrator (Cost & Limit Management) **Must-Have Capabilities:** - Core note-taking interface with vector-based Semantic Search. - Real-time collaborative Brainstorm Canvas (D3 radial graph). - Document Parsing (Chat-with-PDF) and Automated Task Extraction natively integrated into the workspace. - The "Host-Pays" billing engine and BYOK configuration (AES-256-GCM encryption). - High-performance Redis-backed usage tracking for the "AI Discovery Pack". ### Post-MVP Features **Phase 2 (Growth Features):** - Advanced Autonomous Agents (Scraper, Researcher, Monitor) with native orchestration UI. - Enhanced viral loops via branded PPTX/Markdown exports. - SSO / SAML Integration for Business/Enterprise scale-out. **Phase 3 (Vision / Expansion):** - A fully autonomous "Second Brain" ecosystem that proactively anticipates user needs and structures knowledge. - SOC2 Type II compliance implementation and comprehensive enterprise vendor security controls. ### Risk Mitigation Strategy **Technical Risks:** WebSocket connection exhaustion and database write overload during highly active Brainstorm sessions. *Mitigation:* Strict server-side rate limiting, optimized Redis state caching, and fallback to lightweight AI models (e.g., DeepSeek V4 Flash) under heavy load. **Market Risks:** Power users churning when Freemium limits are reached. *Mitigation:* The frictionless BYOK escape hatch that instantly restores functionality at zero marginal cost without forcing a paid subscription. **Resource Risks:** The complexity of integrating 13 different AI APIs delays the MVP launch. *Mitigation:* Utilize an aggregation layer (like OpenRouter) for the "long-tail" of models while building robust, direct API integrations only for the core, high-volume providers (OpenAI, DeepSeek, Gemini). ## Functional Requirements ### Workspace & Knowledge Management - FR1: Users can create, read, update, and delete rich-text notes within their workspace. - FR2: Users can execute natural language semantic searches across their entire personal knowledge base. - FR3: Users can organize notes within isolated workspaces and nested hierarchies. - FR4: Users can upload PDF documents and extract text for AI contextual analysis (Chat-with-PDF). - FR5: Users can invoke automated task extraction on any note to generate structured, actionable to-do lists. - FR6: Users can leverage one-shot AI to automatically generate contextual tags and titles for their notes (Auto-Tagging / Auto-Titling). - FR7: The system will proactively detect and surface semantic connections between disconnected notes in the background ("Memory Echo") to stimulate serendipitous discovery. ### Real-Time Collaboration (Brainstorming) - FR8: Hosts can initialize a real-time collaborative Brainstorm session derived from an existing note. - FR9: Guests can join a shared Brainstorm session via a frictionless sharing link without requiring an account. - FR10: Users can visually map and generate ideas on a multi-directional radial graph (Canvas). - FR11: Users can prompt AI within the shared session to generate specific ideation "Waves" (Variations, Analogies, Disruptions). - FR12: Users can export the completed Brainstorm canvas to structured formats (Markdown, Branded PPTX). ### Billing & Entitlements - FR13: Users can monitor their remaining "AI Discovery Pack" or subscription usage limits via a real-time UI indicator. - FR14: Users can input, update, and securely store their own third-party LLM API keys (BYOK) to bypass platform limits. - FR15: Hosts can assume financial responsibility (token consumption) for all AI queries executed by guests within their active shared sessions. - FR16: Users can upgrade to paid subscription tiers (Pro, Business, Enterprise) via an integrated payment gateway. ### AI Routing & Orchestration - FR17: Users can dynamically switch between supported AI providers (OpenAI, DeepSeek, Gemini, OpenRouter, etc.) for specific generation tasks. - FR18: Administrators can configure smart-routing fallback rules to default to specific models under heavy load or quota exhaustion. - FR19: Users can configure, schedule, and view the outputs of autonomous background agents (Scraper, Researcher, Monitor). ### Enterprise Administration & Security - FR20: Enterprise users can authenticate via Single Sign-On (SSO / SAML). - FR21: Workspace administrators can view comprehensive audit logs detailing user access events and specific AI provider utilization. - FR22: Workspace administrators can configure strict data residency requirements (e.g., EU-only storage) for their tenant. - FR23: Administrators can programmatically enforce zero-data-retention headers/flags for all outbound third-party AI API requests. ## Non-Functional Requirements ### Performance - **NFR-P1 (Real-Time Latency):** Brainstorm Canvas WebSocket events (e.g., node creation, cursor movement) must propagate to all connected clients within 150ms under normal network conditions. - **NFR-P2 (Search Speed):** Vector-based semantic search queries must return initial results within 800ms for personal knowledge bases containing up to 10,000 notes. - **NFR-P3 (AI Routing):** The internal LLM Router must evaluate "Host-Pays" and BYOK rules and dispatch the prompt to the external provider within 50ms of receiving the user request. ### Security & Privacy - **NFR-S1 (Encryption):** All user-provided LLM API keys (BYOK) must be encrypted at rest using AES-256-GCM. - **NFR-S2 (Data Residency):** The architecture must support configurable regional database deployments, guaranteeing EU-only data storage for specified enterprise tenants. - **NFR-S3 (Auditability):** The system must log 100% of LLM API requests, retaining anonymized provider routing and token consumption metrics for a minimum of 1 year to support future SOC2 compliance audits. ### Scalability - **NFR-SC1 (Collaborative Sessions):** A single Brainstorm session must gracefully support up to 50 concurrent active users without degrading the 150ms latency target. - **NFR-SC2 (Rate Limiting):** The Redis-backed entitlement system must process usage quota checks in under 10ms, supporting up to 5,000 concurrent verifications per second globally. ### Reliability & Resilience - **NFR-R1 (Graceful Degradation):** If a primary AI provider (e.g., OpenAI) returns a 429 (Rate Limit) or 500-series error, the LLM Router must automatically fallback to the designated secondary provider (e.g., DeepSeek) within 1.5 seconds. - **NFR-R2 (Availability):** The core note-taking interface, database reads/writes, and offline access must maintain 99.9% uptime, functioning independently of any third-party AI provider outages.