WhisperRNote — Architecture Overview (Language-agnostic)
Purpose
- Explain high-level structure and responsibilities of the WhisperRNote system for engineers and architects.
- Provide a quick reference for onboarding, design decisions, and components without requiring language-specific details.
Scope
- Frontend application (UI, routing, state, components)
- Backend and server-side APIs
- Integrations (AI providers, Appwrite, blockchain, external storage)
- Data flow, storage, and security considerations
- Deployment, developer workflows, and operational notes
- System Overview
- WhisperRNote is a web-first note-taking and AI-assisted editing application. It provides a rich client UI, server-side APIs, and integrations with AI services and identity/back-end storage.
- The project follows a modular structure: a frontend app (Next.js), shared utilities, integration adapters, and small scripts for ops/tests.
- Major Components
-
Frontend (UI)
- Purpose: Interactive note creation, editing, search, and sharing features with AI assistance.
- Location:
src/(app and components directories) - Key parts:
- Pages & Routing: Located under
src/app/. Routes follow a convention-based structure where each folder maps to a route. Examples:landing,pitch,verify,reset, note-specific routes inshared/[noteid]. - UI Components:
src/components/contains reusable components likeNoteEditor,NoteCard,AppHeader, search components, modals, and theme providers. - State & Context:
src/contexts/NotesContext.tsxand components use React context/hooks for state management and local UI state. - Styles: TailwindCSS utility classes with
globals.cssandtailwind.config.ts.
- Pages & Routing: Located under
-
Backend & API
- Purpose: Provide server-side endpoints for AI-assisted operations, integration glue, authentication utilities, and helper services used by the frontend.
- Location:
src/app/api/andsrc/lib/for shared server utilities. - Key parts:
- API Routes:
src/app/api/*contains route handlers for AI interactions and other server-side endpoints. - AI Service Abstraction:
src/lib/ai-service.ts(andsrc/lib/ai/providers) provides a pluggable abstraction over different AI providers. - Integrations:
src/lib/integrations.tsandsrc/integrations/adapters for services such as Appwrite, Gemini, Umi, and ICP. - Appwrite adapter:
src/lib/appwrite.tsandsrc/lib/appwrite/*manage Appwrite API keys, request signing, and document operations. - Auth utilities:
src/lib/auth.tsandsrc/lib/auth-utils.tsfor authentication flows, wallet-based nonce signing, and helpers.
- API Routes:
-
Integrations
- AI Providers
- The app supports multiple AI backends via adapters under
src/lib/aiandsrc/integrations/gemini/. These adapters normalize requests/responses so the frontend and server can switch providers with minimal changes.
- The app supports multiple AI backends via adapters under
- Appwrite
- Used as a primary backend-as-a-service for user management, storage, and database-like operations. There are utility scripts and typed definitions under
src/lib/appwriteandsrc/types/appwrite.*.
- Used as a primary backend-as-a-service for user management, storage, and database-like operations. There are utility scripts and typed definitions under
- Blockchain / ICP
- Some features integrate with blockchain or ICP (Internet Computer Protocol) via
src/lib/icpandsrc/lib/blockchain/*. These provide helper utilities and client code.
- Some features integrate with blockchain or ICP (Internet Computer Protocol) via
- Other Integrations
umiclient and other connectors are present to support external services.
- AI Providers
- Data Flow
-
User Interaction Flow
- User opens the web UI (Next.js frontend) which either retrieves user session data or redirects to authentication flows.
- The frontend requests note data from server-side APIs or Appwrite directly (depending on the route and SSR/CSR implementation).
- When AI features are invoked (e.g., generate, summarize), the frontend calls server-side API routes which:
- Validate input and user permissions
- Route the request to the configured AI provider adapter
- Post-process results and return them to the client
- Notes and metadata are stored in Appwrite or encrypted locally depending on features; cryptographic helpers exist in
src/lib/encryption.
-
Server-to-Provider Flow
- The server ensures sensitive keys are not exposed to the client. Requests to AI providers run server-side where API keys and signing logic are stored in environment variables.
- Provider adapters handle provider-specific payload shaping, rate limiting, and error handling.
-
Offline & Local Considerations
- Components like
NoteEditorhandle local state and may persist drafts to local storage before committing changes to the backend.
- Components like
- Security and Privacy
- Secrets Management
- API keys and secrets are expected to be supplied via environment variables (see
.sampleandenv.sample). The repo containsappwrite.jsonandappwritehelpers but theAGENTS.mdwarns not to edit some appwrite files.
- API keys and secrets are expected to be supplied via environment variables (see
- Authentication
- Appwrite identity and wallet-based nonce flows are used for login/verification. Helpers for signing and verifying wallet signatures exist under
src/lib/authandsrc/lib/wallet-nonce.ts.
- Appwrite identity and wallet-based nonce flows are used for login/verification. Helpers for signing and verifying wallet signatures exist under
- Data Protection
- There's an
encryptionlibrary undersrc/lib/encryptionfor client-side or server-side encryption needs.
- There's an
- Client Trust Boundaries
- Sensitive operations (AI calls, key use) happen server-side. The frontend receives sanitized responses only.
- Developer Workflow & Tooling
- Scripts
- Repo includes
scripts/for environment orchestration (init-nodes.sh,start-nodes.sh, etc.).
- Repo includes
- Builds & Local Dev
- Next.js dev server used in development:
npm run dev(configured to run on port 3001). Production build vianpm run build.
- Next.js dev server used in development:
- Linting & Formatting
- ESLint and TailwindCSS are configured; follow repository guidelines in
AGENTS.mdandCONTRIBUTING.md.
- ESLint and TailwindCSS are configured; follow repository guidelines in
- Testing
- No test framework is configured by default. Add tests intentionally and align with existing patterns if introducing testing.
- Deployment
- Typical deployment targets: Vercel or similar platforms supporting Next.js (serverless functions + static assets).
- Environment variables must be configured in deployment for Appwrite, AI provider keys, and any blockchain credentials.
- Build output is Next.js production assets; server-side API routes become serverless endpoints.
- Observability & Operations
- Logging
- Use service-side logging in API routes. The repo includes
dev.logas a local artifact.
- Use service-side logging in API routes. The repo includes
- Monitoring
- No built-in monitoring agents; recommend integrating Sentry/Datadog for error and performance monitoring.
- Extensibility & Design Principles
- Adapter Pattern
- Integrations (AI, Appwrite, ICP) follow an adapter-style approach to allow swapping providers with minimal change.
- Separation of Concerns
- Frontend handles UI and interaction; heavy lifting (AI, auth) handled server-side to protect secrets and centralize logic.
- Minimal Surface Area
- Keep provider-specific logic on the server, keep shared utilities in
src/libto avoid duplication.
- Keep provider-specific logic on the server, keep shared utilities in
- Notable Files and Directories (Quick Reference)
src/app/- Next.js app routes and page componentssrc/components/- Reusable UI componentssrc/lib/- Server and shared utilities (AI, auth, integrations, encryption)src/integrations/- Third-party integration adapterssrc/contexts/- React contexts and state providersscripts/- Dev and ops scriptspublic/- Static assets
- Recommendations and Next Steps
- Add architecture diagrams (sequence diagrams for AI flows, component diagrams for frontend) for faster onboarding.
- Add automated tests for critical adapters (AI providers, Appwrite access) and auth flows.
- Introduce CI checks for linting and build verification.
- Add runtime secrets checks for local dev and CI to avoid missing configuration.
Appendix
- This overview is intentionally language-agnostic and focuses on system responsibilities, boundaries, and integration points. For implementation details, consult the files under
src/andscripts/.