# dheepakshakthi/autocad-validation-agent architecture

> Architecture diagram of the GitHub repository dheepakshakthi/autocad-validation-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-04-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/dheepakshakthi/autocad-validation-agent
- Repository: https://github.com/dheepakshakthi/autocad-validation-agent

## Overview

1. **Repository shape**
   - This repo is split into two runtime systems: a **C# AutoCAD add-in** and a **Python backend service**.
   - The rest of the repo is mostly feature/spec documents that describe planned capabilities and product direction.

2. **AutoCAD plugin boundary**
   - `KeepAttributesHorizontal` is the AutoCAD-facing component, built as a **.NET 8 / C# add-in** that depends on the AutoCAD managed APIs (`AcCoreMgd`, `AcDbMgd`, `AcMgd`).
   - It is loaded into AutoCAD via `NETLOAD` and exposes command entry points through `myCommands.cs` and `myCommands.Designer.cs`.

3. **UI layer inside AutoCAD**
   - The plugin uses **WPF dockable controls** for the CAD workspace:
     - `CadyWorkspaceControl` is the unified surface.
     - `AiAssistantControl` is the chat/assistant view.
     - `GuardrailPanelControl` is the compliance/status view.
   - The README indicates these were consolidated into a single “unified workspace” palette, with the older commands now acting as aliases.

4. **Event and validation capture**
   - `Validation/GeometryListener.cs` is the key bridge from the drawing model to the compliance system.
   - Its role is to observe geometry/model changes in AutoCAD and trigger validation automatically, rather than requiring a manual validate command.

5. **Plugin-to-backend communication**
   - `Validation/ValidationApiClient.cs` is the outbound integration point from the add-in to the Python service.
   - This is the main data boundary: the plugin packages CAD context or geometry state, sends it to the backend, and consumes validation results, recommendations, or assistant responses.

6. **Backend service**
   - The `backend/` folder is a separate **Python API service** launched with `uvicorn`.
   - `main.py` is the service entry point, `models.py` defines request/response schemas, and `rule_engine.py` contains the domain validation logic.
   - The README describes a local `/health` endpoint and indicates the service reports whether Groq is enabled.

7. **AI integration path**
   - The backend is the AI/LLM gateway and likely owns the **Groq REST API** integration using the `qwen/qwen3-32b` model.
   - In practice, this means the plugin UI does not talk directly to the model; it talks to the backend, which can combine rule-based validation with AI-generated guidance.

8. **Validation vs. assistant concerns**
   - The architecture separates **deterministic compliance checks** from **assistant/chat interactions**:
     - rule engine and validation APIs for guardrails and issues,
     - Groq-backed chat for explanations, SOP lookup, and recommendations.
   - This separation is important for diagramming because the AI layer is not the only source of truth.

9. **Legacy command retained as a separate capability**
   - `KeepStraight` / “Keep Attributes Horizontal” is a standalone legacy feature in the same add-in.
   - It adds an AutoCAD overrule so block attributes remain horizontally readable regardless of block rotation, and it is functionally independent from the validation-agent workflow.

10. **Operational flow**
   - Typical runtime flow is: AutoCAD command or geometry change → C# listener/UI update → backend request → rule/AI evaluation → response returned to the docked workspace and any in-canvas or panel feedback.
   - The README emphasizes automatic refresh of guardrail status, issue details, recommendations, reports, and approvals through typed tool calls.

11. **Build and deployment boundary**
   - The plugin is built in Visual Studio 2022 and staged into a separate `artifacts/netload` output so AutoCAD can load a stable DLL copy without locking the compiler output folder.
   - The backend is run independently on `127.0.0.1:8000`, so the system is a two-process architecture linked over HTTP.

12. **Planning docs**
   - The `features/` markdown files are not runtime components, but they document the intended architecture expansion: in-canvas highlighting, report generation, risk prediction, collaboration, and conversion workflows.
   - They are useful for understanding future subsystem boundaries, but the executable architecture today is primarily the AutoCAD add-in plus local Python validation/AI service.

