How ldk-hub/bmad-2d-monitor works
1. What this repository is
- This is primarily a client-side React 18 + TypeScript + Vite application for a pixel-art virtual office agent monitor.
- The runtime product is a 2D UI simulation, while a large portion of the repo is devoted to BMAD method artifacts, architecture docs, and AI-assisted workflow scaffolding.
2. Top-level boundary: runtime app vs process/tooling
- The runtime application lives under src/, public/, and the Vite entry files.
- The delivery/process layer lives under docs/, _bmad/, _bmad-output/, .agent/workflows/, and .github/workflows/.
- That separation matters: the BMAD folders are not part of the shipped app; they define planning, validation, and AI-driven development workflows.
3. Application composition
- src/main.tsx bootstraps the React app.
- src/App.tsx is the composition root that likely assembles the office scene and the monitoring panel into one screen.
- Styling is app-level CSS plus the referenced utility styling approach from the README.
4. Core UI subsystems
- src/features/office/OfficeMap.tsx renders the virtual office layout.
- src/features/office/PixelFurniture.tsx provides the furniture/scene objects that make the office feel like a pixel-art environment.
- src/features/agents/AgentSprite.tsx renders the agent avatars and their animated states.
- These are the main visual layers an architect would diagram as the scene renderer.
5. State and real-time agent model
- src/store/useAgentStore.ts is the central state boundary, implemented with Zustand.
- src/types/agent.ts defines the agent data model consumed by both rendering and monitoring.
- src/hooks/useAgentMovement.ts encapsulates movement/behavior updates, so motion logic is separated from rendering components.
6. Data flow through the UI
- Agent state is stored centrally in Zustand.
- The office scene reads that state to position and animate agents.
- The monitoring panel reads the same state to show per-agent status, CPU/MEM, task, and logs.
- This creates a single source of truth with two consumers: the visual simulation and the dashboard-style observer panel.
7. Animation and rendering model
- The README indicates Konva.js is the 2D engine choice, so the app is architected around canvas-based sprite rendering rather than DOM-heavy animation.
- The office uses depth sorting / Y-sorting to simulate 2.5D overlap in the scene.
- Agent behavior is described as goal-oriented and FSM-like, so movement/state transitions are part of the interaction model, not just cosmetic animation.
8. Asset pipeline
- public/assets/ holds static image assets, including the preview image and likely sprite/furniture art.
- src/hooks/useImageLoader.ts adds a custom image loading/preprocessing layer.
- The README’s “chroma background removal” suggests assets may arrive with checkerboard-style backgrounds that are programmatically turned into transparency before rendering.
9. Monitoring and observability surface
- src/components/MonitorPanel.tsx is the always-visible operational view.
- Instead of click-to-inspect interactions, the panel aggregates all agents’ live data in one place.
- Architecturally, this is the “telemetry/inspection” boundary of the product: it reads from the same store as the scene, but presents operational data rather than spatial visualization.
10. Documentation as part of the architecture
- docs/PRD.md and docs/ARCHITECTURE.md are first-class artifacts that define the product intent and technical direction.
- _bmad-output/planning-artifacts/ contains generated planning outputs such as epics and an implementation readiness report.
- These files are important because they indicate the repo is using a documentation-driven development lifecycle, not just ad hoc implementation.
11. BMAD framework layer
- _bmad/ contains the BMAD method itself: analysis, planning, solutioning, and implementation workflows.
- It includes reusable agents, skills, templates, and workflows for PRD creation, architecture generation, epics/stories, validation, and sprint planning.
- For an architecture diagram, this layer should be drawn outside the product runtime as the process engine that produces the project’s specs and execution artifacts.
12. CI and self-correction loop
- .agent/workflows/ci-check.md and .github/workflows/ci.yml define automated validation.
- The README frames this as a harness engineering loop: code changes are checked by CI, and the workflow supports self-correction for AI-driven development.
- This is an important operational boundary: quality enforcement happens through pipeline/workflow tooling rather than a server-side runtime.
13. Likely deployment shape
- There is no backend service tree visible here; the repo reads like a static front-end application with local state and canvas rendering.
- Any “real-time sync” reference in the docs should be treated as an architectural target or design assumption unless backed by a separate service not shown in this repository.
- So the safest diagram is: browser app on top of Vite-built assets, with optional future integration points rather than an implemented server tier.
14. What to emphasize in a diagram
- Draw three main boxes: Runtime UI, State/behavior layer, and Process/tooling layer.
- Inside runtime UI, show the office scene, agent sprites, furniture, and monitor panel all reading from the same central agent store.
- Outside runtime, show BMAD docs/workflows and CI as the systems that shape and validate the app’s evolution.
Main entry points: OfficeMap.tsx Office map · App.tsx App shell · useAgentStore.ts Agent store · AgentSprite.tsx Agent sprites
Components 19
Runtime UI
Browser app that renders the pixel-art office and monitor.
- App entry · Mounts the React application in the browser.
src/main.tsx - App shell · Top-level screen composition for the office simulation and monitor.
src/App.tsx - Office map · Renders the virtual office layout and spatial arrangement.
src/features/office/OfficeMap.tsx - Furniture layer · Pixel-art furniture and environment objects used by the office scene.
src/features/office/PixelFurniture.tsx - Agent sprites · Draws agent avatars and animated visual states.
src/features/agents/AgentSprite.tsx - Monitor panel · Operational view that summarizes all agents' live status and telemetry.
src/components/MonitorPanel.tsx - Static assets · Public images and sprite/furniture art used by the UI.
public/assets - App styles · Global and app-level styling for the React UI.
src/App.css
State & Behavior
Shared agent model, store, and motion logic.
- Agent store · Central shared state boundary for agent data and live updates.
src/store/useAgentStore.ts - Agent model · Defines the agent data shape consumed by rendering and monitoring.
src/types/agent.ts - Movement logic · Encapsulates goal-oriented movement and state transitions.
src/hooks/useAgentMovement.ts - Image loader · Loads and preprocesses images for runtime rendering.
src/hooks/useImageLoader.ts - Office areas · Shared area definitions used to reason about office positioning.
src/utils/officeAreas.ts
Process & Tooling
Documentation, BMAD workflows, and CI validation around the product.
- Product docs · PRD and architecture documentation defining intent and direction.
docs/ARCHITECTURE.md - BMAD core · Reusable BMAD methods, skills, and core workflow primitives.
_bmad/core - Planning workflows · BMAD planning and validation workflows for PRDs, UX, and architecture.
_bmad/bmm/2-plan-workflows - Impl workflows · BMAD execution workflows for stories, QA, sprint planning, and reviews.
_bmad/bmm/4-implementation - Planning output · Generated epics and readiness reports produced by the BMAD lifecycle.
_bmad-output/planning-artifacts/epics.md - CI checks · Automated validation loop for repository quality and consistency.
.github/workflows/ci.yml
Connections 23
- App entry → App shell: boots · Entry point mounts the application shell.
- App shell → Office map: composes · App assembles the office scene.
- App shell → Monitor panel: composes · App includes the operational monitor panel.
- Office map → Furniture layer: uses · Scene includes furniture/environment props.
- Office map → Agent sprites: renders · Scene displays agents in spatial context.
- Office map → Agent store: reads · Scene consumes shared agent state.
- Monitor panel → Agent store: reads · Panel consumes the same live store.
- Agent store → Agent model: shapes · Store state follows the agent domain model.
- Movement logic → Agent store: updates · Behavior logic drives state changes and motion.
- Movement logic → Agent model: interprets · Movement logic operates on agent fields and status.
- Agent sprites → Movement logic: animates · Avatar rendering reflects motion and state transitions.
- Image loader → Static assets: loads · Custom loader prepares image assets for rendering.
- Furniture layer → Image loader: uses · Scene props depend on processed assets.
- Agent sprites → Image loader: uses · Sprite rendering depends on loaded images.
- Office map → Office areas: lays out · Office scene uses area definitions for positioning.
- App shell → App styles: styles with · Top-level UI uses app styling.
- Product docs → Planning workflows: guides · Architecture and PRD docs are produced through planning workflows.
- BMAD core → Planning workflows: powers · Core methods support planning and validation workflows.
- BMAD core → Impl workflows: powers · Core methods support implementation workflows.
- Planning workflows → Planning output: produces · Planning workflows generate epics and readiness outputs.
- Impl workflows → Planning output: feeds · Implementation workflows and reviews inform generated artifacts.
- CI checks → Impl workflows: checks · CI enforces the development and review loop.
- CI checks → Product docs: validates · Automated checks help keep docs and implementation aligned.