How dheepakshakthi/autocad-validation-agent works
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: main.py Service API · CadyWorkspaceControl.xaml Workspace · myCommands.cs Commands · AiAssistantControl.xaml AI assistant
Components 16
AutoCAD add-in
C# .NET 8 plugin loaded into AutoCAD via NETLOAD and exposed through commands and WPF palettes.
- Add-in host · AutoCAD-facing entry point and plugin boundary for loading the C# extension.
KeepAttributesHorizontal/PluginExtension.cs - Commands · Command entry points exposed to AutoCAD, including the legacy keep-straight feature and workspace launch actions.
KeepAttributesHorizontal/myCommands.cs - Workspace · Unified dockable surface that hosts the assistant and guardrail views inside AutoCAD.
KeepAttributesHorizontal/UI/CadyWorkspaceControl.xaml - AI assistant · Chat and recommendation surface for guided compliance and explanations.
KeepAttributesHorizontal/UI/AiAssistantControl.xaml - Guardrail panel · Compliance and validation summary panel shown in the AutoCAD workspace.
KeepAttributesHorizontal/UI/GuardrailPanelControl.xaml - Geometry listener · Observes drawing and geometry changes and triggers validation automatically.
KeepAttributesHorizontal/Validation/GeometryListener.cs - API client · Packages CAD context and sends requests to the backend service, then applies returned validation or assistant results.
KeepAttributesHorizontal/Validation/ValidationApiClient.cs - Keep Straight · 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 · Python service entry point launched with uvicorn and exposed on localhost.
backend/main.py - Schemas · Defines the API payloads exchanged between the add-in and the backend.
backend/models.py - Rule engine · Deterministic compliance checks and domain rules for guardrail evaluation.
backend/rule_engine.py - Groq bridge · 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 · Describes the live compliance panel and status workflow.
features/feature-01-live-compliance-guardrail-panel.md - Highlighting spec · Describes in-canvas issue highlighting and feedback presentation.
features/feature-02-in-canvas-issue-highlighting.md - Assistant spec · Describes AI fix recommendations and assistant behavior.
features/feature-03-ai-fix-recommendation-assistant.md - Reports spec · Describes automated validation report generation.
features/feature-05-automated-validation-report-generator.md
Connections 15
- 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.