How chefberke/pane works
1. Overall shape
- This is a Next.js App Router application built as a collaborative workspace/canvas editor.
- The repo is organized around a feature-first client UI in app/features, with a smaller set of route handlers in app/api and page shells in app/.
2. Top-level application routes
- Public/auth flows live at /, /sign-in, /sign-up, and /auth/callback.
- The main product areas appear to be:
- /w/[workspaceId] for the workspace editor
- /w for workspace landing/listing
- /s/[token] for shared view links
- /s/invite/[token] for invite acceptance
- These routes likely assemble the same underlying workspace data into different access modes: owner/editor, invited user, or public/shared viewer.
3. Editor runtime is client-side and feature-composed
- Most of the behavior is implemented in app/features/* as reusable UI + hooks rather than monolithic pages.
- app/features/canvas is the central orchestration layer: it manages viewport, selection, history, persistence, presence, keyboard shortcuts, paste handling, and visible item calculation.
- The editor screen is then layered with domain-specific systems: blocks, connectors, frames, comments, toolbar, context menu, search, sharing, menu panel, and workspace sidebar.
4. Core data model: workspace canvas
- The primary content model is a workspace containing visual objects:
- blocks
- connectors between blocks
- frames/groups
- comments
- user presence/cursors
- Each domain has its own types, utils, hooks, and rendering components, which suggests the canvas state is normalized and manipulated through dedicated submodules rather than ad hoc props.
5. Interaction and layout boundaries
- app/features/canvas and related hooks handle the low-level interaction layer: drag, resize, marquee selection, pinch zoom, viewport following, idle hints, and keyboard shortcuts.
- app/features/blocks, app/features/frames, and app/features/connectors own the geometry and interaction for their respective objects.
- This separation makes the diagram clearer: the canvas is the stage, and each object type is an independently interactive subsystem.
6. Rendering system for content blocks
- Blocks are not just generic rectangles; they have specialized renderers for rich content:
- text notes
- images
- links
- embeds for GitHub, YouTube, Twitter, Spotify, maps, and PDFs
- app/features/blocks/renderers/* is a content adaptation layer that turns URLs or block types into specific visual presentations.
- The preview API and preview/security.ts likely support safe fetching of remote metadata for link/embed previews.
7. Collaboration and sharing
- Real-time collaboration appears to be a first-class subsystem:
- usePresenceSync, usePresence, PeerLayer, FollowOverlay, and avatar/member UI indicate live peer awareness.
- Sharing is split into:
- invite tokens and acceptance flow
- share links/tokens
- per-user roles/capabilities
- member management
- docs/sharing-permissions.md and the share feature hooks (useMembers, useInvites, useShareLinks, useViewerCapability) imply that access control is a core architectural concern, not just a UI detail.
8. Workspace management and app-level chrome
- app/features/workspace and app/features/menu-panel handle workspace discovery, switching, CRUD, import/export, settings, delete/trash, and feedback.
- This is the “control plane” around the editor: it governs which workspace is active and how users move data in/out.
- Search, items panel, theme switching, and shortcuts help navigate large canvases and are treated as separate overlays/modals rather than part of the canvas core.
9. Auth and session flow
- Authentication is built as a dedicated feature set under app/features/auth, with sign-in/sign-up pages and a callback page.
- The UI suggests both magic-code and OAuth login paths.
- Hooks like useRedirectIfAuthed and useNextParam indicate route-level gating and post-login redirect handling.
- app/lib/authedFetch.ts is the likely boundary for authenticated client-to-server calls, keeping auth concerns out of feature code.
10. Server/API boundaries
- Route handlers in app/api provide the mutation and privileged operations layer:
- workspace/save and workspace/import
- share/[token]
- invite/[token]/accept
- preview
- feedback
- These endpoints form the backend integration point for the client editor, especially for persistence, import/export, token-based access, and user feedback submission.
11. Data, permissions, and admin infrastructure
- instant.schema.ts and instant.perms.ts are strong indicators of a schema-driven realtime backend with explicit permission rules.
- app/lib/db.ts, app/lib/admin.ts, and app/lib/env.ts separate normal app access from privileged/admin operations and environment wiring.
- app/lib/rateLimit.ts suggests at least some API routes are protected against abuse, which matters for public share/invite/preview endpoints.
12. Operational/supporting assets
- scripts/backfill-links.ts indicates a maintenance/migration script for stored link data.
- .github/workflows/ci.yml provides CI automation.
- docs/design-system.md and docs/sharing-permissions.md are useful for architecture intent, especially around UI consistency and access control.
13. How data likely flows through the system
- A user enters a workspace route → the page mounts the canvas/editor shell → feature hooks load workspace state and presence data → local interactions mutate selection/layout/content → changes are persisted through backend APIs or realtime DB hooks → collaborators see updates through presence/sync layers.
- Public invite/share flows follow a separate token-based path, with the server validating access and the client rendering a restricted or shared view.
14. What to diagram as the main subsystems
- App routing/auth shell
- Workspace/editor canvas runtime
- Domain object systems: blocks, frames, connectors, comments
- Collaboration/share/permissions
- Workspace management and modals/overlays
- Server route handlers and realtime/data backend
- Supporting admin/env/rate-limit infrastructure
Main entry points: Canvas.tsx Canvas · Share.tsx Share · MenuPanel.tsx Menu Panel · route.ts Invite API
Components 28
App Shell
Route shells, entry pages, and auth flows
- Home · Landing page and top-level entry
app/page.tsx - Sign In · Authentication page
app/sign-in/page.tsx - Sign Up · Account creation page
app/sign-up/page.tsx - Callback · OAuth or magic-code callback handling
app/auth/callback/page.tsx - Workspace · Main workspace editor shell
app/w/[workspaceId]/page.tsx - Workspaces · Workspace landing and list view
app/w/page.tsx - Shared View · Public shared workspace view
app/s/[token]/page.tsx - Invite Accept · Invite token acceptance page
app/s/invite/[token]/page.tsx
Editor Runtime
Client-side canvas orchestration and interactive object systems
- Canvas · Central editor orchestration and interaction layer
app/features/canvas/Canvas.tsx - World · Canvas composition and overlay structure
app/features/canvas/CanvasWorld.tsx - Blocks · Movable content blocks and rich renderers
app/features/blocks/Block.tsx - Frames · Resizable framed regions and thumbnails
app/features/frames/Frame.tsx - Connectors · Edges and endpoint editing between items
app/features/connectors/Connectors.tsx - Comments · Comment bubbles, threads, and composer
app/features/comments/CommentsSheet.tsx - Toolbar · Alignment and quick editing actions
app/features/toolbar/Toolbar.tsx - Workspace Mgmt · Workspace discovery, CRUD, transfer, and redirect
app/features/workspace/WorkspaceSidebar.tsx - Menu Panel · Import, export, settings, feedback, and trash
app/features/menu-panel/MenuPanel.tsx
Collaboration
Presence, sharing, invites, and permissions
Server & Infra
API handlers and app-level integration boundaries
- Save · Persist workspace state
app/api/workspace/save/route.ts - Import · Import workspace data
app/api/workspace/import/route.ts - Share API · Resolve shared workspace access
app/api/share/[token]/route.ts - Invite API · Accept invite tokens
app/api/invite/[token]/accept/route.ts - Preview API · Fetch safe link and embed metadata
app/api/preview/route.ts - Feedback API · Submit user feedback
app/api/feedback/route.ts - App Lib · Auth fetch, db, env, admin, and rate limits
app/lib/db.ts - Schema · Backend schema and permission rules
instant.schema.ts - Permissions · Realtime access control rules
instant.perms.ts
Connections 28
- Workspace → Canvas: mounts · Workspace route composes the editor runtime
- Workspaces → Workspace Mgmt: uses · Workspace list is driven by workspace management features
- Shared View → Canvas: renders · Shared view reuses the canvas runtime
- Invite Accept → Invite API: calls · Invite acceptance page completes via token endpoint
- Sign In → Callback: returns to · Login flow redirects through callback handling
- Sign Up → Callback: returns to · Signup flow redirects through callback handling
- Canvas → World: composes · Canvas assembles the main world and overlay layers
- Canvas → Blocks: manages · Canvas coordinates block state and interactions
- Canvas → Frames: manages · Canvas coordinates frame interactions and layout
- Canvas → Connectors: manages · Canvas coordinates connector geometry and edits
- Canvas → Comments: manages · Canvas integrates comment rendering and activity
- Canvas → Toolbar: drives · Canvas feeds selection and context into the toolbar
- Canvas → Presence: syncs · Canvas runtime syncs peer presence and follow state
- Canvas → Save: persists via · Editor changes are saved through workspace mutations
- Canvas → Preview API: fetches via · Block previews and embeds use preview metadata
- Blocks → Preview API: uses · Rich block renderers depend on safe preview fetches
- Share → Presence: shows · Sharing UI exposes collaborators and live presence
- Share → Share API: reads · Shared access is resolved through token endpoint
- Share → Invite API: invites via · Invite workflow is backed by acceptance endpoint
- Workspace Mgmt → Menu Panel: opens · Workspace control plane is surfaced in the menu panel
- Menu Panel → Import: imports via · Import modal uses the workspace import route
- Menu Panel → Feedback API: submits via · Feedback modal sends submissions to the feedback route
- Save → App Lib: uses · API routes rely on shared app libraries
- Import → App Lib: uses · API routes rely on shared app libraries
- Share API → Schema: guards by · Shared access is constrained by schema-backed permissions
- Invite API → Permissions: guards by · Invite acceptance is validated against permission rules
- App Lib → Schema: connects to · App libraries bridge to the realtime backend
- Schema → Permissions: enforced by · Permission rules define access boundaries over the schema