# ldk-hub/bmad-2d-monitor architecture

> Architecture diagram of the GitHub repository ldk-hub/bmad-2d-monitor, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ldk-hub/bmad-2d-monitor
- Repository: https://github.com/ldk-hub/bmad-2d-monitor

## Overview

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: [`src/features/office/OfficeMap.tsx`](https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/features/office/OfficeMap.tsx) (Office map), [`src/App.tsx`](https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/App.tsx) (App shell), [`src/store/useAgentStore.ts`](https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/store/useAgentStore.ts) (Agent store), [`src/features/agents/AgentSprite.tsx`](https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/features/agents/AgentSprite.tsx) (Agent sprites)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_runtime["Runtime UI"]
  node_main(("App entry<br/>vite bootstrap<br/>[main.tsx]"))
  node_app["App shell<br/>react composition<br/>[App.tsx]"]
  node_officemap["Office map<br/>scene renderer<br/>[OfficeMap.tsx]"]
  node_furniture["Furniture layer<br/>scene props<br/>[PixelFurniture.tsx]"]
  node_agentsprite["Agent sprites<br/>avatar renderer<br/>[AgentSprite.tsx]"]
  node_monitor["Monitor panel<br/>observability UI<br/>[MonitorPanel.tsx]"]
  node_assets["Static assets<br/>image assets"]
  node_styles["App styles<br/>css styling<br/>[App.css]"]
end

subgraph group_state["State & Behavior"]
  node_store[("Agent store<br/>zustand state<br/>[useAgentStore.ts]")]
  node_agenttype["Agent model<br/>domain types<br/>[agent.ts]"]
  node_movement["Movement logic<br/>behavior hook"]
  node_imageloader["Image loader<br/>asset pipeline<br/>[useImageLoader.ts]"]
  node_officeareas["Office areas<br/>layout utils<br/>[officeAreas.ts]"]
end

subgraph group_process["Process & Tooling"]
  node_docs["Product docs<br/>specification<br/>[ARCHITECTURE.md]"]
  node_bmadcore["BMAD core<br/>method framework"]
  node_bmadplan["Planning workflows<br/>workflow set"]
  node_bmadimpl["Impl workflows<br/>workflow set"]
  node_bmadout["Planning output<br/>generated artifacts<br/>[epics.md]"]
  node_ci["CI checks<br/>validation pipeline<br/>[ci.yml]"]
end

node_main -->|"boots"| node_app
node_app -->|"composes"| node_officemap
node_app -->|"composes"| node_monitor
node_officemap -->|"uses"| node_furniture
node_officemap -->|"renders"| node_agentsprite
node_officemap -->|"reads"| node_store
node_monitor -->|"reads"| node_store
node_store -->|"shapes"| node_agenttype
node_movement -->|"updates"| node_store
node_movement -->|"interprets"| node_agenttype
node_agentsprite -->|"animates"| node_movement
node_imageloader -->|"loads"| node_assets
node_furniture -->|"uses"| node_imageloader
node_agentsprite -->|"uses"| node_imageloader
node_officemap -->|"lays out"| node_officeareas
node_app -->|"styles with"| node_styles
node_docs -->|"guides"| node_bmadplan
node_bmadcore -->|"powers"| node_bmadplan
node_bmadcore -->|"powers"| node_bmadimpl
node_bmadplan -->|"produces"| node_bmadout
node_bmadimpl -->|"feeds"| node_bmadout
node_ci -->|"checks"| node_bmadimpl
node_ci -->|"validates"| node_docs

