# rajin-khan/puffnotes architecture

> Architecture diagram of the GitHub repository rajin-khan/puffnotes, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/rajin-khan/puffnotes
- Repository: https://github.com/rajin-khan/puffnotes

## Overview

#### Purpose and Runtime
Puffnotes is a Vite-built React single-page markdown editor with two operating modes: private local/offline editing and authenticated Google Drive-backed editing. The browser is the primary runtime; Vercel deployment configuration is present at `puffnotes/vercel.json`. Application bootstrap flows from `puffnotes/src/main.jsx` into `puffnotes/src/App.jsx`.

#### Application Routing and Mode Selection
`puffnotes/src/App.jsx` is the top-level state coordinator, selecting marketing/landing, onboarding, offline, or online experiences. `puffnotes/src/components/LandingPage.jsx` and `puffnotes/src/components/MarketingLanding.jsx` introduce the product and direct users into a mode. `puffnotes/src/components/OnboardingModal.jsx` and `puffnotes/src/components/OnlineSetupModal.jsx` collect mode-specific setup before an editor is entered.

#### Offline Editing Boundary
Offline mode is implemented by `puffnotes/src/components/OfflineApp.jsx` and browser-side filesystem access through `puffnotes/src/hooks/useFileSystemAccess.js`. This establishes a local-first boundary: note content and file interactions stay in the Chromium browser without account or network requirements. The File System Access API is therefore a material browser compatibility constraint.

#### Online Editing and Cloud Sync
`puffnotes/src/components/OnlineApp.jsx` is the connected editor surface. It delegates identity/session configuration to `puffnotes/src/lib/firebase.js` and Drive operations to `puffnotes/src/lib/googleDrive.js`. Firebase and Google authentication/Google Drive are external service boundaries; online note persistence and multi-device synchronization depend on them rather than a repository-hosted backend.

#### Authoring, Rendering, and Export Pipeline
The editor flows markdown through live rendering in `puffnotes/src/components/MarkdownPreview.jsx`. AI enhancement is a separate transformation stage: UI actions invoke `puffnotes/src/lib/beautifyWorkflow.js`, which accesses Groq through `puffnotes/src/lib/groq.js`; user-provided API keys support the external Groq boundary. PDF export is handled by `puffnotes/src/lib/exportNoteToPdf.jsx`, with layout/page splitting logic in `puffnotes/src/lib/pdfPagination.js`.

#### Interaction Shell and User Preferences
Shared UI overlays isolate secondary workflows from editor surfaces: settings in `puffnotes/src/components/SettingsModal.jsx`, shortcuts in `puffnotes/src/components/KeyboardShortcutsModal.jsx`, and animated modal behavior in `puffnotes/src/components/ModalMotion.jsx`. Theme selection and persistence are centralized in `puffnotes/src/lib/themeManager.js`, applied through `puffnotes/src/components/ThemeSwitcher.jsx` and `puffnotes/src/components/ThemeBackground.jsx`.

#### Presentation Assets and Theme System
The visual system is predominantly client-side CSS, rooted in `puffnotes/src/App.css` and `puffnotes/src/index.css`, with named theme stylesheets such as `puffnotes/src/styles/galaxyTheme.css` and `puffnotes/src/styles/komorebiTheme.css`. Background video assets are statically served from `puffnotes/public/`, allowing themed/editor visuals without an application media service.