Main entry points: [`backend/main.py`](https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/backend/main.py) (Service API), [`KeepAttributesHorizontal/UI/CadyWorkspaceControl.xaml`](https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/KeepAttributesHorizontal/UI/CadyWorkspaceControl.xaml) (Workspace), [`KeepAttributesHorizontal/myCommands.cs`](https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/KeepAttributesHorizontal/myCommands.cs) (Commands), [`KeepAttributesHorizontal/UI/AiAssistantControl.xaml`](https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/KeepAttributesHorizontal/UI/AiAssistantControl.xaml) (AI assistant)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_group_autocad["AutoCAD add-in"]
  node_node_addin["Add-in host<br/>.NET 8 plugin<br/>[PluginExtension.cs]"]
  node_node_commands["Commands<br/>[myCommands.cs]"]
  node_node_workspace["Workspace<br/>WPF palette"]
  node_node_assistant["AI assistant<br/>WPF chat view"]
  node_node_guardrail["Guardrail panel<br/>WPF status view"]
  node_node_listener(("Geometry listener<br/>model watcher"))
  node_node_client["API client<br/>HTTP boundary"]
  node_node_legacy{{"Keep Straight<br/>attribute overrule"}}
end

subgraph group_group_backend["Python backend"]
  node_node_backend_main["Service API<br/>FastAPI entry<br/>[main.py]"]
  node_node_models["Schemas<br/>request/response models<br/>[models.py]"]
  node_node_rules{{"Rule engine<br/>validation logic<br/>[rule_engine.py]"}}
  node_node_llm["Groq bridge<br/>LLM gateway"]
end

subgraph group_group_docs["Planning docs"]
  node_node_feature1["Guardrail panel spec<br/>feature spec"]
  node_node_feature2["Highlighting spec<br/>feature spec"]
  node_node_feature3["Assistant spec<br/>feature spec"]
  node_node_feature5["Reports spec<br/>feature spec"]
end

node_node_addin -->|"exposes"| node_node_commands
node_node_commands -->|"opens"| node_node_workspace
node_node_workspace -->|"hosts"| node_node_assistant
node_node_workspace -->|"hosts"| node_node_guardrail
node_node_listener -->|"triggers"| node_node_client
node_node_commands -->|"includes"| node_node_legacy
node_node_client -->|"calls"| node_node_backend_main
node_node_backend_main -->|"uses"| node_node_models
node_node_backend_main -->|"runs"| node_node_rules
node_node_backend_main -->|"delegates"| node_node_llm
node_node_rules -->|"augments"| node_node_llm
node_node_guardrail -.->|"informs"| node_node_feature1
node_node_assistant -.->|"informs"| node_node_feature3
node_node_workspace -.->|"extends to"| node_node_feature2
node_node_backend_main -.->|"extends to"| node_node_feature5

