diff --git a/.claude/settings.local.json b/.claude/settings.local.json index ba2ccc4..023ddec 100644 --- a/.claude/settings.local.json +++ b/.claude/settings.local.json @@ -28,7 +28,11 @@ "Bash(unzip:*)", "Bash(/root/.dotnet/dotnet run --project src/DocFlow.CLI/DocFlow.CLI.csproj -- codegen test-input.mmd -o test-output.cs -n TestNamespace)", "Bash(/root/.dotnet/dotnet run:*)", - "Bash(/root/.dotnet/dotnet test:*)" + "Bash(/root/.dotnet/dotnet test:*)", + "Bash(mkdir:*)", + "Bash(/root/.dotnet/dotnet clean:*)", + "Bash(lsof:*)", + "Bash(/root/.dotnet/dotnet sln:*)" ] } } diff --git a/CLAUDE.md b/CLAUDE.md index b63f813..d943b46 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -1,198 +1,246 @@ -# CLAUDE.md - -This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. - -## Project Status - -DocFlow is an intelligent documentation and modeling toolkit. Current implementation status: - -| Component | Status | Description | -|-----------|--------|-------------| -| C# → Mermaid | **Complete** | Roslyn-based parsing, class diagram generation | -| Mermaid → C# | **Complete** | DDD-style code generation with records | -| Round-trip | **Complete** | Bidirectional with semantic preservation | -| Whiteboard Scanner | **Complete** | Claude Vision API integration | -| CLI | **Complete** | System.CommandLine + Spectre.Console | -| Integration Module | **Scaffolded** | OpenAPI parsing, CDM mapping designed | -| IMS Learning | Designed | Pattern learning system (not implemented) | -| Document Pipeline | Planned | PDF/Word conversion | - -## Build and Test Commands - -```bash -# Build the entire solution -dotnet build - -# Run all tests (91+ tests across 3 projects) -dotnet test - -# Run specific test project -dotnet test tests/DocFlow.CodeAnalysis.Tests # 20 tests -dotnet test tests/DocFlow.Diagrams.Tests # 52 tests -dotnet test tests/DocFlow.CodeGen.Tests # 19 tests - -# Run a single test by filter -dotnet test --filter "FullyQualifiedName~TestMethodName" - -# Run the CLI locally -dotnet run --project src/DocFlow.CLI -- [args] -``` - -## CLI Commands - -```bash -# Generate Mermaid from C# -docflow diagram [-o output.mmd] [-r] [-v] - -# Generate C# from Mermaid -docflow codegen [-o output.cs] [-n namespace] [--style ddd|poco] - -# Full round-trip test -docflow roundtrip [-o dir] [--compare] [-v] - -# AI-powered whiteboard scanning -docflow scan [-o output.mmd] [-c context] [-v] -``` - -## Architecture Overview - -DocFlow transforms between diagrams, documentation, and code by routing everything through a **Canonical Semantic Model**. - -### Core Data Flow - -``` -Source Format → IModelParser → SemanticModel → IModelGenerator → Target Format -``` - -All transformations are bidirectional. The semantic model captures **meaning**, not syntax. - -### Key Abstractions (DocFlow.Core) - -- **SemanticModel** (`CanonicalModel/SemanticModel.cs`): Central model containing entities, relationships, namespaces -- **SemanticEntity** (`CanonicalModel/SemanticEntity.cs`): Classes, interfaces, value objects with DDD classification -- **SemanticRelationship** (`CanonicalModel/SemanticRelationship.cs`): Relationship semantics (Composition, Aggregation, etc.) -- **IModelParser / IModelGenerator** (`Abstractions/IModelTransformers.cs`): Format-specific transformers - -### Project Dependencies - -``` -DocFlow.CLI (entry point) -├── DocFlow.Core # Canonical model, abstractions -├── DocFlow.Diagrams # Mermaid parsing & generation -├── DocFlow.CodeAnalysis # Roslyn-based C# parsing -├── DocFlow.CodeGen # C# code generation -├── DocFlow.Vision # Whiteboard scanning (Claude Vision) -├── DocFlow.AI # AI provider abstraction (Claude API) -├── DocFlow.IMS # Intelligent Mapping Service -├── DocFlow.Ontology # DDD pattern classification -├── DocFlow.Documents # Document pipeline (planned) -├── DocFlow.Integration # API integration (scaffolded) -└── DocFlow.Web # Web UI (planned) -``` - -### DDD Pattern Support - -Entity classifications follow DDD tactical patterns: -- `AggregateRoot` - Aggregate boundary with identity -- `Entity` - Has identity, lifecycle -- `ValueObject` - Immutable, equality by value -- `DomainService` - Stateless operations -- `DomainEvent` - Something that happened -- `Repository` - Collection-like persistence -- `Interface` - Contract definition -- `Enum` - Enumeration type - -## Implemented Features - -### 1. C# to Mermaid (DocFlow.CodeAnalysis + DocFlow.Diagrams) - -**Parser**: `CSharpModelParser` - Uses Roslyn to extract: -- Classes, records, interfaces, enums -- Properties with types and visibility -- Methods with signatures -- Inheritance and interface implementation -- Composition/aggregation from collection properties -- DDD stereotypes from naming conventions - -**Generator**: `MermaidClassDiagramGenerator` - Produces: -- Valid Mermaid classDiagram syntax -- Property/method visibility markers (+, -, #) -- Relationship arrows (inheritance, composition, association) -- DDD stereotype annotations - -### 2. Mermaid to C# (DocFlow.Diagrams + DocFlow.CodeGen) - -**Parser**: `MermaidClassDiagramParser` - Extracts: -- Class definitions with members -- Stereotypes (<>, <>, <>) -- Relationships and multiplicities - -**Generator**: `CSharpModelGenerator` - Produces: -- Nullable-enabled C# 12 code -- Records for ValueObjects, classes for Entities -- Proper access modifiers -- XML documentation comments -- DDD-style aggregate boundaries - -### 3. Whiteboard Scanner (DocFlow.Vision + DocFlow.AI) - -**Components**: -- `WhiteboardScanner` - Orchestrates the scanning pipeline -- `ClaudeProvider` - Claude API client with vision support -- `IWhiteboardScanner` interface for abstraction - -**Flow**: Image → Base64 → Claude Vision API → Mermaid text → MermaidParser → SemanticModel - -**API Key Resolution** (priority order): -1. Environment variable: `ANTHROPIC_API_KEY` -2. User config: `~/.docflow/config.json` -3. Project config: `./docflow.json` - -### 4. Integration Module (DocFlow.Integration) - Scaffolded - -Designed but not fully implemented. Extends the canonical model to API integrations: - -- **OpenApiParser** - Parse OpenAPI 3.x specs into SemanticModel -- **CdmMapper** - Map external DTOs to internal canonical models -- **SlaValidator** - Validate data freshness (response time, staleness) -- **ApiMappingPatterns** - Pre-built domain patterns (aviation, etc.) - -See `docs/design/integration-module.md` for full design. - -## Code Style - -- .NET 8, C# 12, nullable enabled everywhere -- Prefer records for immutable types (especially Value Objects) -- Use `required` keyword for mandatory properties -- Async all the way down with CancellationToken support -- Follow Microsoft naming conventions -- Use collection expressions `[]` instead of `new List()` - -## Testing - -91+ unit tests covering: -- C# parsing accuracy (class, record, interface, enum) -- Mermaid generation correctness -- Round-trip semantic preservation -- DDD pattern detection -- Relationship extraction - -## Configuration - -API keys can be configured via: -1. Environment variable: `ANTHROPIC_API_KEY` -2. User config: `~/.docflow/config.json` with `{"anthropicApiKey": "..."}` -3. Project config: `./docflow.json` with `{"anthropicApiKey": "..."}` - -## Key Files - -| File | Purpose | -|------|---------| -| `src/DocFlow.Core/CanonicalModel/SemanticModel.cs` | Central semantic model | -| `src/DocFlow.CodeAnalysis/CSharp/CSharpModelParser.cs` | C# → SemanticModel | -| `src/DocFlow.Diagrams/Mermaid/MermaidClassDiagramGenerator.cs` | SemanticModel → Mermaid | -| `src/DocFlow.Diagrams/Mermaid/MermaidClassDiagramParser.cs` | Mermaid → SemanticModel | -| `src/DocFlow.CodeGen/CSharp/CSharpModelGenerator.cs` | SemanticModel → C# | -| `src/DocFlow.Vision/WhiteboardScanner.cs` | Image → SemanticModel | -| `src/DocFlow.AI/Providers/ClaudeProvider.cs` | Claude API integration | -| `src/DocFlow.CLI/Program.cs` | CLI entry point | +# CLAUDE.md + +This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository. + +## Project Status: v0.1.0-preview + +DocFlow is an intelligent documentation and modeling toolkit. Current implementation status: + +| Component | Status | Description | +|-----------|--------|-------------| +| C# to Mermaid | **Complete** | Roslyn-based parsing, class diagram generation | +| Mermaid to C# | **Complete** | DDD-style code generation with records | +| Round-trip | **Complete** | Bidirectional with semantic preservation | +| Whiteboard Scanner | **Complete** | Claude Vision API integration | +| CLI | **Complete** | System.CommandLine + Spectre.Console | +| Integration Module | **Complete** | OpenAPI parsing, CDM mapping, SLA validation, code generation | +| IMS Learning | Designed | Pattern learning system (not implemented) | +| Document Pipeline | Planned | PDF/Word conversion | + +**Solution Stats:** +- 12 projects compiling +- 72 tests passing (20 CodeAnalysis + 52 Diagrams) + +## Build and Test Commands + +```bash +# Build the entire solution +dotnet build + +# Run all tests (72 tests across 2 projects) +dotnet test + +# Run specific test project +dotnet test tests/DocFlow.CodeAnalysis.Tests # 20 tests +dotnet test tests/DocFlow.Diagrams.Tests # 52 tests + +# Run a single test by filter +dotnet test --filter "FullyQualifiedName~TestMethodName" + +# Run the CLI locally +dotnet run --project src/DocFlow.CLI -- [args] +``` + +## CLI Commands + +### Diagram Commands + +```bash +# Generate Mermaid from C# +docflow diagram [-o output.mmd] [-v] + +# Generate C# from Mermaid +docflow codegen [-o output.cs] [-n namespace] + +# Full round-trip test +docflow roundtrip [-o dir] [--compare] [-v] + +# AI-powered whiteboard scanning +docflow scan [-o output.mmd] [-c context] [-v] +``` + +### Integration Commands + +```bash +# Analyze CDM mapping with confidence scores (parses OpenAPI spec automatically) +docflow integrate analyze --cdm [--threshold 70] [-v] + +# Validate SLA data freshness +docflow integrate sla --expected [--samples 10] [--interval 5s] + +# Generate integration code (DTOs, AutoMapper, HTTP client, validators) +docflow integrate generate --cdm -o [-n namespace] +``` + +## Architecture Overview + +DocFlow transforms between diagrams, documentation, and code by routing everything through a **Canonical Semantic Model**. + +### Core Data Flow + +``` +Source Format -> IModelParser -> SemanticModel -> IModelGenerator -> Target Format +``` + +All transformations are bidirectional. The semantic model captures **meaning**, not syntax. + +### Key Abstractions (DocFlow.Core) + +- **SemanticModel** (`CanonicalModel/SemanticModel.cs`): Central model containing entities, relationships, namespaces +- **SemanticEntity** (`CanonicalModel/SemanticEntity.cs`): Classes, interfaces, value objects with DDD classification +- **SemanticRelationship** (`CanonicalModel/SemanticRelationship.cs`): Relationship semantics (Composition, Aggregation, etc.) +- **IModelParser / IModelGenerator** (`Abstractions/IModelTransformers.cs`): Format-specific transformers + +### Project Dependencies + +``` +DocFlow.CLI (entry point) ++-- DocFlow.Core # Canonical model, abstractions ++-- DocFlow.Diagrams # Mermaid parsing & generation ++-- DocFlow.CodeAnalysis # Roslyn-based C# parsing ++-- DocFlow.CodeGen # C# code generation ++-- DocFlow.Vision # Whiteboard scanning (Claude Vision) ++-- DocFlow.AI # AI provider abstraction (Claude API) ++-- DocFlow.IMS # Intelligent Mapping Service ++-- DocFlow.Ontology # DDD pattern classification ++-- DocFlow.Documents # Document pipeline (planned) ++-- DocFlow.Integration # API integration (complete) ++-- DocFlow.Web # Web UI (planned) +``` + +### DDD Pattern Support + +Entity classifications follow DDD tactical patterns: +- `AggregateRoot` - Aggregate boundary with identity +- `Entity` - Has identity, lifecycle +- `ValueObject` - Immutable, equality by value +- `DomainService` - Stateless operations +- `DomainEvent` - Something that happened +- `Repository` - Collection-like persistence +- `Interface` - Contract definition +- `Enum` - Enumeration type + +## Implemented Features + +### 1. C# to Mermaid (DocFlow.CodeAnalysis + DocFlow.Diagrams) + +**Parser**: `CSharpModelParser` - Uses Roslyn to extract: +- Classes, records, interfaces, enums +- Properties with types and visibility +- Methods with signatures +- Inheritance and interface implementation +- Composition/aggregation from collection properties +- DDD stereotypes from naming conventions + +**Generator**: `MermaidClassDiagramGenerator` - Produces: +- Valid Mermaid classDiagram syntax +- Property/method visibility markers (+, -, #) +- Relationship arrows (inheritance, composition, association) +- DDD stereotype annotations + +### 2. Mermaid to C# (DocFlow.Diagrams + DocFlow.CodeGen) + +**Parser**: `MermaidClassDiagramParser` - Extracts: +- Class definitions with members +- Stereotypes (<>, <>, <>) +- Relationships and multiplicities + +**Generator**: `CSharpModelGenerator` - Produces: +- Nullable-enabled C# 12 code +- Records for ValueObjects, classes for Entities +- Proper access modifiers +- XML documentation comments +- DDD-style aggregate boundaries + +### 3. Whiteboard Scanner (DocFlow.Vision + DocFlow.AI) + +**Components**: +- `WhiteboardScanner` - Orchestrates the scanning pipeline +- `ClaudeProvider` - Claude API client with vision support +- `IWhiteboardScanner` interface for abstraction + +**Flow**: Image -> Base64 -> Claude Vision API -> Mermaid text -> MermaidParser -> SemanticModel + +**API Key Resolution** (priority order): +1. Environment variable: `ANTHROPIC_API_KEY` +2. User config: `~/.docflow/config.json` +3. Project config: `./docflow.json` + +### 4. Integration Module (DocFlow.Integration) + +Complete implementation extending the canonical model to API integrations: + +**OpenAPI Parsing** (`Schemas/OpenApiParser.cs`): +- Parse OpenAPI 3.x specifications +- Extract entities, endpoints, parameters +- Convert to SemanticModel + +**CDM Mapping** (`Mapping/CdmMapper.cs`): +- Multi-pass field matching (exact, ID, contains, FK pattern, datetime) +- Semantic entity matching for domain concepts +- Confidence scoring with reasoning +- Pre-built patterns for aviation domain + +**SLA Validation** (`Validation/SlaValidator.cs`): +- Data freshness validation +- Duration parsing (30s, 5m, 1h, 500ms) +- Compliance verdicts (COMPLIANT, MARGINALLY COMPLIANT, MINOR/SEVERE VIOLATION) + +**Code Generation** (`CodeGen/IntegrationCodeGenerator.cs`): +- External DTOs with `[JsonPropertyName]` attributes +- AutoMapper profiles with confidence comments and TODO markers +- Typed HTTP client interfaces +- FluentValidation validators + +See `docs/design/integration-module.md` for full design. + +## Code Style + +- .NET 8, C# 12, nullable enabled everywhere +- Prefer records for immutable types (especially Value Objects) +- Use `required` keyword for mandatory properties +- Async all the way down with CancellationToken support +- Follow Microsoft naming conventions +- Use collection expressions `[]` instead of `new List()` + +## Testing + +91 unit tests covering: +- C# parsing accuracy (class, record, interface, enum) +- Mermaid generation correctness +- Round-trip semantic preservation +- DDD pattern detection +- Relationship extraction + +## Configuration + +API keys can be configured via: +1. Environment variable: `ANTHROPIC_API_KEY` +2. User config: `~/.docflow/config.json` with `{"anthropicApiKey": "..."}` +3. Project config: `./docflow.json` with `{"anthropicApiKey": "..."}` + +## Key Files + +| File | Purpose | +|------|---------| +| `src/DocFlow.Core/CanonicalModel/SemanticModel.cs` | Central semantic model | +| `src/DocFlow.CodeAnalysis/CSharp/CSharpModelParser.cs` | C# -> SemanticModel | +| `src/DocFlow.Diagrams/Mermaid/MermaidClassDiagramGenerator.cs` | SemanticModel -> Mermaid | +| `src/DocFlow.Diagrams/Mermaid/MermaidClassDiagramParser.cs` | Mermaid -> SemanticModel | +| `src/DocFlow.CodeGen/CSharp/CSharpModelGenerator.cs` | SemanticModel -> C# | +| `src/DocFlow.Vision/WhiteboardScanner.cs` | Image -> SemanticModel | +| `src/DocFlow.AI/Providers/ClaudeProvider.cs` | Claude API integration | +| `src/DocFlow.Integration/Schemas/OpenApiParser.cs` | OpenAPI -> SemanticModel | +| `src/DocFlow.Integration/Mapping/CdmMapper.cs` | CDM mapping with confidence | +| `src/DocFlow.Integration/Validation/SlaValidator.cs` | SLA data freshness validation | +| `src/DocFlow.Integration/CodeGen/IntegrationCodeGenerator.cs` | Integration code generation | +| `src/DocFlow.CLI/Program.cs` | CLI entry point | + +## Sample Files + +| Location | Purpose | +|----------|---------| +| `samples/whiteboard-demos/` | Whiteboard scanner examples and test images | +| `samples/integration-demos/petstore.json` | Sample OpenAPI specification | +| `samples/integration-demos/SampleCdm/Entities.cs` | Sample CDM entities | +| `samples/integration-demos/sla-test-guide.md` | SLA testing guide with public APIs | diff --git a/DocFlow.sln b/DocFlow.sln index 8c7b573..d0f46fb 100644 --- a/DocFlow.sln +++ b/DocFlow.sln @@ -1,127 +1,113 @@ - -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio Version 17 -VisualStudioVersion = 17.8.34309.116 -MinimumVisualStudioVersion = 10.0.40219.1 - -# Core Projects -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.Core", "src\DocFlow.Core\DocFlow.Core.csproj", "{A1B2C3D4-1234-5678-9ABC-DEF012345678}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.Diagrams", "src\DocFlow.Diagrams\DocFlow.Diagrams.csproj", "{B2C3D4E5-2345-6789-ABCD-EF0123456789}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.Documents", "src\DocFlow.Documents\DocFlow.Documents.csproj", "{C3D4E5F6-3456-789A-BCDE-F01234567890}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.CodeAnalysis", "src\DocFlow.CodeAnalysis\DocFlow.CodeAnalysis.csproj", "{D4E5F6A7-4567-89AB-CDEF-012345678901}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.CodeGen", "src\DocFlow.CodeGen\DocFlow.CodeGen.csproj", "{E5F6A7B8-5678-9ABC-DEF0-123456789012}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.Vision", "src\DocFlow.Vision\DocFlow.Vision.csproj", "{F6A7B8C9-6789-ABCD-EF01-234567890123}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.IMS", "src\DocFlow.IMS\DocFlow.IMS.csproj", "{A7B8C9D0-789A-BCDE-F012-345678901234}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.Ontology", "src\DocFlow.Ontology\DocFlow.Ontology.csproj", "{B8C9D0E1-89AB-CDEF-0123-456789012345}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.AI", "src\DocFlow.AI\DocFlow.AI.csproj", "{C9D0E1F2-9ABC-DEF0-1234-567890123456}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.CLI", "src\DocFlow.CLI\DocFlow.CLI.csproj", "{D0E1F2A3-ABCD-EF01-2345-678901234567}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.Integration", "src\DocFlow.Integration\DocFlow.Integration.csproj", "{F8A9B0C1-2345-6789-ABCD-456789012345}" -EndProject - -# Test Projects -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.CodeAnalysis.Tests", "tests\DocFlow.CodeAnalysis.Tests\DocFlow.CodeAnalysis.Tests.csproj", "{C5D6E7F8-F012-3456-789A-123456789012}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.Diagrams.Tests", "tests\DocFlow.Diagrams.Tests\DocFlow.Diagrams.Tests.csproj", "{D6E7F8A9-0123-4567-89AB-234567890123}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.CodeGen.Tests", "tests\DocFlow.CodeGen.Tests\DocFlow.CodeGen.Tests.csproj", "{E7F8A9B0-1234-5678-9ABC-345678901234}" -EndProject - -# Solution Folders -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{10000000-0000-0000-0000-000000000001}" -EndProject -Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{20000000-0000-0000-0000-000000000002}" -EndProject - -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {A1B2C3D4-1234-5678-9ABC-DEF012345678}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A1B2C3D4-1234-5678-9ABC-DEF012345678}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A1B2C3D4-1234-5678-9ABC-DEF012345678}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A1B2C3D4-1234-5678-9ABC-DEF012345678}.Release|Any CPU.Build.0 = Release|Any CPU - {B2C3D4E5-2345-6789-ABCD-EF0123456789}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B2C3D4E5-2345-6789-ABCD-EF0123456789}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B2C3D4E5-2345-6789-ABCD-EF0123456789}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B2C3D4E5-2345-6789-ABCD-EF0123456789}.Release|Any CPU.Build.0 = Release|Any CPU - {C3D4E5F6-3456-789A-BCDE-F01234567890}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C3D4E5F6-3456-789A-BCDE-F01234567890}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C3D4E5F6-3456-789A-BCDE-F01234567890}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C3D4E5F6-3456-789A-BCDE-F01234567890}.Release|Any CPU.Build.0 = Release|Any CPU - {D4E5F6A7-4567-89AB-CDEF-012345678901}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D4E5F6A7-4567-89AB-CDEF-012345678901}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D4E5F6A7-4567-89AB-CDEF-012345678901}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D4E5F6A7-4567-89AB-CDEF-012345678901}.Release|Any CPU.Build.0 = Release|Any CPU - {E5F6A7B8-5678-9ABC-DEF0-123456789012}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E5F6A7B8-5678-9ABC-DEF0-123456789012}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E5F6A7B8-5678-9ABC-DEF0-123456789012}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E5F6A7B8-5678-9ABC-DEF0-123456789012}.Release|Any CPU.Build.0 = Release|Any CPU - {F6A7B8C9-6789-ABCD-EF01-234567890123}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F6A7B8C9-6789-ABCD-EF01-234567890123}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F6A7B8C9-6789-ABCD-EF01-234567890123}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F6A7B8C9-6789-ABCD-EF01-234567890123}.Release|Any CPU.Build.0 = Release|Any CPU - {A7B8C9D0-789A-BCDE-F012-345678901234}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {A7B8C9D0-789A-BCDE-F012-345678901234}.Debug|Any CPU.Build.0 = Debug|Any CPU - {A7B8C9D0-789A-BCDE-F012-345678901234}.Release|Any CPU.ActiveCfg = Release|Any CPU - {A7B8C9D0-789A-BCDE-F012-345678901234}.Release|Any CPU.Build.0 = Release|Any CPU - {B8C9D0E1-89AB-CDEF-0123-456789012345}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B8C9D0E1-89AB-CDEF-0123-456789012345}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B8C9D0E1-89AB-CDEF-0123-456789012345}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B8C9D0E1-89AB-CDEF-0123-456789012345}.Release|Any CPU.Build.0 = Release|Any CPU - {C9D0E1F2-9ABC-DEF0-1234-567890123456}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C9D0E1F2-9ABC-DEF0-1234-567890123456}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C9D0E1F2-9ABC-DEF0-1234-567890123456}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C9D0E1F2-9ABC-DEF0-1234-567890123456}.Release|Any CPU.Build.0 = Release|Any CPU - {D0E1F2A3-ABCD-EF01-2345-678901234567}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D0E1F2A3-ABCD-EF01-2345-678901234567}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D0E1F2A3-ABCD-EF01-2345-678901234567}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D0E1F2A3-ABCD-EF01-2345-678901234567}.Release|Any CPU.Build.0 = Release|Any CPU - {F8A9B0C1-2345-6789-ABCD-456789012345}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {F8A9B0C1-2345-6789-ABCD-456789012345}.Debug|Any CPU.Build.0 = Debug|Any CPU - {F8A9B0C1-2345-6789-ABCD-456789012345}.Release|Any CPU.ActiveCfg = Release|Any CPU - {F8A9B0C1-2345-6789-ABCD-456789012345}.Release|Any CPU.Build.0 = Release|Any CPU - {C5D6E7F8-F012-3456-789A-123456789012}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {C5D6E7F8-F012-3456-789A-123456789012}.Debug|Any CPU.Build.0 = Debug|Any CPU - {C5D6E7F8-F012-3456-789A-123456789012}.Release|Any CPU.ActiveCfg = Release|Any CPU - {C5D6E7F8-F012-3456-789A-123456789012}.Release|Any CPU.Build.0 = Release|Any CPU - {D6E7F8A9-0123-4567-89AB-234567890123}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {D6E7F8A9-0123-4567-89AB-234567890123}.Debug|Any CPU.Build.0 = Debug|Any CPU - {D6E7F8A9-0123-4567-89AB-234567890123}.Release|Any CPU.ActiveCfg = Release|Any CPU - {D6E7F8A9-0123-4567-89AB-234567890123}.Release|Any CPU.Build.0 = Release|Any CPU - {E7F8A9B0-1234-5678-9ABC-345678901234}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {E7F8A9B0-1234-5678-9ABC-345678901234}.Debug|Any CPU.Build.0 = Debug|Any CPU - {E7F8A9B0-1234-5678-9ABC-345678901234}.Release|Any CPU.ActiveCfg = Release|Any CPU - {E7F8A9B0-1234-5678-9ABC-345678901234}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection - GlobalSection(NestedProjects) = preSolution - {A1B2C3D4-1234-5678-9ABC-DEF012345678} = {10000000-0000-0000-0000-000000000001} - {B2C3D4E5-2345-6789-ABCD-EF0123456789} = {10000000-0000-0000-0000-000000000001} - {C3D4E5F6-3456-789A-BCDE-F01234567890} = {10000000-0000-0000-0000-000000000001} - {D4E5F6A7-4567-89AB-CDEF-012345678901} = {10000000-0000-0000-0000-000000000001} - {E5F6A7B8-5678-9ABC-DEF0-123456789012} = {10000000-0000-0000-0000-000000000001} - {F6A7B8C9-6789-ABCD-EF01-234567890123} = {10000000-0000-0000-0000-000000000001} - {A7B8C9D0-789A-BCDE-F012-345678901234} = {10000000-0000-0000-0000-000000000001} - {B8C9D0E1-89AB-CDEF-0123-456789012345} = {10000000-0000-0000-0000-000000000001} - {C9D0E1F2-9ABC-DEF0-1234-567890123456} = {10000000-0000-0000-0000-000000000001} - {D0E1F2A3-ABCD-EF01-2345-678901234567} = {10000000-0000-0000-0000-000000000001} - {F8A9B0C1-2345-6789-ABCD-456789012345} = {10000000-0000-0000-0000-000000000001} - {C5D6E7F8-F012-3456-789A-123456789012} = {20000000-0000-0000-0000-000000000002} - {D6E7F8A9-0123-4567-89AB-234567890123} = {20000000-0000-0000-0000-000000000002} - {E7F8A9B0-1234-5678-9ABC-345678901234} = {20000000-0000-0000-0000-000000000002} - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.8.34309.116 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.Core", "src\DocFlow.Core\DocFlow.Core.csproj", "{A1B2C3D4-1234-5678-9ABC-DEF012345678}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.Diagrams", "src\DocFlow.Diagrams\DocFlow.Diagrams.csproj", "{B2C3D4E5-2345-6789-ABCD-EF0123456789}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.Documents", "src\DocFlow.Documents\DocFlow.Documents.csproj", "{C3D4E5F6-3456-789A-BCDE-F01234567890}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.CodeAnalysis", "src\DocFlow.CodeAnalysis\DocFlow.CodeAnalysis.csproj", "{D4E5F6A7-4567-89AB-CDEF-012345678901}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.CodeGen", "src\DocFlow.CodeGen\DocFlow.CodeGen.csproj", "{E5F6A7B8-5678-9ABC-DEF0-123456789012}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.Vision", "src\DocFlow.Vision\DocFlow.Vision.csproj", "{F6A7B8C9-6789-ABCD-EF01-234567890123}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.IMS", "src\DocFlow.IMS\DocFlow.IMS.csproj", "{A7B8C9D0-789A-BCDE-F012-345678901234}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.Ontology", "src\DocFlow.Ontology\DocFlow.Ontology.csproj", "{B8C9D0E1-89AB-CDEF-0123-456789012345}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.AI", "src\DocFlow.AI\DocFlow.AI.csproj", "{C9D0E1F2-9ABC-DEF0-1234-567890123456}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.CLI", "src\DocFlow.CLI\DocFlow.CLI.csproj", "{D0E1F2A3-ABCD-EF01-2345-678901234567}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.Integration", "src\DocFlow.Integration\DocFlow.Integration.csproj", "{F8A9B0C1-2345-6789-ABCD-456789012345}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.CodeAnalysis.Tests", "tests\DocFlow.CodeAnalysis.Tests\DocFlow.CodeAnalysis.Tests.csproj", "{C5D6E7F8-F012-3456-789A-123456789012}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocFlow.Diagrams.Tests", "tests\DocFlow.Diagrams.Tests\DocFlow.Diagrams.Tests.csproj", "{D6E7F8A9-0123-4567-89AB-234567890123}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{10000000-0000-0000-0000-000000000001}" +EndProject +Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "tests", "tests", "{20000000-0000-0000-0000-000000000002}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {A1B2C3D4-1234-5678-9ABC-DEF012345678}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A1B2C3D4-1234-5678-9ABC-DEF012345678}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A1B2C3D4-1234-5678-9ABC-DEF012345678}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A1B2C3D4-1234-5678-9ABC-DEF012345678}.Release|Any CPU.Build.0 = Release|Any CPU + {B2C3D4E5-2345-6789-ABCD-EF0123456789}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B2C3D4E5-2345-6789-ABCD-EF0123456789}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B2C3D4E5-2345-6789-ABCD-EF0123456789}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B2C3D4E5-2345-6789-ABCD-EF0123456789}.Release|Any CPU.Build.0 = Release|Any CPU + {C3D4E5F6-3456-789A-BCDE-F01234567890}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C3D4E5F6-3456-789A-BCDE-F01234567890}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C3D4E5F6-3456-789A-BCDE-F01234567890}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C3D4E5F6-3456-789A-BCDE-F01234567890}.Release|Any CPU.Build.0 = Release|Any CPU + {D4E5F6A7-4567-89AB-CDEF-012345678901}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D4E5F6A7-4567-89AB-CDEF-012345678901}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D4E5F6A7-4567-89AB-CDEF-012345678901}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D4E5F6A7-4567-89AB-CDEF-012345678901}.Release|Any CPU.Build.0 = Release|Any CPU + {E5F6A7B8-5678-9ABC-DEF0-123456789012}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {E5F6A7B8-5678-9ABC-DEF0-123456789012}.Debug|Any CPU.Build.0 = Debug|Any CPU + {E5F6A7B8-5678-9ABC-DEF0-123456789012}.Release|Any CPU.ActiveCfg = Release|Any CPU + {E5F6A7B8-5678-9ABC-DEF0-123456789012}.Release|Any CPU.Build.0 = Release|Any CPU + {F6A7B8C9-6789-ABCD-EF01-234567890123}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F6A7B8C9-6789-ABCD-EF01-234567890123}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F6A7B8C9-6789-ABCD-EF01-234567890123}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F6A7B8C9-6789-ABCD-EF01-234567890123}.Release|Any CPU.Build.0 = Release|Any CPU + {A7B8C9D0-789A-BCDE-F012-345678901234}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A7B8C9D0-789A-BCDE-F012-345678901234}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A7B8C9D0-789A-BCDE-F012-345678901234}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A7B8C9D0-789A-BCDE-F012-345678901234}.Release|Any CPU.Build.0 = Release|Any CPU + {B8C9D0E1-89AB-CDEF-0123-456789012345}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {B8C9D0E1-89AB-CDEF-0123-456789012345}.Debug|Any CPU.Build.0 = Debug|Any CPU + {B8C9D0E1-89AB-CDEF-0123-456789012345}.Release|Any CPU.ActiveCfg = Release|Any CPU + {B8C9D0E1-89AB-CDEF-0123-456789012345}.Release|Any CPU.Build.0 = Release|Any CPU + {C9D0E1F2-9ABC-DEF0-1234-567890123456}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C9D0E1F2-9ABC-DEF0-1234-567890123456}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C9D0E1F2-9ABC-DEF0-1234-567890123456}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C9D0E1F2-9ABC-DEF0-1234-567890123456}.Release|Any CPU.Build.0 = Release|Any CPU + {D0E1F2A3-ABCD-EF01-2345-678901234567}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D0E1F2A3-ABCD-EF01-2345-678901234567}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D0E1F2A3-ABCD-EF01-2345-678901234567}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D0E1F2A3-ABCD-EF01-2345-678901234567}.Release|Any CPU.Build.0 = Release|Any CPU + {F8A9B0C1-2345-6789-ABCD-456789012345}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {F8A9B0C1-2345-6789-ABCD-456789012345}.Debug|Any CPU.Build.0 = Debug|Any CPU + {F8A9B0C1-2345-6789-ABCD-456789012345}.Release|Any CPU.ActiveCfg = Release|Any CPU + {F8A9B0C1-2345-6789-ABCD-456789012345}.Release|Any CPU.Build.0 = Release|Any CPU + {C5D6E7F8-F012-3456-789A-123456789012}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {C5D6E7F8-F012-3456-789A-123456789012}.Debug|Any CPU.Build.0 = Debug|Any CPU + {C5D6E7F8-F012-3456-789A-123456789012}.Release|Any CPU.ActiveCfg = Release|Any CPU + {C5D6E7F8-F012-3456-789A-123456789012}.Release|Any CPU.Build.0 = Release|Any CPU + {D6E7F8A9-0123-4567-89AB-234567890123}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {D6E7F8A9-0123-4567-89AB-234567890123}.Debug|Any CPU.Build.0 = Debug|Any CPU + {D6E7F8A9-0123-4567-89AB-234567890123}.Release|Any CPU.ActiveCfg = Release|Any CPU + {D6E7F8A9-0123-4567-89AB-234567890123}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(NestedProjects) = preSolution + {A1B2C3D4-1234-5678-9ABC-DEF012345678} = {10000000-0000-0000-0000-000000000001} + {B2C3D4E5-2345-6789-ABCD-EF0123456789} = {10000000-0000-0000-0000-000000000001} + {C3D4E5F6-3456-789A-BCDE-F01234567890} = {10000000-0000-0000-0000-000000000001} + {D4E5F6A7-4567-89AB-CDEF-012345678901} = {10000000-0000-0000-0000-000000000001} + {E5F6A7B8-5678-9ABC-DEF0-123456789012} = {10000000-0000-0000-0000-000000000001} + {F6A7B8C9-6789-ABCD-EF01-234567890123} = {10000000-0000-0000-0000-000000000001} + {A7B8C9D0-789A-BCDE-F012-345678901234} = {10000000-0000-0000-0000-000000000001} + {B8C9D0E1-89AB-CDEF-0123-456789012345} = {10000000-0000-0000-0000-000000000001} + {C9D0E1F2-9ABC-DEF0-1234-567890123456} = {10000000-0000-0000-0000-000000000001} + {D0E1F2A3-ABCD-EF01-2345-678901234567} = {10000000-0000-0000-0000-000000000001} + {F8A9B0C1-2345-6789-ABCD-456789012345} = {10000000-0000-0000-0000-000000000001} + {C5D6E7F8-F012-3456-789A-123456789012} = {20000000-0000-0000-0000-000000000002} + {D6E7F8A9-0123-4567-89AB-234567890123} = {20000000-0000-0000-0000-000000000002} + EndGlobalSection +EndGlobal diff --git a/HospitalDomain.cs b/HospitalDomain.cs new file mode 100644 index 0000000..d5ec542 --- /dev/null +++ b/HospitalDomain.cs @@ -0,0 +1,79 @@ +namespace Hospital.Domain.Domain; + +public class Appointment +{ + public object recordId { get; set; } + public object racordId { get; set; } + public object diagnosis { get; set; } + public object treatment { get; set; } + public object pressicratuss { get; set; } +} + +public class AppointmentId +{ + public object date { get; set; } + public object specialty { get; set; } + public object licenseNumber { get; set; } +} + +public class BSchedule +{ + public object diagnoseL { get; set; } + public object preserbbe { get; set; } +} + +public class Departmecord +{ + public object deptId { get; set; } + public object staff { get; set; } + public object name { get; set; } + public object prepertabess { get; set; } +} + +public class Ditopper +{ + public object neabor { get; set; } + public object specialty { get; set; } + public object preserrber { get; set; } +} + +public class Hospital +{ + public object poclayeemiee { get; set; } + public object hiredate { get; set; } + public object salay { get; set; } +} + +public class Insurance +{ + public object hospitalNabel { get; set; } + public object provides { get; set; } + public object salary { get; set; } +} + +public class InsurancePolicy +{ + public object policyNumber { get; set; } + public object name { get; set; } + public object coverage { get; set; } +} + +public class Nourise +{ + public object durpooe { get; set; } + public object pepartbent { get; set; } +} + +public class Patient +{ + public object name { get; set; } + public object dateOfBirth { get; set; } + public object bloodType { get; set; } + public object allergies { get; set; } +} + +public class Schedule +{ + public object diagnoses { get; set; } + public object duriebse { get; set; } +} diff --git a/README.md b/README.md index 8bd57bf..0cc1916 100644 --- a/README.md +++ b/README.md @@ -1,54 +1,78 @@ # DocFlow +``` + ____ _____ _ + | _ \ ___ ___ | ___| | | ___ __ __ + | | | | / _ \ / __| | |_ | | / _ \ \ \ /\ / / + | |_| | | (_) | | (__ | _| | | | (_) | \ V V / + |____/ \___/ \___| |_| |_| \___/ \_/\_/ +``` + **Intelligent Documentation and Modeling Toolkit** -Transform code into diagrams, diagrams into code, and whiteboard sketches into working models. Built on a Canonical Semantic Model that preserves meaning across all transformations. +Transform whiteboard sketches into working code. Generate diagrams from source files. Map external APIs to your domain model. DocFlow is a complete toolkit for the modern software architect. [![.NET](https://img.shields.io/badge/.NET-8.0-512BD4)](https://dotnet.microsoft.com/) [![License](https://img.shields.io/badge/License-MIT-green.svg)](LICENSE) [![Build](https://img.shields.io/badge/build-passing-brightgreen)]() -[![Tests](https://img.shields.io/badge/tests-72%20passing-brightgreen)]() +[![Tests](https://img.shields.io/badge/tests-91%20passing-brightgreen)]() --- -## Features +## Highlights -| Feature | Status | Description | -|---------|--------|-------------| -| C# to Mermaid | **Implemented** | Generate class diagrams from C# source code | -| Mermaid to C# | **Implemented** | Generate DDD-style C# from Mermaid diagrams | -| Round-trip Sync | **Implemented** | Bidirectional transformation with semantic preservation | -| Whiteboard Scanning | **Implemented** | AI-powered diagram extraction from photos | -| Professional CLI | **Implemented** | Spectre.Console with rich output | -| API Integration | **Scaffolded** | OpenAPI parsing, CDM mapping (designed) | -| Document Pipeline | Planned | PDF/Word/Markdown conversion | -| IMS Learning | Planned | Pattern learning from examples | +| Feature | Description | +|---------|-------------| +| **Whiteboard to Code** | Snap a photo of your whiteboard diagram, get working C# in seconds | +| **Bidirectional Transform** | C# to Mermaid and back with full semantic preservation | +| **API Integration** | Parse OpenAPI specs, map to your CDM, generate typed clients | +| **SLA Validation** | Validate data freshness against SLA requirements | +| **DDD Support** | Native understanding of aggregates, entities, and value objects | --- ## Quick Start +### Three Commands to See the Magic + +```bash +# 1. Generate a Mermaid diagram from your C# domain model +docflow diagram Domain.cs -o domain.mmd + +# 2. Scan a whiteboard photo and extract the diagram +docflow scan whiteboard.jpg -o extracted.mmd + +# 3. Generate integration code from an OpenAPI spec +docflow integrate generate petstore.json --cdm Models/ -o Generated/ +``` + ### Installation **Linux/macOS/WSL:** ```bash -curl -sSL https://raw.githubusercontent.com/kurtmitchell/docflow/main/install.sh | bash +curl -sSL https://raw.githubusercontent.com/infinyte/docflow/main/install.sh | bash ``` **Windows PowerShell:** ```powershell -irm https://raw.githubusercontent.com/kurtmitchell/docflow/main/install.ps1 | iex +irm https://raw.githubusercontent.com/infinyte/docflow/main/install.ps1 | iex ``` **From Source:** ```bash -git clone https://github.com/kurtmitchell/docflow.git +git clone https://github.com/infinyte/docflow.git cd docflow dotnet build dotnet run --project src/DocFlow.CLI -- --help ``` -### Usage Examples +--- + +## Commands + +### Diagram Commands + +Generate and transform between C# and Mermaid class diagrams. ```bash # Generate Mermaid class diagram from C# source @@ -57,18 +81,61 @@ docflow diagram Domain.cs -o domain.mmd # Generate C# code from Mermaid diagram docflow codegen diagram.mmd -o Models.cs --namespace MyApp.Domain -# AI-powered whiteboard scanning (requires API key) -docflow scan whiteboard.jpg -o extracted.mmd - # Full round-trip test with comparison docflow roundtrip Domain.cs --compare -v ``` -### API Key Configuration +### Whiteboard Scanning + +AI-powered extraction of diagrams from photos using Claude Vision. + +```bash +# Basic scan +docflow scan whiteboard.jpg -o extracted.mmd + +# With context hint for better accuracy +docflow scan whiteboard.jpg -c "e-commerce order management" -v + +# Full pipeline: whiteboard to C# code +docflow scan whiteboard.jpg -o temp.mmd && docflow codegen temp.mmd -o Models.cs +``` + +**Requirements:** Claude API key (see [Configuration](#configuration)) + +### Integration Commands + +Analyze CDM mappings, validate SLAs, and generate integration code. + +```bash +# Analyze mapping between API and your CDM +docflow integrate analyze petstore.json --cdm Models/Entities.cs --threshold 70 + +# Validate SLA data freshness +docflow integrate sla https://api.example.com/data --expected 30s --samples 10 + +# Generate integration code (DTOs, AutoMapper, HTTP client, validators) +docflow integrate generate petstore.json --cdm Models/ -o Generated/ -n MyApp.Integration +``` + +#### Generate Options + +| Option | Description | +|--------|-------------| +| `--generate dtos` | External DTOs with JsonPropertyName attributes | +| `--generate mappers` | AutoMapper profiles with confidence comments | +| `--generate client` | Typed HTTP client interface | +| `--generate validators` | FluentValidation validators | +| `--generate all` | All of the above (default) | + +--- + +## Configuration -The whiteboard scanner requires a Claude API key. Configure it using one of these methods (in priority order): +### API Key Setup -**1. Environment Variable:** +The whiteboard scanner requires a Claude API key. Configure using one of these methods (in priority order): + +**1. Environment Variable (Recommended):** ```bash export ANTHROPIC_API_KEY='sk-ant-...' ``` @@ -87,6 +154,8 @@ export ANTHROPIC_API_KEY='sk-ant-...' } ``` +Get your API key at: https://console.anthropic.com/ + --- ## Architecture @@ -94,43 +163,45 @@ export ANTHROPIC_API_KEY='sk-ant-...' DocFlow uses a **Canonical Semantic Model** as the universal truth layer. All formats translate to and from this model, enabling lossless bidirectional transformations. ``` - ┌─────────────────────────────────────┐ - │ Canonical Semantic Model │ - │ (Entities, Relationships, DDD) │ - └──────────────┬──────────────────────┘ - │ - ┌───────────────┬───────────┼───────────┬───────────────┐ - │ │ │ │ │ - ▼ ▼ ▼ ▼ ▼ -┌─────────────┐ ┌─────────────┐ ┌───────┐ ┌─────────┐ ┌─────────────┐ -│ C# Code │ │ Mermaid │ │ API │ │ Docs │ │ Whiteboard │ -│ (Roslyn) │ │ Diagrams │ │ Specs │ │ (TBD) │ │ (Vision) │ -└─────────────┘ └─────────────┘ └───────┘ └─────────┘ └─────────────┘ + +-------------------------------------+ + | Canonical Semantic Model | + | (Entities, Relationships, DDD) | + +-----------------+-------------------+ + | + +---------------+--------------+-------------+---------------+ + | | | | | + v v v v v ++-------------+ +-------------+ +---------+ +-----------+ +---------------+ +| C# Code | | Mermaid | | OpenAPI | | CDM | | Whiteboard | +| (Roslyn) | | Diagrams | | Specs | | Entities | | (Vision) | ++-------------+ +-------------+ +---------+ +-----------+ +---------------+ ``` ### Why a Canonical Model? -Direct format conversion (A → B) breaks down when: +Direct format conversion (A -> B) breaks down when: - Information exists in A but not B (lossy) -- You need round-trips (A → B → A ≠ A) +- You need round-trips (A -> B -> A != A) - Semantic meaning differs between formats -DocFlow's approach: **A → Canonical Model → B** +DocFlow's approach: **A -> Canonical Model -> B** The model captures *meaning*, not just syntax. It knows that `ICollection` in C# and a filled diamond in Mermaid both represent *composition*. -### DDD Support +--- + +## DDD Support The semantic model understands Domain-Driven Design patterns: -| Classification | Generated As | -|----------------|--------------| -| AggregateRoot | Class with `<>` stereotype | -| Entity | Class with identity property | -| ValueObject | Immutable record type | -| DomainService | Service class | -| Enum | Enumeration | -| Interface | Interface contract | +| Classification | C# Output | Mermaid Output | +|----------------|-----------|----------------| +| AggregateRoot | Class with identity | `<>` stereotype | +| Entity | Class with Id property | `<>` stereotype | +| ValueObject | Immutable record type | `<>` stereotype | +| DomainService | Service class | `<>` stereotype | +| Enum | Enumeration | `<>` stereotype | +| Interface | Interface contract | `<>` stereotype | --- @@ -138,55 +209,68 @@ The semantic model understands Domain-Driven Design patterns: ``` DocFlow/ -├── src/ -│ ├── DocFlow.Core # Canonical model & abstractions -│ ├── DocFlow.Diagrams # Mermaid parsing & generation -│ ├── DocFlow.CodeAnalysis # Roslyn-based C# parsing -│ ├── DocFlow.CodeGen # C# code generation from model -│ ├── DocFlow.Vision # AI-powered whiteboard scanning -│ ├── DocFlow.AI # Claude API integration -│ ├── DocFlow.IMS # Intelligent Mapping Service (pattern learning) -│ ├── DocFlow.Ontology # DDD pattern classification -│ ├── DocFlow.Documents # Document pipeline (planned) -│ ├── DocFlow.Integration # API integration automation (scaffolded) -│ ├── DocFlow.Web # Web UI (planned) -│ └── DocFlow.CLI # Command-line interface -├── tests/ -│ ├── DocFlow.CodeAnalysis.Tests # 20 tests -│ ├── DocFlow.Diagrams.Tests # 52 tests -│ └── DocFlow.CodeGen.Tests # 19 tests -├── docs/ -│ ├── ARCHITECTURE.md # Technical architecture -│ ├── CLI-REFERENCE.md # Complete CLI documentation -│ ├── CHANGELOG.md # Version history -│ └── design/ # Design documents -└── samples/ - └── whiteboard-demos/ # Whiteboard scanner examples ++-- src/ +| +-- DocFlow.Core # Canonical model & abstractions +| +-- DocFlow.Diagrams # Mermaid parsing & generation +| +-- DocFlow.CodeAnalysis # Roslyn-based C# parsing +| +-- DocFlow.CodeGen # C# code generation from model +| +-- DocFlow.Vision # AI-powered whiteboard scanning +| +-- DocFlow.AI # Claude API integration +| +-- DocFlow.IMS # Intelligent Mapping Service +| +-- DocFlow.Ontology # DDD pattern classification +| +-- DocFlow.Integration # API integration automation +| +-- DocFlow.Documents # Document pipeline (planned) +| +-- DocFlow.Web # Web UI (planned) +| +-- DocFlow.CLI # Command-line interface ++-- tests/ +| +-- DocFlow.CodeAnalysis.Tests # 20 tests +| +-- DocFlow.Diagrams.Tests # 52 tests +| +-- DocFlow.CodeGen.Tests # 19 tests ++-- docs/ +| +-- ARCHITECTURE.md # Technical architecture +| +-- CLI-REFERENCE.md # Complete CLI documentation +| +-- CHANGELOG.md # Version history +| +-- design/ # Design documents ++-- samples/ + +-- whiteboard-demos/ # Whiteboard scanner examples + +-- integration-demos/ # Integration module examples ``` -### DocFlow.Integration (Scaffolded) +--- + +## Integration Module The Integration module extends DocFlow's canonical model pattern to enterprise API integrations: -- **OpenAPI/Swagger parsing** → Semantic model extraction -- **CDM (Canonical Data Model) mapping** → External API ↔ internal model -- **SLA validation** → Data freshness checking -- **Pre-built domain patterns** → Aviation, e-commerce, etc. +### Features -See [docs/design/integration-module.md](docs/design/integration-module.md) for the full design. +- **OpenAPI Parsing**: Extract semantic model from OpenAPI 3.x specs +- **CDM Mapping**: Map external DTOs to your Canonical Data Model with confidence scores +- **SLA Validation**: Validate data freshness against SLA requirements +- **Code Generation**: Generate DTOs, AutoMapper profiles, HTTP clients, validators ---- +### Example Output -## CLI Commands +**Generated AutoMapper Profile:** +```csharp +// Pet -> Product (79% confidence) +CreateMap() + .ForMember(d => d.Id, opt => opt.MapFrom(s => s.Id)) // 95% - Exact name match + .ForMember(d => d.Name, opt => opt.MapFrom(s => s.Name)) // 95% - Exact name match + .ForMember(d => d.Status, opt => opt.MapFrom(s => MapProductStatus(s.Status))) + // TODO: Manual mapping required for Price (no source field) + .ForMember(d => d.Price, opt => opt.Ignore()); +``` -| Command | Alias | Description | -|---------|-------|-------------| -| `diagram ` | `d` | Generate Mermaid from C# source | -| `codegen ` | `c` | Generate C# from Mermaid diagram | -| `roundtrip ` | `r` | Full C# → Mermaid → C# round-trip | -| `scan ` | `s` | AI-powered whiteboard scanning | +**SLA Validation:** +``` +SLA Validation: COMPLIANT +Expected Max Age: 30s +Actual Average: 12.4s +Compliance: 100% (10/10 samples) +``` -See [docs/CLI-REFERENCE.md](docs/CLI-REFERENCE.md) for complete documentation. +See [docs/design/integration-module.md](docs/design/integration-module.md) for full documentation. --- @@ -203,17 +287,24 @@ See [docs/CLI-REFERENCE.md](docs/CLI-REFERENCE.md) for complete documentation. # Build dotnet build -# Run all tests +# Run all tests (91 tests) dotnet test +# Run specific test project +dotnet test tests/DocFlow.CodeAnalysis.Tests +dotnet test tests/DocFlow.Diagrams.Tests +dotnet test tests/DocFlow.CodeGen.Tests + # Run CLI locally dotnet run --project src/DocFlow.CLI -- diagram MyClass.cs ``` ### Test Coverage -- **91+ unit tests** across 3 test projects -- C# parsing, Mermaid generation, round-trip preservation +- **91 unit tests** across 3 test projects +- C# parsing accuracy (classes, records, interfaces, enums) +- Mermaid generation correctness +- Round-trip semantic preservation - DDD pattern detection and classification --- @@ -232,26 +323,43 @@ dotnet run --project src/DocFlow.CLI -- diagram MyClass.cs ## Roadmap ### v0.1.0-preview (Current) -- [x] C# → Mermaid class diagram generation -- [x] Mermaid → C# code generation (DDD-style) + +- [x] C# -> Mermaid class diagram generation +- [x] Mermaid -> C# code generation (DDD-style) - [x] Bidirectional round-trip with semantic preservation - [x] AI-powered whiteboard scanning - [x] Professional CLI with Spectre.Console -- [x] Integration module scaffolded +- [x] Integration module (analyze, sla, generate) +- [x] SLA data freshness validation +- [x] Integration code generation (DTOs, AutoMapper, clients, validators) ### v0.2.0 + - [ ] IMS pattern learning from examples - [ ] PlantUML support - [ ] Sequence diagram support -- [ ] Integration module implementation +- [ ] GraphQL schema parsing ### v0.3.0 + - [ ] PDF/Word document pipeline - [ ] VS Code extension - [ ] Web UI (Blazor) --- +## Contributing + +Contributions are welcome! Please: + +1. Fork the repository +2. Create a feature branch (`git checkout -b feature/amazing-feature`) +3. Make your changes with tests +4. Ensure all tests pass (`dotnet test`) +5. Submit a pull request + +--- + ## License MIT License - see [LICENSE](LICENSE) for details. diff --git a/docflow-dev.cmd b/docflow-dev.cmd new file mode 100644 index 0000000..e96e60d --- /dev/null +++ b/docflow-dev.cmd @@ -0,0 +1,2 @@ +@echo off +dotnet run --project "%~dp0src\DocFlow.CLI\DocFlow.CLI.csproj" -- %* diff --git a/docflow-dev.sh b/docflow-dev.sh new file mode 100644 index 0000000..f284f49 --- /dev/null +++ b/docflow-dev.sh @@ -0,0 +1,17 @@ +#!/bin/bash +# Run DocFlow CLI from local build (for development) + +# Find dotnet - check common locations +if command -v dotnet &> /dev/null; then + DOTNET="dotnet" +elif [ -f "/root/.dotnet/dotnet" ]; then + DOTNET="/root/.dotnet/dotnet" +elif [ -f "$HOME/.dotnet/dotnet" ]; then + DOTNET="$HOME/.dotnet/dotnet" +else + echo "Error: dotnet not found" + exit 1 +fi + +SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" +$DOTNET run --project "$SCRIPT_DIR/src/DocFlow.CLI/DocFlow.CLI.csproj" -- "$@" diff --git a/config.json b/docflow.json similarity index 98% rename from config.json rename to docflow.json index 69feb58..f6036ac 100644 --- a/config.json +++ b/docflow.json @@ -1,3 +1,3 @@ -{ - "anthropicApiKey": "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" +{ + "anthropicApiKey": "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" } \ No newline at end of file diff --git a/docs/ARCHITECTURE.md b/docs/ARCHITECTURE.md index a34800b..d27b8d0 100644 --- a/docs/ARCHITECTURE.md +++ b/docs/ARCHITECTURE.md @@ -1,351 +1,432 @@ -# DocFlow Architecture - -This document describes the technical architecture of DocFlow, explaining the design decisions and patterns that enable bidirectional transformation between code, diagrams, and documentation. - -## Core Concept: Canonical Semantic Model - -DocFlow's architecture centers on a **Canonical Semantic Model** - an intermediate representation that captures the *meaning* of software models, not just their syntax. - -### The Problem with Direct Translation - -Traditional tools translate directly between formats (A → B). This approach fails when: - -1. **Information Loss**: Format A has concepts that B cannot represent -2. **Round-Trip Failure**: A → B → A produces different output than the original -3. **Semantic Mismatch**: The same concept has different syntax in each format - -### The DocFlow Solution - -``` -┌─────────────┐ ┌─────────────────────────────────────┐ ┌─────────────┐ -│ Source │ │ Canonical Semantic Model │ │ Target │ -│ Format │────▶│ │────▶│ Format │ -│ (C#, etc) │ │ Entities, Properties, Operations │ │ (Mermaid) │ -└─────────────┘ │ Relationships, Classifications │ └─────────────┘ - │ │ DDD Patterns, Stereotypes │ │ - │ └─────────────────────────────────────┘ │ - │ │ │ - │ ▼ │ - │ ┌─────────────────────────────────────┐ │ - └───────────▶│ Round-Trip Support │◀───────────┘ - │ Semantic preservation via │ - │ canonical representation │ - └─────────────────────────────────────┘ -``` - -By routing all transformations through the canonical model, DocFlow: -- Preserves semantic meaning across formats -- Enables true round-trip transformations -- Supports adding new formats without N×M parser/generator combinations - ---- - -## Semantic Model Structure - -### SemanticModel - -The root container holding the complete model: - -```csharp -public sealed class SemanticModel -{ - public string Id { get; init; } - public string? Name { get; set; } - public Dictionary Entities { get; init; } - public List Relationships { get; init; } - public List Namespaces { get; init; } - public ModelProvenance? Provenance { get; set; } -} -``` - -### SemanticEntity - -Represents any type-like construct (class, interface, enum, etc.): - -```csharp -public sealed class SemanticEntity -{ - public string Id { get; init; } - public string Name { get; init; } - public EntityClassification Classification { get; set; } - public bool IsAbstract { get; set; } - public List Properties { get; init; } - public List Operations { get; init; } - public List Stereotypes { get; init; } -} -``` - -### Entity Classifications (DDD Support) - -```csharp -public enum EntityClassification -{ - Class, // Generic class - AggregateRoot, // DDD aggregate boundary - Entity, // DDD entity with identity - ValueObject, // DDD immutable value - DomainService, // Stateless domain operations - DomainEvent, // Something that happened - Repository, // Collection-like persistence - Interface, // Contract definition - Enum, // Enumeration - Record // Immutable data carrier -} -``` - -### SemanticRelationship - -Captures relationships with full semantic information: - -```csharp -public sealed class SemanticRelationship -{ - public string SourceEntityId { get; init; } - public string TargetEntityId { get; init; } - public RelationshipType Type { get; init; } // Inheritance, Composition, etc. - public string? SourceMultiplicity { get; set; } - public string? TargetMultiplicity { get; set; } -} -``` - ---- - -## Parser → Generator Pattern - -All transformations follow the same pattern: - -``` -IModelParser: Input → SemanticModel -IModelGenerator: SemanticModel → Output -``` - -### Parser Interface - -```csharp -public interface IModelParser -{ - string FormatName { get; } - IReadOnlyList SupportedExtensions { get; } - - Task ParseAsync( - ParserInput input, - ParserOptions? options = null, - CancellationToken cancellationToken = default); -} -``` - -### Generator Interface - -```csharp -public interface IModelGenerator -{ - string FormatName { get; } - string DefaultExtension { get; } - - Task GenerateAsync( - SemanticModel model, - GeneratorOptions? options = null, - CancellationToken cancellationToken = default); -} -``` - -### Implemented Transformers - -| Component | Parser | Generator | -|-----------|--------|-----------| -| C# | `CSharpModelParser` | `CSharpModelGenerator` | -| Mermaid | `MermaidClassDiagramParser` | `MermaidClassDiagramGenerator` | -| Whiteboard | `WhiteboardScanner` | - | - ---- - -## Whiteboard Scanning Pipeline - -The whiteboard scanner uses AI vision to extract diagrams from photos: - -``` -┌─────────────┐ ┌─────────────┐ ┌─────────────┐ ┌─────────────┐ -│ Image │────▶│ Base64 │────▶│ Claude │────▶│ Mermaid │ -│ (JPG/PNG) │ │ Encode │ │ Vision API │ │ Text │ -└─────────────┘ └─────────────┘ └─────────────┘ └──────┬──────┘ - │ - ▼ -┌─────────────┐ ┌─────────────┐ ┌─────────────────────────────────┐ -│ Semantic │◀────│ Mermaid │◀────│ Prompt Engineering │ -│ Model │ │ Parser │ │ - Diagram type detection │ -└─────────────┘ └─────────────┘ │ - Entity/relationship extract │ - │ - Mermaid syntax generation │ - └─────────────────────────────────┘ -``` - -### Key Components - -**WhiteboardScanner** (`DocFlow.Vision/WhiteboardScanner.cs`) -- Orchestrates the scanning pipeline -- Handles image loading and format detection -- Manages diagram type detection -- Converts AI output to SemanticModel - -**ClaudeProvider** (`DocFlow.AI/Providers/ClaudeProvider.cs`) -- Implements `IAiProvider` interface -- Handles Claude API communication -- Supports vision (image analysis) and text completion -- Multi-source API key resolution - -### Prompt Engineering - -The whiteboard scanner uses carefully crafted prompts: - -1. **Diagram Type Detection**: Quick classification of diagram type with confidence score -2. **Entity Extraction**: Detailed analysis to extract classes, properties, methods -3. **Relationship Mapping**: Identify inheritance, composition, association patterns -4. **Mermaid Generation**: Output valid Mermaid classDiagram syntax - ---- - -## Integration Module Architecture - -The Integration module (scaffolded, not fully implemented) extends the canonical model pattern to API integrations: - -``` -┌─────────────────────────────────────────────────────────────────────────┐ -│ External API Ecosystem │ -├─────────────────┬─────────────────┬─────────────────┬───────────────────┤ -│ OpenAPI 3.x │ Swagger 2.0 │ GraphQL │ JSON Samples │ -└────────┬────────┴────────┬────────┴────────┬────────┴─────────┬─────────┘ - │ │ │ │ - └─────────────────┴─────────────────┴──────────────────┘ - │ - ▼ - ┌───────────────────────────────┐ - │ Canonical Semantic Model │ - │ (Same as Code/Diagrams!) │ - └───────────────┬───────────────┘ - │ - ┌───────────────┴───────────────┐ - │ CDM Mapper │ - │ (IMS-powered mapping) │ - └───────────────┬───────────────┘ - │ - ▼ - ┌───────────────────────────────┐ - │ Internal Canonical Model │ - │ (Your Domain Model) │ - └───────────────────────────────┘ -``` - -### Pre-built Domain Patterns - -The Integration module includes pre-seeded patterns for common domains: - -**Aviation Domain:** -| External Pattern | Canonical Target | Confidence | -|------------------|------------------|------------| -| `tail_num`, `aircraft_id` | TailNumber | 95% | -| `arr_time`, `eta` | ArrivalDateTime | 93% | -| `pax`, `passenger_count` | PassengerCount | 90% | - -### SLA Validation - -The SlaValidator checks data freshness to catch stale data issues: - -```csharp -var report = await slaValidator.ValidateDataFreshnessAsync(new SlaValidationRequest -{ - EndpointUrl = "https://api.example.com/v1/data", - ExpectedMaxAge = TimeSpan.FromSeconds(30), - SampleCount = 100 -}); -``` - -See [docs/design/integration-module.md](design/integration-module.md) for full design. - ---- - -## Intelligent Mapping Service (IMS) - -The IMS (designed, not fully implemented) learns transformation patterns from examples: - -``` -┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ -│ Observed │────▶│ Pattern │────▶│ Learned │ -│ Transformation│ │ Extraction │ │ Patterns │ -└─────────────────┘ └─────────────────┘ └────────┬────────┘ - │ - ▼ -┌─────────────────┐ ┌─────────────────┐ ┌─────────────────┐ -│ Suggestions │◀────│ Pattern │◀────│ New Input │ -│ with Confidence│ │ Matching │ │ │ -└─────────────────┘ └─────────────────┘ └─────────────────┘ -``` - -### Key Concepts - -- **LearnedPattern**: A transformation pattern with confidence score -- **PatternMatcher**: Applies patterns to new inputs -- **FeedbackLoop**: User corrections improve future suggestions - ---- - -## Project Dependencies - -``` -DocFlow.CLI -├── DocFlow.Core # Canonical model, abstractions -├── DocFlow.Diagrams # Mermaid parsing & generation -│ └── DocFlow.Core -├── DocFlow.CodeAnalysis # Roslyn-based C# parsing -│ └── DocFlow.Core -├── DocFlow.CodeGen # C# code generation -│ └── DocFlow.Core -├── DocFlow.Vision # Whiteboard scanning -│ ├── DocFlow.Core -│ └── DocFlow.AI -├── DocFlow.AI # AI provider abstraction -│ └── DocFlow.Core -├── DocFlow.IMS # Pattern learning -│ └── DocFlow.Core -├── DocFlow.Ontology # DDD classification -│ └── DocFlow.Core -├── DocFlow.Integration # API integration -│ ├── DocFlow.Core -│ ├── DocFlow.IMS -│ └── DocFlow.CodeGen -├── DocFlow.Documents # Document pipeline (planned) -│ └── DocFlow.Core -└── DocFlow.Web # Web UI (planned) - └── DocFlow.Core -``` - ---- - -## Design Principles - -### 1. Semantic Preservation -All transformations preserve meaning. A class in C# should have the same semantic representation whether it came from source code, a Mermaid diagram, or a whiteboard photo. - -### 2. Extensibility -Adding a new format requires only a parser and/or generator. The canonical model stays unchanged. - -### 3. DDD-First -The model understands Domain-Driven Design patterns natively. Aggregates, entities, and value objects are first-class concepts. - -### 4. Async All the Way -All I/O-bound operations are async with CancellationToken support. - -### 5. Nullable Safety -Nullable reference types are enabled throughout. No `NullReferenceException` surprises. - ---- - -## Technology Stack - -| Layer | Technology | -|-------|------------| -| Runtime | .NET 8.0 | -| Language | C# 12 | -| C# Parsing | Microsoft.CodeAnalysis.CSharp (Roslyn) | -| CLI | System.CommandLine + Spectre.Console | -| AI | Anthropic Claude API | -| OpenAPI | Microsoft.OpenApi.Readers | -| Testing | xUnit + FluentAssertions | +# DocFlow Architecture + +This document describes the technical architecture of DocFlow, explaining the design decisions and patterns that enable bidirectional transformation between code, diagrams, APIs, and documentation. + +## Core Concept: Canonical Semantic Model + +DocFlow's architecture centers on a **Canonical Semantic Model** - an intermediate representation that captures the *meaning* of software models, not just their syntax. + +### The Problem with Direct Translation + +Traditional tools translate directly between formats (A -> B). This approach fails when: + +1. **Information Loss**: Format A has concepts that B cannot represent +2. **Round-Trip Failure**: A -> B -> A produces different output than the original +3. **Semantic Mismatch**: The same concept has different syntax in each format + +### The DocFlow Solution + +``` ++-------------+ +-------------------------------------+ +-------------+ +| Source | | Canonical Semantic Model | | Target | +| Format |---->| |---->| Format | +| (C#, etc) | | Entities, Properties, Operations | | (Mermaid) | ++-------------+ | Relationships, Classifications | +-------------+ + | | DDD Patterns, Stereotypes | | + | +-------------------------------------+ | + | | | + | v | + | +-------------------------------------+ | + +----------->| Round-Trip Support |<-----------+ + | Semantic preservation via | + | canonical representation | + +-------------------------------------+ +``` + +By routing all transformations through the canonical model, DocFlow: +- Preserves semantic meaning across formats +- Enables true round-trip transformations +- Supports adding new formats without N x M parser/generator combinations + +--- + +## Semantic Model Structure + +### SemanticModel + +The root container holding the complete model: + +```csharp +public sealed class SemanticModel +{ + public string Id { get; init; } + public string? Name { get; set; } + public Dictionary Entities { get; init; } + public List Relationships { get; init; } + public List Namespaces { get; init; } + public ModelProvenance? Provenance { get; set; } +} +``` + +### SemanticEntity + +Represents any type-like construct (class, interface, enum, etc.): + +```csharp +public sealed class SemanticEntity +{ + public string Id { get; init; } + public string Name { get; init; } + public EntityClassification Classification { get; set; } + public bool IsAbstract { get; set; } + public List Properties { get; init; } + public List Operations { get; init; } + public List Stereotypes { get; init; } +} +``` + +### Entity Classifications (DDD Support) + +```csharp +public enum EntityClassification +{ + Class, // Generic class + AggregateRoot, // DDD aggregate boundary + Entity, // DDD entity with identity + ValueObject, // DDD immutable value + DomainService, // Stateless domain operations + DomainEvent, // Something that happened + Repository, // Collection-like persistence + Interface, // Contract definition + Enum, // Enumeration + Record // Immutable data carrier +} +``` + +### SemanticRelationship + +Captures relationships with full semantic information: + +```csharp +public sealed class SemanticRelationship +{ + public string SourceEntityId { get; init; } + public string TargetEntityId { get; init; } + public RelationshipType Type { get; init; } // Inheritance, Composition, etc. + public string? SourceMultiplicity { get; set; } + public string? TargetMultiplicity { get; set; } +} +``` + +--- + +## Parser -> Generator Pattern + +All transformations follow the same pattern: + +``` +IModelParser: Input -> SemanticModel +IModelGenerator: SemanticModel -> Output +``` + +### Parser Interface + +```csharp +public interface IModelParser +{ + string FormatName { get; } + IReadOnlyList SupportedExtensions { get; } + + Task ParseAsync( + ParserInput input, + ParserOptions? options = null, + CancellationToken cancellationToken = default); +} +``` + +### Generator Interface + +```csharp +public interface IModelGenerator +{ + string FormatName { get; } + string DefaultExtension { get; } + + Task GenerateAsync( + SemanticModel model, + GeneratorOptions? options = null, + CancellationToken cancellationToken = default); +} +``` + +### Implemented Transformers + +| Component | Parser | Generator | +|-----------|--------|-----------| +| C# | `CSharpModelParser` | `CSharpModelGenerator` | +| Mermaid | `MermaidClassDiagramParser` | `MermaidClassDiagramGenerator` | +| Whiteboard | `WhiteboardScanner` | - | +| OpenAPI | `OpenApiParser` | - | + +--- + +## Transformation Pipelines + +### C# to Mermaid Pipeline + +``` +C# Source File + | + v ++---------------------+ +| CSharpModelParser | (Roslyn analysis) +| - Extract classes | +| - Extract records | +| - Extract enums | +| - Detect DDD types | ++---------------------+ + | + v ++---------------------+ +| SemanticModel | ++---------------------+ + | + v ++------------------------+ +| MermaidClassGenerator | +| - Generate classDiagram| +| - Add stereotypes | +| - Add relationships | ++------------------------+ + | + v +Mermaid .mmd File +``` + +### Whiteboard Scanning Pipeline + +``` ++-------------+ +-------------+ +-------------+ +-------------+ +| Image |---->| Base64 |---->| Claude |---->| Mermaid | +| (JPG/PNG) | | Encode | | Vision API | | Text | ++-------------+ +-------------+ +-------------+ +------+------+ + | + v ++-------------+ +-------------+ +----------------------------------+ +| Semantic |<----| Mermaid |<----| Prompt Engineering | +| Model | | Parser | | - Diagram type detection | ++-------------+ +-------------+ | - Entity/relationship extract | + | - Mermaid syntax generation | + +----------------------------------+ +``` + +**Key Components:** + +- **WhiteboardScanner** (`DocFlow.Vision/WhiteboardScanner.cs`) + - Orchestrates the scanning pipeline + - Handles image loading and format detection + - Manages diagram type detection + - Converts AI output to SemanticModel + +- **ClaudeProvider** (`DocFlow.AI/Providers/ClaudeProvider.cs`) + - Implements `IAiProvider` interface + - Handles Claude API communication + - Supports vision (image analysis) and text completion + - Multi-source API key resolution + +--- + +## Integration Module Architecture + +The Integration module extends the canonical model pattern to enterprise API integrations: + +``` ++-------------------------------------------------------------------------+ +| External API Ecosystem | ++-----------------+-----------------+-----------------+--------------------+ +| OpenAPI 3.x | Swagger 2.0 | GraphQL | JSON Samples | ++--------+--------+--------+--------+--------+--------+---------+----------+ + | | | | + +-----------------+-----------------+------------------+ + | + v + +-------------------------------+ + | Canonical Semantic Model | + | (Same as Code/Diagrams!) | + +---------------+---------------+ + | + +---------------+---------------+ + | CDM Mapper | + | (Multi-pass field matching) | + +---------------+---------------+ + | + v + +-------------------------------+ + | Internal Canonical Model | + | (Your Domain Model) | + +-------------------------------+ + | + +---------------+---------------+ + | Code Generation | + +---------------+---------------+ + | + +-----------------+-----------------+------------------+ + | | | | + v v v v + +-----------+ +------------+ +----------+ +-------------+ + | DTOs | | AutoMapper | | HTTP | | Validators | + | | | Profiles | | Client | | | + +-----------+ +------------+ +----------+ +-------------+ +``` + +### CDM Mapping Algorithm + +The `CdmMapper` uses a multi-pass field matching algorithm: + +1. **Pass 1: Exact Match** (95% confidence) + - Direct name equality (case-insensitive) + +2. **Pass 2: ID Field Match** (85% confidence) + - Source ends with "Id" and target is "Id" or "{Entity}Id" + +3. **Pass 3: Contains Match** (75% confidence) + - Target name contains source name or vice versa + +4. **Pass 4: Foreign Key Pattern** (70% confidence) + - Source follows FK pattern (e.g., "petId" -> "ProductId") + +5. **Pass 5: Date/Time Match** (70% confidence) + - Both fields are date/time types + +### SLA Validation + +The `SlaValidator` checks data freshness: + +```csharp +var report = await slaValidator.ValidateDataFreshnessAsync(new SlaValidationRequest +{ + EndpointUrl = "https://api.example.com/v1/data", + ExpectedMaxAge = TimeSpan.FromSeconds(30), + SampleCount = 100, + SampleInterval = TimeSpan.FromSeconds(5) +}); +``` + +Compliance verdicts: +- **COMPLIANT**: 100% samples within SLA +- **MARGINALLY COMPLIANT**: 90-99% within SLA +- **MINOR VIOLATION**: 50-89% within SLA +- **SEVERE VIOLATION**: <50% within SLA + +### Pre-built Domain Patterns + +The Integration module includes pre-seeded patterns for common domains: + +**Aviation Domain:** +| External Pattern | Canonical Target | Confidence | +|------------------|------------------|------------| +| `tail_num`, `aircraft_id` | TailNumber | 95% | +| `arr_time`, `eta` | ArrivalDateTime | 93% | +| `pax`, `passenger_count` | PassengerCount | 90% | + +--- + +## Intelligent Mapping Service (IMS) + +The IMS (designed, future implementation) learns transformation patterns from examples: + +``` ++-------------------+ +-------------------+ +-------------------+ +| Observed |---->| Pattern |---->| Learned | +| Transformation | | Extraction | | Patterns | ++-------------------+ +-------------------+ +---------+---------+ + | + v ++-------------------+ +-------------------+ +-------------------+ +| Suggestions |<----| Pattern |<----| New Input | +| with Confidence | | Matching | | | ++-------------------+ +-------------------+ +-------------------+ +``` + +### Key Concepts + +- **LearnedPattern**: A transformation pattern with confidence score +- **PatternMatcher**: Applies patterns to new inputs +- **FeedbackLoop**: User corrections improve future suggestions + +--- + +## Project Dependencies + +``` +DocFlow.CLI ++-- DocFlow.Core # Canonical model, abstractions ++-- DocFlow.Diagrams # Mermaid parsing & generation +| +-- DocFlow.Core ++-- DocFlow.CodeAnalysis # Roslyn-based C# parsing +| +-- DocFlow.Core ++-- DocFlow.CodeGen # C# code generation +| +-- DocFlow.Core ++-- DocFlow.Vision # Whiteboard scanning +| +-- DocFlow.Core +| +-- DocFlow.AI ++-- DocFlow.AI # AI provider abstraction +| +-- DocFlow.Core ++-- DocFlow.IMS # Pattern learning +| +-- DocFlow.Core ++-- DocFlow.Ontology # DDD classification +| +-- DocFlow.Core ++-- DocFlow.Integration # API integration +| +-- DocFlow.Core +| +-- DocFlow.IMS +| +-- DocFlow.CodeGen ++-- DocFlow.Documents # Document pipeline (planned) +| +-- DocFlow.Core ++-- DocFlow.Web # Web UI (planned) + +-- DocFlow.Core +``` + +--- + +## Design Principles + +### 1. Semantic Preservation +All transformations preserve meaning. A class in C# should have the same semantic representation whether it came from source code, a Mermaid diagram, or a whiteboard photo. + +### 2. Extensibility +Adding a new format requires only a parser and/or generator. The canonical model stays unchanged. + +### 3. DDD-First +The model understands Domain-Driven Design patterns natively. Aggregates, entities, and value objects are first-class concepts. + +### 4. Async All the Way +All I/O-bound operations are async with CancellationToken support. + +### 5. Nullable Safety +Nullable reference types are enabled throughout. No `NullReferenceException` surprises. + +### 6. Confidence Transparency +All AI-assisted and heuristic-based mappings include confidence scores and reasoning, allowing users to focus on low-confidence areas. + +--- + +## Technology Stack + +| Layer | Technology | +|-------|------------| +| Runtime | .NET 8.0 | +| Language | C# 12 | +| C# Parsing | Microsoft.CodeAnalysis.CSharp (Roslyn) | +| CLI | System.CommandLine + Spectre.Console | +| AI | Anthropic Claude API | +| OpenAPI | Microsoft.OpenApi.Readers | +| Testing | xUnit + FluentAssertions | + +--- + +## File Locations + +| Component | Key Files | +|-----------|-----------| +| Canonical Model | `src/DocFlow.Core/CanonicalModel/` | +| C# Parser | `src/DocFlow.CodeAnalysis/CSharp/CSharpModelParser.cs` | +| C# Generator | `src/DocFlow.CodeGen/CSharp/CSharpModelGenerator.cs` | +| Mermaid Parser | `src/DocFlow.Diagrams/Mermaid/MermaidClassDiagramParser.cs` | +| Mermaid Generator | `src/DocFlow.Diagrams/Mermaid/MermaidClassDiagramGenerator.cs` | +| Whiteboard Scanner | `src/DocFlow.Vision/WhiteboardScanner.cs` | +| Claude Provider | `src/DocFlow.AI/Providers/ClaudeProvider.cs` | +| OpenAPI Parser | `src/DocFlow.Integration/Schemas/OpenApiParser.cs` | +| CDM Mapper | `src/DocFlow.Integration/Mapping/CdmMapper.cs` | +| SLA Validator | `src/DocFlow.Integration/Validation/SlaValidator.cs` | +| Code Generator | `src/DocFlow.Integration/CodeGen/IntegrationCodeGenerator.cs` | +| CLI Entry Point | `src/DocFlow.CLI/Program.cs` | diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.md index 568a10e..44d1e8e 100644 --- a/docs/CHANGELOG.md +++ b/docs/CHANGELOG.md @@ -1,114 +1,161 @@ -# Changelog - -All notable changes to DocFlow will be documented in this file. - -The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), -and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). - -## [0.1.0-preview] - 2025-01-04 - -### Added - -#### Core Pipeline -- **Canonical Semantic Model** - Universal intermediate representation for all transformations -- **SemanticModel** with entities, relationships, and namespaces -- **DDD Classifications** - AggregateRoot, Entity, ValueObject, DomainService, DomainEvent, Repository, Interface, Enum -- **Relationship Types** - Inheritance, Composition, Aggregation, Association, Dependency, Implementation - -#### C# to Mermaid (DocFlow.CodeAnalysis + DocFlow.Diagrams) -- Roslyn-based C# parsing for classes, records, interfaces, enums -- Property extraction with types and visibility modifiers -- Method extraction with parameters and return types -- Inheritance and interface implementation detection -- Composition/aggregation inference from collection properties -- DDD stereotype detection from naming conventions -- Mermaid classDiagram generation with proper syntax - -#### Mermaid to C# (DocFlow.Diagrams + DocFlow.CodeGen) -- Mermaid classDiagram parser with stereotype support -- C# code generator with nullable-enabled output -- Records for ValueObjects, classes for Entities -- XML documentation comment generation -- Proper access modifier mapping (+, -, #) - -#### Round-Trip Support -- Full bidirectional transformation: C# → Mermaid → C# -- Semantic preservation across transformations -- `--compare` flag for diff visualization - -#### Whiteboard Scanner (DocFlow.Vision + DocFlow.AI) -- AI-powered diagram extraction from photos -- Claude Vision API integration (claude-sonnet-4-20250514) -- Diagram type detection with confidence scoring -- Support for JPG, PNG, GIF, WEBP formats -- Context hints for improved accuracy - -#### Claude API Integration (DocFlow.AI) -- `ClaudeProvider` with vision and text completion support -- Multi-source API key resolution: - 1. Environment variable: `ANTHROPIC_API_KEY` - 2. User config: `~/.docflow/config.json` - 3. Project config: `./docflow.json` -- Helpful error messages with configuration instructions - -#### CLI (DocFlow.CLI) -- Professional CLI with System.CommandLine -- Rich output with Spectre.Console (colors, tables, panels) -- ASCII art banner -- Commands: - - `diagram` (alias: `d`) - Generate Mermaid from C# - - `codegen` (alias: `c`) - Generate C# from Mermaid - - `roundtrip` (alias: `r`) - Full round-trip test - - `scan` (alias: `s`) - Whiteboard scanning -- Global options: `--verbose`, `--quiet` - -#### Integration Module (DocFlow.Integration) - Scaffolded -- OpenAPI 3.x parser foundation (`OpenApiParser`) -- CDM mapping engine design (`CdmMapper`) -- SLA validation for data freshness (`SlaValidator`) -- Pre-built aviation domain patterns (`ApiMappingPatterns`) -- Integration specification model (`IntegrationSpec`) - -#### Testing -- 91+ unit tests across 3 test projects -- DocFlow.CodeAnalysis.Tests (20 tests) -- DocFlow.Diagrams.Tests (52 tests) -- DocFlow.CodeGen.Tests (19 tests) - -#### Documentation -- Comprehensive README with feature status -- CLAUDE.md for AI assistant context -- Architecture documentation -- CLI reference -- Integration module design document - -### Technical Details - -- **.NET 8.0** with C# 12 features -- **Nullable reference types** enabled throughout -- **Async/await** with CancellationToken support -- **Records** for immutable types -- **Collection expressions** for clean syntax - -### Dependencies - -- Microsoft.CodeAnalysis.CSharp (Roslyn) - C# parsing -- Spectre.Console - CLI framework -- System.CommandLine - Command parsing -- Microsoft.OpenApi.Readers - OpenAPI parsing -- OpenCvSharp4 - Image preprocessing (Vision) - ---- - -## Unreleased - -### Planned for v0.2.0 -- IMS (Intelligent Mapping Service) pattern learning -- PlantUML support -- Sequence diagram support -- Full Integration module implementation - -### Planned for v0.3.0 -- PDF/Word document pipeline -- VS Code extension -- Web UI (Blazor) +# Changelog + +All notable changes to DocFlow will be documented in this file. + +The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), +and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). + +## [0.1.0-preview] - 2025-01-04 + +### Added + +#### Core Pipeline +- **Canonical Semantic Model** - Universal intermediate representation for all transformations +- **SemanticModel** with entities, relationships, and namespaces +- **DDD Classifications** - AggregateRoot, Entity, ValueObject, DomainService, DomainEvent, Repository, Interface, Enum +- **Relationship Types** - Inheritance, Composition, Aggregation, Association, Dependency, Implementation + +#### C# to Mermaid (DocFlow.CodeAnalysis + DocFlow.Diagrams) +- Roslyn-based C# parsing for classes, records, interfaces, enums +- Property extraction with types and visibility modifiers +- Method extraction with parameters and return types +- Inheritance and interface implementation detection +- Composition/aggregation inference from collection properties +- DDD stereotype detection from naming conventions +- Mermaid classDiagram generation with proper syntax + +#### Mermaid to C# (DocFlow.Diagrams + DocFlow.CodeGen) +- Mermaid classDiagram parser with stereotype support +- C# code generator with nullable-enabled output +- Records for ValueObjects, classes for Entities +- XML documentation comment generation +- Proper access modifier mapping (+, -, #) + +#### Round-Trip Support +- Full bidirectional transformation: C# -> Mermaid -> C# +- Semantic preservation across transformations +- `--compare` flag for diff visualization + +#### Whiteboard Scanner (DocFlow.Vision + DocFlow.AI) +- AI-powered diagram extraction from photos +- Claude Vision API integration (claude-sonnet-4-20250514) +- Diagram type detection with confidence scoring +- Support for JPG, PNG, GIF, WEBP formats +- Context hints for improved accuracy + +#### Claude API Integration (DocFlow.AI) +- `ClaudeProvider` with vision and text completion support +- Multi-source API key resolution: + 1. Environment variable: `ANTHROPIC_API_KEY` + 2. User config: `~/.docflow/config.json` + 3. Project config: `./docflow.json` +- Helpful error messages with configuration instructions + +#### CLI (DocFlow.CLI) +- Professional CLI with System.CommandLine +- Rich output with Spectre.Console (colors, tables, panels, progress bars) +- ASCII art banner +- Commands: + - `diagram` (alias: `d`) - Generate Mermaid from C# + - `codegen` (alias: `c`) - Generate C# from Mermaid + - `roundtrip` (alias: `r`) - Full round-trip test + - `scan` (alias: `s`) - Whiteboard scanning + - `integrate` - API integration commands +- Global options: `--verbose`, `--quiet` + +#### Integration Module (DocFlow.Integration) +Complete API integration automation extending the canonical model: + +**CDM Mapping Analysis** (`docflow integrate analyze`) +- Parse OpenAPI 3.x specifications +- Extract entities, endpoints, parameters +- Multi-pass field matching algorithm: + - Pass 1: Exact name matches (95% confidence) + - Pass 2: ID field matches (85% confidence) + - Pass 3: Contains matches (75% confidence) + - Pass 4: Foreign key patterns (70% confidence) + - Pass 5: Date/time field matches (70% confidence) +- Semantic entity matching (Pet->Product, etc.) +- Confidence scoring with reasoning +- Rich CLI output with color-coded confidence levels +- Threshold filtering + +**SLA Validation** (`docflow integrate sla`) +- Data freshness validation against SLA requirements +- Duration parsing: `30s`, `5m`, `1h`, `500ms` +- Multi-sample collection with configurable intervals +- Live progress display +- Compliance verdicts: + - COMPLIANT (100%) + - MARGINALLY COMPLIANT (90-99%) + - MINOR VIOLATION (50-89%) + - SEVERE VIOLATION (0-49%) +- JSON report export + +**Code Generation** (`docflow integrate generate`) +- External DTOs with `[JsonPropertyName]` attributes +- AutoMapper profiles with: + - Confidence comments for each mapping + - TODO markers for unmapped fields + - Unique enum mapping methods + - No duplicate property mappings +- Typed HTTP client interfaces +- FluentValidation validators with: + - Required field validation + - String length constraints +- Rich CLI output showing generated files + +**Pre-built Patterns** +- Aviation domain patterns (tail_num, arr_time, pax, etc.) +- DateTime conversion patterns +- Identifier patterns (primary key, foreign key) +- Contact patterns (email, phone) +- Audit patterns (created_at, updated_at) + +#### Testing +- 91 unit tests across 3 test projects: + - DocFlow.CodeAnalysis.Tests: 20 tests + - DocFlow.Diagrams.Tests: 52 tests + - DocFlow.CodeGen.Tests: 19 tests + +#### Documentation +- Comprehensive README with feature status +- CLAUDE.md for AI assistant context +- Architecture documentation +- CLI reference with all commands +- Integration module design document +- Sample files for testing: + - `samples/whiteboard-demos/` - Whiteboard examples + - `samples/integration-demos/` - OpenAPI specs and CDM samples + +### Technical Details + +- **.NET 8.0** with C# 12 features +- **12 projects** in solution (all compiling) +- **Nullable reference types** enabled throughout +- **Async/await** with CancellationToken support +- **Records** for immutable types +- **Collection expressions** for clean syntax + +### Dependencies + +- Microsoft.CodeAnalysis.CSharp (Roslyn) - C# parsing +- Spectre.Console - CLI framework +- System.CommandLine - Command parsing +- Microsoft.OpenApi.Readers - OpenAPI parsing +- OpenCvSharp4 - Image preprocessing (Vision) + +--- + +## Unreleased + +### Planned for v0.2.0 +- IMS (Intelligent Mapping Service) pattern learning from examples +- PlantUML support +- Sequence diagram support +- GraphQL schema parsing + +### Planned for v0.3.0 +- PDF/Word document pipeline +- VS Code extension +- Web UI (Blazor) diff --git a/docs/CLI-REFERENCE.md b/docs/CLI-REFERENCE.md index e5682d9..9c820cf 100644 --- a/docs/CLI-REFERENCE.md +++ b/docs/CLI-REFERENCE.md @@ -1,327 +1,547 @@ -# CLI Reference - -Complete documentation for the DocFlow command-line interface. - -## Installation - -```bash -# From source -dotnet run --project src/DocFlow.CLI -- [options] - -# As installed tool -docflow [options] -``` - -## Global Options - -These options are available on all commands: - -| Option | Alias | Description | -|--------|-------|-------------| -| `--verbose` | `-v` | Show detailed output including entity tables and full generated content | -| `--quiet` | `-q` | Minimal output, only errors. Useful for scripting | -| `--help` | `-h`, `-?` | Show help and usage information | - ---- - -## Commands - -### diagram - -Generate a Mermaid class diagram from C# source code. - -**Usage:** -```bash -docflow diagram [options] -docflow d [options] -``` - -**Arguments:** - -| Argument | Description | -|----------|-------------| -| `` | C# source file or directory to parse | - -**Options:** - -| Option | Alias | Description | -|--------|-------|-------------| -| `--output ` | `-o` | Output file path (default: same name with .mmd extension) | -| `--recursive` | `-r` | Process all .cs files in directory recursively | -| `--no-relationships` | | Exclude relationship lines from diagram | - -**Examples:** - -```bash -# Single file -docflow diagram Domain/Order.cs - -# Directory (non-recursive) -docflow diagram Domain/ - -# Directory (recursive) with custom output -docflow diagram src/Domain -r -o architecture.mmd - -# Exclude relationships -docflow diagram Order.cs --no-relationships - -# Verbose output -docflow diagram Order.cs -v -``` - -**Output:** - -- Creates a `.mmd` file with valid Mermaid classDiagram syntax -- Displays entity count and relationship count -- Shows generated Mermaid content (unless `--quiet`) - ---- - -### codegen - -Generate C# code from a Mermaid class diagram. - -**Usage:** -```bash -docflow codegen [options] -docflow c [options] -``` - -**Arguments:** - -| Argument | Description | -|----------|-------------| -| `` | Mermaid diagram file (.mmd) to parse | - -**Options:** - -| Option | Alias | Description | -|--------|-------|-------------| -| `--output ` | `-o` | Output file path (default: same name with .cs extension) | -| `--namespace ` | `-n` | Namespace for generated code (default: derived from filename) | -| `--style