Main entry points: [`puffnotes/src/components/OnlineApp.jsx`](https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/components/OnlineApp.jsx) (Online editor), [`puffnotes/src/App.jsx`](https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/App.jsx) (App coordinator), [`puffnotes/src/components/OfflineApp.jsx`](https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/components/OfflineApp.jsx) (Offline editor), [`puffnotes/src/components/OnboardingModal.jsx`](https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/components/OnboardingModal.jsx) (Mode setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_browser["Browser Application"]
  node_bootstrap["React bootstrap<br/>entry point<br/>[main.jsx]"]
  node_app["App coordinator<br/>route and mode state<br/>[App.jsx]"]
  node_landing["Landing experiences<br/>marketing UI<br/>[LandingPage.jsx]"]
  node_onboarding["Mode setup<br/>onboarding UI"]
  node_vercel["Vercel deployment<br/>deployment configuration<br/>[vercel.json]"]
end

subgraph group_offline["Offline Mode"]
  node_offline_app["Offline editor<br/>local editor surface<br/>[OfflineApp.jsx]"]
  node_filesystem{{"File System Access API<br/>browser filesystem"}}
end

subgraph group_online["Online Mode"]
  node_online_setup["Online setup<br/>connected-mode setup"]
  node_online_app["Online editor<br/>connected editor surface<br/>[OnlineApp.jsx]"]
  node_firebase{{"Firebase auth<br/>identity client<br/>[firebase.js]"}}
  node_drive{{"Google Drive client<br/>cloud persistence client<br/>[googleDrive.js]"}}
end

subgraph group_authoring["Authoring Pipeline"]
  node_preview["Markdown preview<br/>live renderer"]
  node_beautify["AI beautify workflow<br/>markdown transformation"]
  node_groq{{"Groq client<br/>AI service client<br/>[groq.js]"}}
  node_pdf_export["PDF export<br/>export pipeline"]
  node_pagination["PDF pagination<br/>page layout<br/>[pdfPagination.js]"]
end

subgraph group_presentation["UI and Themes"]
  node_overlays["Settings and shortcuts<br/>shared modal UI<br/>[SettingsModal.jsx]"]
  node_theme_manager["Theme manager<br/>preference persistence<br/>[themeManager.js]"]
  node_theme_ui["Theme presentation<br/>switcher and background UI<br/>[ThemeSwitcher.jsx]"]
  node_styles["CSS themes and assets<br/>static presentation<br/>[App.css]"]
end

node_bootstrap -->|"mounts"| node_app
node_app -->|"shows"| node_landing
node_landing -->|"starts mode selection"| node_onboarding
node_app -->|"opens"| node_onboarding
node_onboarding -->|"enters offline mode"| node_offline_app
node_offline_app -->|"reads and writes local files"| node_filesystem
node_app -->|"opens"| node_online_setup
node_online_setup -->|"enters online mode"| node_online_app
node_online_app -->|"configures identity and session"| node_firebase
node_online_app -->|"syncs notes"| node_drive
node_offline_app -->|"renders markdown"| node_preview
node_online_app -->|"renders markdown"| node_preview
node_online_app -->|"enhances markdown"| node_beautify
node_beautify -->|"requests AI completion"| node_groq
node_offline_app -->|"exports note"| node_pdf_export
node_online_app -->|"exports note"| node_pdf_export
node_pdf_export -->|"splits page layout"| node_pagination
node_app -->|"opens secondary workflows"| node_overlays
node_overlays -->|"updates preference"| node_theme_manager
node_theme_ui -->|"selects theme"| node_theme_manager
node_theme_manager -->|"applies visual theme"| node_styles

click node_bootstrap "https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/main.jsx"
click node_app "https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/App.jsx"
click node_landing "https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/components/LandingPage.jsx"
click node_onboarding "https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/components/OnboardingModal.jsx"
click node_offline_app "https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/components/OfflineApp.jsx"
click node_filesystem "https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/hooks/useFileSystemAccess.js"
click node_online_setup "https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/components/OnlineSetupModal.jsx"
click node_online_app "https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/components/OnlineApp.jsx"
click node_firebase "https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/lib/firebase.js"
click node_drive "https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/lib/googleDrive.js"
click node_preview "https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/components/MarkdownPreview.jsx"
click node_beautify "https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/lib/beautifyWorkflow.js"
click node_groq "https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/lib/groq.js"
click node_pdf_export "https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/lib/exportNoteToPdf.jsx"
click node_pagination "https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/lib/pdfPagination.js"
click node_overlays "https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/components/SettingsModal.jsx"
click node_theme_manager "https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/lib/themeManager.js"
click node_theme_ui "https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/components/ThemeSwitcher.jsx"
click node_styles "https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/App.css"
click node_vercel "https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/vercel.json"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_bootstrap,node_app,node_landing,node_onboarding,node_vercel toneBlue
class node_offline_app,node_filesystem toneAmber
class node_online_setup,node_online_app,node_firebase,node_drive toneMint
class node_preview,node_beautify,node_groq,node_pdf_export,node_pagination toneRose
class node_overlays,node_theme_manager,node_theme_ui,node_styles toneIndigo
```

## Components

### Browser Application

Vite React single-page runtime.

- [React bootstrap](https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/main.jsx): entry point · `puffnotes/src/main.jsx`
- [App coordinator](https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/App.jsx): route and mode state · Selects landing, setup, offline, or online experiences. · `puffnotes/src/App.jsx`
- [Landing experiences](https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/components/LandingPage.jsx): marketing UI · `puffnotes/src/components/LandingPage.jsx`
- [Mode setup](https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/components/OnboardingModal.jsx): onboarding UI · `puffnotes/src/components/OnboardingModal.jsx`
- [Vercel deployment](https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/vercel.json): deployment configuration · `puffnotes/vercel.json`

### Offline Mode

Local-first editing without an account or network.

- [Offline editor](https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/components/OfflineApp.jsx): local editor surface · `puffnotes/src/components/OfflineApp.jsx`
- [File System Access API](https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/hooks/useFileSystemAccess.js): browser filesystem · Chromium browser compatibility boundary. · `puffnotes/src/hooks/useFileSystemAccess.js`

### Online Mode

Authenticated Google Drive-backed editing.

- [Online setup](https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/components/OnlineSetupModal.jsx): connected-mode setup · `puffnotes/src/components/OnlineSetupModal.jsx`
- [Online editor](https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/components/OnlineApp.jsx): connected editor surface · `puffnotes/src/components/OnlineApp.jsx`
- [Firebase auth](https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/lib/firebase.js): identity client · External Firebase and Google authentication boundary. · `puffnotes/src/lib/firebase.js`
- [Google Drive client](https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/lib/googleDrive.js): cloud persistence client · Persists notes and enables multi-device sync through Google Drive. · `puffnotes/src/lib/googleDrive.js`

### Authoring Pipeline

- [Markdown preview](https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/components/MarkdownPreview.jsx): live renderer · `puffnotes/src/components/MarkdownPreview.jsx`
- [AI beautify workflow](https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/lib/beautifyWorkflow.js): markdown transformation · `puffnotes/src/lib/beautifyWorkflow.js`
- [Groq client](https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/lib/groq.js): AI service client · Uses user-provided API keys for the external Groq service. · `puffnotes/src/lib/groq.js`
- [PDF export](https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/lib/exportNoteToPdf.jsx): export pipeline · `puffnotes/src/lib/exportNoteToPdf.jsx`
- [PDF pagination](https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/lib/pdfPagination.js): page layout · `puffnotes/src/lib/pdfPagination.js`

### UI and Themes

- [Settings and shortcuts](https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/components/SettingsModal.jsx): shared modal UI · `puffnotes/src/components/SettingsModal.jsx`
- [Theme manager](https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/lib/themeManager.js): preference persistence · `puffnotes/src/lib/themeManager.js`
- [Theme presentation](https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/components/ThemeSwitcher.jsx): switcher and background UI · `puffnotes/src/components/ThemeSwitcher.jsx`
- [CSS themes and assets](https://github.com/rajin-khan/puffnotes/blob/main/puffnotes/src/App.css): static presentation · Client-side styles include named themes; background videos are served from public assets. · `puffnotes/src/App.css`

## Connections

- React bootstrap → App coordinator: mounts
- App coordinator → Landing experiences: shows
- Landing experiences → Mode setup: starts mode selection
- App coordinator → Mode setup: opens
- Mode setup → Offline editor: enters offline mode
- Offline editor → File System Access API: reads and writes local files
- App coordinator → Online setup: opens
- Online setup → Online editor: enters online mode
- Online editor → Firebase auth: configures identity and session
- Online editor → Google Drive client: syncs notes
- Offline editor → Markdown preview: renders markdown
- Online editor → Markdown preview: renders markdown
- Online editor → AI beautify workflow: enhances markdown
- AI beautify workflow → Groq client: requests AI completion
- Offline editor → PDF export: exports note
- Online editor → PDF export: exports note
- PDF export → PDF pagination: splits page layout
- App coordinator → Settings and shortcuts: opens secondary workflows
- Settings and shortcuts → Theme manager: updates preference
- Theme presentation → Theme manager: selects theme
- Theme manager → CSS themes and assets: applies visual theme
