# CodeGuardian for Revit

CodeGuardian is a compliance platform for the AEC industry. Our Revit plugin scans building designs in real time to detect code violations. We are expanding to a municipal version that helps cities review submitted plans faster.

## Live Product

- Website: `https://codeguardianapp.com`
- Revit Windows installer: `https://codeguardianapp.com/download/installer`
- Cloud review preview: `https://codeguardianapp.com/aps`

## Deploy Website

If the Cloudflare dashboard code editor keeps spinning, deploy with Wrangler instead:

```powershell
powershell -ExecutionPolicy Bypass -File .\deploy\cloudflare-worker\deploy-with-wrangler.ps1
```

See `docs/cloudflare-worker-deploy.md` for the full setup steps.

## Windows Trust

Production releases should be Authenticode-signed before public distribution. See `docs/windows-installer-trust.md` for Microsoft Defender false-positive submission steps and the code-signing environment variables supported by the release script.

## Why This Exists

Building projects often lose time because code issues are discovered late, after drawings are already coordinated or submitted for review. CodeGuardian moves advisory compliance checks into the design workflow so architects, BIM managers, and future municipal reviewers can see risks earlier.

## What It Does

- Adds a focused `CodeGuardian` ribbon tab to Revit 2024+.
- Scans design elements for advisory compliance warnings.
- Groups warnings by low, medium, and high priority.
- Splits warnings into legal requirements, drawings/model checks, and construction/inspection checks.
- Uses yellow, orange, and red severity colors.
- Lets users choose building typology and thresholds in Options.
- Lets users set project state, local AHJ, adopted code edition, amendments, occupancy, construction type, fire protection, occupant-load basis, accessibility scope, professional review status, and selected permit/code requirements.
- Tracks 12 permit review gates: zoning/land use, building code, fire/life safety, structural, MEP, accessibility, environmental/sustainability, civil/site, historic preservation, construction documents, fees/approvals, and construction inspections.
- Can import missing permit/code settings from Revit Project Information, title block parameters, and likely cover/code sheets.
- Auto-generates project-specific Options from the active Revit project and leaves unread fields blank for manual entry, preventing settings from older projects from carrying into a new file.
- Checks door, window, and room tags for missing, duplicate, orphaned, wrong-category, and text/data mismatch conditions.
- Lets users click a warning to select and zoom to the Revit element.
- Locates issues in the active view when possible, then falls back to matching plan, section, elevation, detail, or 3D views.
- Includes a public download website, user-level web installer, and packaged free Revit add-in download.

## Build

Revit 2025 or newer must be installed under `C:\Program Files\Autodesk\` for local 2025+ API builds. The Revit 2024 package targets `.NET Framework 4.8` and can be built with the 2024 API reference package used by the publishing script.

```powershell
dotnet build .\CodeComplianceGuard.slnx
```

## Install For Local Revit 2024+

Install into every Revit version 2024 or newer found on this machine:

```powershell
.\installer\install.ps1
```

Install into specific versions:

```powershell
.\installer\install.ps1 -RevitVersion 2024,2025,2026
```

Restart Revit after installing. The add-in loads from:

`%APPDATA%\Autodesk\Revit\Addins\<version>\CodeGuard.Revit.addin`

Compatibility note: Revit 2024 uses `.NET Framework 4.8`; Revit 2025 and 2026 use `.NET 8`; Revit 2027 and newer use `.NET 10`. The installer chooses the target framework automatically for each Revit version it installs.

## Install From Public Website

Download the free Windows installer from:

`https://codeguardianapp.com/download/installer`

Double-click `CodeGuardianSetup.exe`. It detects installed Revit 2024, 2025, and 2026 versions, lets the user choose which Revit versions should receive CodeGuardian, downloads the right package for each selected version, installs into the user-level Revit add-ins folder, and asks the user to restart Revit.

The public package endpoints are `https://codeguardianapp.com/download/package/2024`, `https://codeguardianapp.com/download/package/2025`, and `https://codeguardianapp.com/download/package/2026`.

## Important Limitation

This prototype performs advisory checks only. Real US building code compliance depends on the adopted code edition, jurisdiction amendments, occupancy, construction type, fire protection, occupant load, accessibility scope, and professional judgment.

## Repository Structure

- `src/CodeGuard.Core` - shared compliance models, rule thresholds, issue grouping, subscriptions, rule-pack concepts, and permit review metadata.
- `src/CodeGuard.Revit` - Autodesk Revit add-in, ribbon commands, dashboard UI, options UI, Revit model import, scanner, and locate behavior.
- `website` - public website, admin login, Stripe link routing, APS OAuth/model-review preview, and download routes.
- `installer` - local and public PowerShell installers for user-level Revit add-in installation.
- `deploy` - Cloudflare Worker/Pages publishing scripts.
- `docs` - commercialization, deployment, rule-authoring, Autodesk distribution, Stripe, and drawing-import notes.
- `tests` - core unit tests.

## Recommended Drawing Import Format

Use the template in `docs/drawing-import-format.md` on cover/code sheets or Project Information parameters so CodeGuardian reads labeled values instead of guessing from general notes.