click node_main "https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/main.tsx"
click node_app "https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/App.tsx"
click node_officemap "https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/features/office/OfficeMap.tsx"
click node_furniture "https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/features/office/PixelFurniture.tsx"
click node_agentsprite "https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/features/agents/AgentSprite.tsx"
click node_monitor "https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/components/MonitorPanel.tsx"
click node_store "https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/store/useAgentStore.ts"
click node_agenttype "https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/types/agent.ts"
click node_movement "https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/hooks/useAgentMovement.ts"
click node_imageloader "https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/hooks/useImageLoader.ts"
click node_officeareas "https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/utils/officeAreas.ts"
click node_assets "https://github.com/ldk-hub/bmad-2d-monitor/tree/main/public/assets"
click node_styles "https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/App.css"
click node_docs "https://github.com/ldk-hub/bmad-2d-monitor/blob/main/docs/ARCHITECTURE.md"
click node_bmadcore "https://github.com/ldk-hub/bmad-2d-monitor/tree/main/_bmad/core"
click node_bmadplan "https://github.com/ldk-hub/bmad-2d-monitor/tree/main/_bmad/bmm/2-plan-workflows"
click node_bmadimpl "https://github.com/ldk-hub/bmad-2d-monitor/tree/main/_bmad/bmm/4-implementation"
click node_bmadout "https://github.com/ldk-hub/bmad-2d-monitor/blob/main/_bmad-output/planning-artifacts/epics.md"
click node_ci "https://github.com/ldk-hub/bmad-2d-monitor/blob/main/.github/workflows/ci.yml"

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_main,node_app,node_officemap,node_furniture,node_agentsprite,node_monitor,node_assets,node_styles toneBlue
class node_store,node_agenttype,node_movement,node_imageloader,node_officeareas toneAmber
class node_docs,node_bmadcore,node_bmadplan,node_bmadimpl,node_bmadout,node_ci toneMint
```

## Components

### Runtime UI

Browser app that renders the pixel-art office and monitor.

- [App entry](https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/main.tsx): vite bootstrap · Mounts the React application in the browser. · `src/main.tsx`
- [App shell](https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/App.tsx): react composition · Top-level screen composition for the office simulation and monitor. · `src/App.tsx`
- [Office map](https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/features/office/OfficeMap.tsx): scene renderer · Renders the virtual office layout and spatial arrangement. · `src/features/office/OfficeMap.tsx`
- [Furniture layer](https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/features/office/PixelFurniture.tsx): scene props · Pixel-art furniture and environment objects used by the office scene. · `src/features/office/PixelFurniture.tsx`
- [Agent sprites](https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/features/agents/AgentSprite.tsx): avatar renderer · Draws agent avatars and animated visual states. · `src/features/agents/AgentSprite.tsx`
- [Monitor panel](https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/components/MonitorPanel.tsx): observability UI · Operational view that summarizes all agents' live status and telemetry. · `src/components/MonitorPanel.tsx`
- [Static assets](https://github.com/ldk-hub/bmad-2d-monitor/tree/main/public/assets): image assets · Public images and sprite/furniture art used by the UI. · `public/assets`
- [App styles](https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/App.css): css styling · Global and app-level styling for the React UI. · `src/App.css`

### State & Behavior

Shared agent model, store, and motion logic.

- [Agent store](https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/store/useAgentStore.ts): zustand state · Central shared state boundary for agent data and live updates. · `src/store/useAgentStore.ts`
- [Agent model](https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/types/agent.ts): domain types · Defines the agent data shape consumed by rendering and monitoring. · `src/types/agent.ts`
- [Movement logic](https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/hooks/useAgentMovement.ts): behavior hook · Encapsulates goal-oriented movement and state transitions. · `src/hooks/useAgentMovement.ts`
- [Image loader](https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/hooks/useImageLoader.ts): asset pipeline · Loads and preprocesses images for runtime rendering. · `src/hooks/useImageLoader.ts`
- [Office areas](https://github.com/ldk-hub/bmad-2d-monitor/blob/main/src/utils/officeAreas.ts): layout utils · 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](https://github.com/ldk-hub/bmad-2d-monitor/blob/main/docs/ARCHITECTURE.md): specification · PRD and architecture documentation defining intent and direction. · `docs/ARCHITECTURE.md`
- [BMAD core](https://github.com/ldk-hub/bmad-2d-monitor/tree/main/_bmad/core): method framework · Reusable BMAD methods, skills, and core workflow primitives. · `_bmad/core`
- [Planning workflows](https://github.com/ldk-hub/bmad-2d-monitor/tree/main/_bmad/bmm/2-plan-workflows): workflow set · BMAD planning and validation workflows for PRDs, UX, and architecture. · `_bmad/bmm/2-plan-workflows`
- [Impl workflows](https://github.com/ldk-hub/bmad-2d-monitor/tree/main/_bmad/bmm/4-implementation): workflow set · BMAD execution workflows for stories, QA, sprint planning, and reviews. · `_bmad/bmm/4-implementation`
- [Planning output](https://github.com/ldk-hub/bmad-2d-monitor/blob/main/_bmad-output/planning-artifacts/epics.md): generated artifacts · Generated epics and readiness reports produced by the BMAD lifecycle. · `_bmad-output/planning-artifacts/epics.md`
- [CI checks](https://github.com/ldk-hub/bmad-2d-monitor/blob/main/.github/workflows/ci.yml): validation pipeline · Automated validation loop for repository quality and consistency. · `.github/workflows/ci.yml`

## Connections

- 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.
