Architecture
The application follows a single-page architecture with the mainApp.jsx component managing global state and coordinating between child components.
Component hierarchy
TheApp component serves as the root container and manages:
- File state and active file selection
- Sidebar visibility toggle
- Font size scaling factor
- Drag-and-drop file upload
- LocalStorage persistence
Sidebar
Handles file list display, file selection, and file management actions (upload, create new, remove).Toolbar
Displays the active file title and provides controls for sidebar toggle and font size adjustment.MarkdownRenderer
Renders markdown content using react-markdown with GitHub Flavored Markdown support. It delegates mermaid diagram rendering to theMermaid component.
How components work together
- File management flow: User uploads or creates a file → Sidebar updates → App state changes → MarkdownRenderer receives new content
- Font scaling: User adjusts font size in Toolbar → App state updates → MarkdownRenderer applies new scale factor via CSS variable
- Mermaid diagrams: MarkdownRenderer detects mermaid code blocks → Mermaid component renders SVG diagram
- Sidebar toggle: User clicks toggle in Toolbar → App state updates → Sidebar visibility changes
State management
The application uses React’s built-inuseState hooks for state management, with all state centralized in the App component. Key state includes:
files: Array of file objects with id, name, and contentactiveFileId: Currently selected file IDisOpen: Sidebar visibilityfontSizeFactor: Markdown scaling factor (0.5 to 2.0)isToolbarHidden: Auto-hide state based on scroll
Component pages
Markdown renderer
Core markdown rendering with GFM support
Sidebar
File list and management interface
Toolbar
Controls and title bar
Mermaid
Diagram rendering component