How whisperrnote/auth works
Project Type and Purpose
• Whisperrauth is a full-stack, zero-knowledge password manager built with Next.js for the front-end and Appwrite as a Backend-as-a-Service.
• It provides secure, client-side encryption; user authentication (email/password, magic links, OTP, TOTP); credential storage; and sync across devices.
File Structure
• app/ – Next.js 13 “app router” directory. Contains page.tsx files for each route (/, /login, /register, /credentials, /forgot-password, /reset-password, /settings, /totp).
• components/ – Reusable UI primitives (Button, Card, DropdownMenu, Input) and layout (AppShell, Header).
• lib/ – Utility modules: Appwrite client initializer (appwrite.ts), shared helper functions (utils.ts).
• Configuration: .env.sample (Appwrite endpoint, project ID, collection IDs), next.config.ts, tsconfig.json, postcss.config.mjs.
README for Context
• Confirms the Next.js + Appwrite stack.
• Details features: zero-knowledge encryption (client-side), password generator, biometric login hooks, automatic syncing, TOTP generator, magic link & OTP flows.
• Mentions environment variables required to connect to Appwrite.
a. Main Components
• Client (Browser/Mobile/WebView)
• Next.js Application (Server-Side Rendering + API Routes + Client Bundle)
• Appwrite Backend (Authentication Service, Database, Storage)
• Zero-Knowledge Crypto Module (in-browser encryption/decryption)
• TOTP Generator Module (in-browser)
• External Services (e.g., CDN, Analytics – optional)
b. Relationships & Data Flows
1. User Interaction
• User visits Next.js pages (login/register/credentials).
• Inputs credentials or uses magic link/OTP.
2. Authentication
• Next.js invokes Appwrite Auth SDK via REST or JS SDK.
• Appwrite issues JWT/session cookie.
3. Zero-Knowledge Encryption
• On “save credential,” front-end uses the crypto module to encrypt data before sending to Appwrite database.
• On “view credential,” encrypted blob fetched from Appwrite, then decrypted client-side.
4. TOTP Flow
• User enables TOTP: front-end generates secret, shows QR.
• On login with TOTP, front-end validates code locally or via Appwrite function.
5. Sync
• Data changes trigger push to Appwrite; other clients pull updates on next launch or via real-time subscription.
c. Architectural Patterns & Principles
• Zero-Trust / Zero-Knowledge: all sensitive operations (encrypt/decrypt) happen on the client.
• Serverless / BaaS: Appwrite handles authentication, database, storage, and functions – no custom back-end servers needed.
• Componentization: UI and utility layers are modular (clear separation).
• Next.js App Router: server and client components co-located by route under app/.
d. Key Technologies
• Next.js 13 (React, App Router, SSR/SSG)
• Appwrite JS SDK (auth, database, storage)
• Tailwind CSS (styling)
• TypeScript (static typing)
• Web Crypto API or custom libs in lib/utils.ts for encryption