How homanp/infinite-monitor works
1. Overall shape
- This is a Next.js App Router application that serves both the dashboard editor UI and its backend API.
- The product is an AI-powered “infinite canvas” dashboard builder where widgets are generated, deployed, and rendered live in isolated frames.
2. Primary user surfaces
- The main editor lives at src/app/page.tsx and is built from the canvas and chat components in src/components/.
- Shared/public viewing is split out into src/app/share/[shareId]/page.tsx, which uses dedicated shared-dashboard components for read-only or live shared viewing.
3. Canvas/editor subsystem
- The dashboard editor is centered on an infinite canvas with drag/resize/zoom controls, widget cards, a grid, and layout management.
- Key UI pieces here are infinite-canvas, dashboard-grid, draggable-widget, zoom-controls, widget-card, and live-shared-dashboard-view.
4. AI chat and agent loop
- The chat sidebar drives widget creation and iteration via src/app/api/chat/route.ts.
- The UI components under src/components/ai-elements/ handle conversation rendering, prompt input, model selection, reasoning display, and code-block presentation.
- src/app/api/generate-title/route.ts is a supporting endpoint for auto-titling dashboards or conversations.
5. Model/provider abstraction
- The repo is designed for bring-your-own-key AI usage across multiple providers.
- src/lib/model-registry.ts, src/lib/create-model.ts, and src/lib/openrouter.ts indicate a provider/model abstraction layer, with UI support for switching models in the chat.
- Provider credentials are stored client-side in local storage, not persisted server-side.
6. Widget runtime boundary
- Each widget is treated as a separate React app running in an iframe-like isolation boundary.
- The runtime path appears to be: user prompt → AI-generated files → sandboxed build/run → served widget output.
- src/lib/widget-runner.ts and the /api/widgets/* plus /api/widget/* routes are the main backend pieces for generating, building, and serving widget artifacts.
7. Sandboxed build/execution
- Widget builds run in a secure execution environment rather than Docker, with the README explicitly calling out Secure Exec / V8 isolate.
- src/lib/durable-stream.ts suggests long-running build/chat processes stream progress back to the UI.
- src/app/api/widgets/bootstrap/route.ts and src/app/api/widget/[id]/[[...path]]/route.ts separate widget bootstrap from static asset serving.
8. Persistence layer
- State is stored in SQLite through Drizzle ORM (src/db/, drizzle.config.ts).
- src/db/schema.ts and src/db/widgets.ts are the core database definitions for widgets and related dashboard state.
- The browser also keeps user settings and API keys in Zustand/localStorage via src/store/settings-store.ts and src/store/widget-store.ts.
9. Sharing and live projection
- Sharing is a first-class subsystem, not just a URL copy feature.
- src/lib/share.ts, share-recorder.ts, share-projection.ts, and share-types.ts indicate the app can record a dashboard state, project it into a shareable format, and serve it through /api/share/[shareId]/bootstrap.
- The live view path is handled by src/components/shared-dashboard-view.tsx and live-shared-dashboard-view.tsx.
10. External data access and safety
- Widget code can make outbound requests through a dedicated /api/proxy route, which acts as a server-side CORS/data access boundary.
- src/lib/web-search.ts and src/lib/brin.ts show that the agent can search the web, but results and proxy requests are threat-scanned before use.
- src/lib/mcp-registry.ts and /api/mcp/test suggest support for tool/MCP integrations, with a registry and test path for validating connectors.
11. Templates and bootstrap flow
- The src/templates/*.json files provide prebuilt dashboard starting points for common domains.
- /api/templates serves these templates, while bootstrap routes are used to initialize widget or share state into a runnable form.
12. Operational boundary
- This repo is built and tested as a standard web app with CI, linting, and Vitest tests under src/lib/__tests__ and src/store/__tests__.
- Deployment is handled through Railway (railway.toml, GitHub deploy workflow), so the main runtime boundary is: browser UI + Next.js server + SQLite + external AI providers + sandboxed widget builds.
Main entry points: widget-runner.ts Widget runner · create-model.ts Model layer · page.tsx Editor page · infinite-canvas.tsx Infinite canvas
Components 25
Next.js app
Browser entry points and API routes
- Editor page · Main dashboard editor shell
src/app/page.tsx - Shared page · Read-only/live shared dashboard view
src/app/share/[shareId]/page.tsx - Chat API · Agent loop for widget creation and iteration
src/app/api/chat/route.ts - Widget API · Serve widget artifacts from the isolated runtime
src/app/api/widget/[id]/[[...path]]/route.ts - Widgets bootstrap · Initialize widget runtime state
src/app/api/widgets/bootstrap/route.ts - Share bootstrap · Bootstrap shared dashboard state
src/app/api/share/[shareId]/bootstrap/route.ts - Templates API · Serves starter dashboard templates
src/app/api/templates/route.ts - Proxy API · Server-side outbound request boundary
src/app/api/proxy/route.ts
UI system
Dashboard editor, chat, and shared views
- Infinite canvas · Main layout and interaction surface
src/components/infinite-canvas.tsx - Dashboard grid · Canvas positioning and layout layer
src/components/dashboard-grid.tsx - Widget card · Per-widget presentation and controls
src/components/widget-card.tsx - Chat sidebar · Prompting and iteration surface
src/components/chat-sidebar.tsx - AI elements · Conversation, prompt, model, and reasoning UI
src/components/ai-elements/conversation.tsx - Shared view · Shared dashboard rendering components
src/components/shared-dashboard-view.tsx - Live projection · Live shared dashboard presentation
src/components/live-shared-dashboard-view.tsx
Widget runtime
Generation, sandboxed execution, and serving
- Widget runner · Build/run boundary for isolated widgets
src/lib/widget-runner.ts - Durable stream · Streams long-running build and chat progress
src/lib/durable-stream.ts
Data layer
SQLite persistence and client state
- SQLite layer · Drizzle-backed database access
src/db/index.ts - DB schema · Widget and dashboard tables
src/db/schema.ts - Client stores · Local settings and widget state in browser storage
src/store/widget-store.ts
AI and tools
Model abstraction, search, and MCP integration
- Model layer · Provider selection and model creation
src/lib/create-model.ts - Model registry · Available models and providers
src/lib/model-registry.ts - OpenRouter · External model gateway integration
src/lib/openrouter.ts - Search and MCP · Web search, threat scanning, and connector registry
src/lib/web-search.ts
Sharing
Recording, projection, and shared delivery
- Share core · Share recording, projection, and types
src/lib/share.ts
Connections 22
- Editor page → Infinite canvas: renders · Editor page composes the canvas shell and workspace
- Editor page → Chat sidebar: renders · Editor page includes the chat sidebar
- Infinite canvas → Dashboard grid: uses · Canvas positions widgets on the dashboard grid
- Infinite canvas → Widget card: hosts · Canvas renders widget cards as movable units
- Chat sidebar → AI elements: uses · Chat sidebar is built from AI conversation controls
- Chat API → Model layer: selects · Chat API invokes the chosen model/provider
- Model layer → Model registry: consults · Model creation is driven by the registry
- Model layer → OpenRouter: adapts · One provider path goes through OpenRouter
- Chat API → Widget runner: triggers · Agent output can produce widget builds and runs
- Widget runner → Durable stream: streams · Build/run progress is streamed back to the UI
- Widget API → Widget runner: serves · Widget serving boundary is backed by the runner
- Widgets bootstrap → Widget runner: boots · Bootstrap endpoint initializes widget runtime state
- Widget runner → SQLite layer: persists · Widget artifacts and state are stored server-side
- SQLite layer → DB schema: defined by · Drizzle database uses the schema definitions
- Editor page → Client stores: reads · Editor UI relies on client-side settings and widget state
- Share bootstrap → Share core: uses · Shared bootstrap is produced by the share engine
- Shared page → Shared view: renders · Shared page uses the shared dashboard view
- Shared view → Live projection: extends · Live shared viewing is a specialized presentation
- Share core → SQLite layer: reads · Share recording and projection are backed by persisted state
- Templates API → DB schema: loads · Templates initialize dashboard state and content
- Proxy API → Search and MCP: guards · Outbound access and tool use are mediated through safety layers
- Search and MCP → Model layer: feeds · Tooling supports the AI agent loop