click node_node_addin "https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/KeepAttributesHorizontal/PluginExtension.cs"
click node_node_commands "https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/KeepAttributesHorizontal/myCommands.cs"
click node_node_workspace "https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/KeepAttributesHorizontal/UI/CadyWorkspaceControl.xaml"
click node_node_assistant "https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/KeepAttributesHorizontal/UI/AiAssistantControl.xaml"
click node_node_guardrail "https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/KeepAttributesHorizontal/UI/GuardrailPanelControl.xaml"
click node_node_listener "https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/KeepAttributesHorizontal/Validation/GeometryListener.cs"
click node_node_client "https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/KeepAttributesHorizontal/Validation/ValidationApiClient.cs"
click node_node_backend_main "https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/backend/main.py"
click node_node_models "https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/backend/models.py"
click node_node_rules "https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/backend/rule_engine.py"
click node_node_feature1 "https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/features/feature-01-live-compliance-guardrail-panel.md"
click node_node_feature2 "https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/features/feature-02-in-canvas-issue-highlighting.md"
click node_node_feature3 "https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/features/feature-03-ai-fix-recommendation-assistant.md"
click node_node_feature5 "https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/features/feature-05-automated-validation-report-generator.md"

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_node_addin,node_node_commands,node_node_workspace,node_node_assistant,node_node_guardrail,node_node_listener,node_node_client,node_node_legacy toneBlue
class node_node_backend_main,node_node_models,node_node_rules,node_node_llm toneAmber
class node_node_feature1,node_node_feature2,node_node_feature3,node_node_feature5 toneMint
```

## Components

### AutoCAD add-in

C# .NET 8 plugin loaded into AutoCAD via NETLOAD and exposed through commands and WPF palettes.

- [Add-in host](https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/KeepAttributesHorizontal/PluginExtension.cs): .NET 8 plugin · AutoCAD-facing entry point and plugin boundary for loading the C# extension. · `KeepAttributesHorizontal/PluginExtension.cs`
- [Commands](https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/KeepAttributesHorizontal/myCommands.cs): AutoCAD commands · Command entry points exposed to AutoCAD, including the legacy keep-straight feature and workspace launch actions. · `KeepAttributesHorizontal/myCommands.cs`
- [Workspace](https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/KeepAttributesHorizontal/UI/CadyWorkspaceControl.xaml): WPF palette · Unified dockable surface that hosts the assistant and guardrail views inside AutoCAD. · `KeepAttributesHorizontal/UI/CadyWorkspaceControl.xaml`
- [AI assistant](https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/KeepAttributesHorizontal/UI/AiAssistantControl.xaml): WPF chat view · Chat and recommendation surface for guided compliance and explanations. · `KeepAttributesHorizontal/UI/AiAssistantControl.xaml`
- [Guardrail panel](https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/KeepAttributesHorizontal/UI/GuardrailPanelControl.xaml): WPF status view · Compliance and validation summary panel shown in the AutoCAD workspace. · `KeepAttributesHorizontal/UI/GuardrailPanelControl.xaml`
- [Geometry listener](https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/KeepAttributesHorizontal/Validation/GeometryListener.cs): model watcher · Observes drawing and geometry changes and triggers validation automatically. · `KeepAttributesHorizontal/Validation/GeometryListener.cs`
- [API client](https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/KeepAttributesHorizontal/Validation/ValidationApiClient.cs): HTTP boundary · Packages CAD context and sends requests to the backend service, then applies returned validation or assistant results. · `KeepAttributesHorizontal/Validation/ValidationApiClient.cs`
- **Keep Straight**: attribute overrule · Standalone legacy capability that keeps block attributes horizontally readable regardless of block rotation.

### Python backend

Local HTTP service that performs rule validation and AI-assisted responses.

- [Service API](https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/backend/main.py): FastAPI entry · Python service entry point launched with uvicorn and exposed on localhost. · `backend/main.py`
- [Schemas](https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/backend/models.py): request/response models · Defines the API payloads exchanged between the add-in and the backend. · `backend/models.py`
- [Rule engine](https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/backend/rule_engine.py): validation logic · Deterministic compliance checks and domain rules for guardrail evaluation. · `backend/rule_engine.py`
- **Groq bridge**: LLM gateway · Backend-side AI integration path for model-backed explanations and recommendations.

### Planning docs

Feature/spec documents that describe intended future capabilities and product direction.

- [Guardrail panel spec](https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/features/feature-01-live-compliance-guardrail-panel.md): feature spec · Describes the live compliance panel and status workflow. · `features/feature-01-live-compliance-guardrail-panel.md`
- [Highlighting spec](https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/features/feature-02-in-canvas-issue-highlighting.md): feature spec · Describes in-canvas issue highlighting and feedback presentation. · `features/feature-02-in-canvas-issue-highlighting.md`
- [Assistant spec](https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/features/feature-03-ai-fix-recommendation-assistant.md): feature spec · Describes AI fix recommendations and assistant behavior. · `features/feature-03-ai-fix-recommendation-assistant.md`
- [Reports spec](https://github.com/dheepakshakthi/autocad-validation-agent/blob/main/features/feature-05-automated-validation-report-generator.md): feature spec · Describes automated validation report generation. · `features/feature-05-automated-validation-report-generator.md`

## Connections

- Add-in host → Commands: exposes · The plugin registers command entry points for AutoCAD.
- Commands → Workspace: opens · Commands surface the unified workspace palette.
- Workspace → AI assistant: hosts · The workspace contains the assistant chat surface.
- Workspace → Guardrail panel: hosts · The workspace contains the guardrail/compliance surface.
- Geometry listener → API client: triggers · Geometry changes initiate validation and backend calls.
- Commands → Keep Straight: includes · The legacy horizontal attribute behavior remains available as a separate capability.
- API client → Service API: calls · The add-in communicates with the local Python service over HTTP.
- Service API → Schemas: uses · The service validates and shapes API payloads with shared schemas.
- Service API → Rule engine: runs · The service invokes deterministic validation logic for guardrails.
- Service API → Groq bridge: delegates · AI-assisted guidance is routed through the backend integration layer.
- Rule engine → Groq bridge: augments · Rule-based evaluation and AI responses complement each other.
- Guardrail panel → Guardrail panel spec: informs · The implementation aligns with the planned live guardrail workflow.
- AI assistant → Assistant spec: informs · The assistant UI maps to the documented recommendation workflow.
- Workspace → Highlighting spec: extends to · Future in-canvas highlighting expands the current workspace feedback loop.
- Service API → Reports spec: extends to · Report generation is part of the planned backend capability set.
