How microsoft/kiota works
Main components
• Core Libraries (blue):
– Kiota.Builder (C#): the heart of the code generator. It contains:
• CodeDOM model (CodeElement, CodeClass, etc.)
• Generation logic (KiotaBuilder, KiotaSearcher)
• Language-specific CodeRenderers (TypeScript, CSharp, Java, Go, Python, etc.)
– Abstractions (folder “abstractions” and “authentication”): a common HTTP & serialization abstraction layer and authentication providers.
– HTTP/Serialization (folders “http” and “serialization”): HTTP transport, format serializers (JSON, multipart, text, form).
– SearchProviders: modules to fetch OpenAPI specs (GitHub, APIsGuru, OpenApiSpec).
– Plugin system: PluginsGenerationService, plugin walkers, plugin auth.
• CLI / Host (green):
– CLI Host (“src/kiota”): Program.cs, command handlers (AddHandler, GenerateHandler, SearchHandler, etc.), configuration extensions, RPC server (Rpc folder).
– Telemetry (AppInsights/OpenTelemetry): TelemetryConfig, Instrumentation.
– Kiota.Generated: small project to generate version and settings at build time.
– Dockerfile, CI pipelines: build & release orchestration.
• Editor & Language Integrations (orange):
– VS Code Extension (“vscode/microsoft-kiota”): TypeScript extension invoking the CLI over RPC or child‐process, deepLink, handlers, tree providers.
– NPM wrapper (“vscode/npm-package”): TS library that shells out to the Kiota CLI, exposes JS API for generateClient, searchDescription, migrate, updateClients, etc.
– IntelliJ Plugin (“intellij”): Java plugin using KiotaGenerationLanguage and GenerateClientHandler to integrate code generation into IntelliJ.
– Other “it” test harnesses for C#, Java, Go, Dart, Python, Ruby, TS.
Relationships and data flows
– User or IDE issues a command (VS Code command palette, IntelliJ menu, or NPM JS call).
– The integration invokes the Kiota CLI Host via:
• RPC channel (WebSocket/IPC) or
• Child‐process CLI (dotnet kiota.exe).
– CLI Host parses command → routes to a specific CommandHandler.
– Handler uses:
• SearchProviders to locate or download the OpenAPI description.
• Abstractions + HTTP libs to fetch or validate the spec.
• Kiota.Builder to build a CodeDOM and generate code:
– KiotaBuilder orchestrates parsing, refinement (Refiners), rendering (CodeRenderers).
– The generated code is written via Writers modules to the target language directory.
– Plugin system may augment generation or post‐process output.
– Telemetry events are sent to AppInsights/OpenTelemetry.
Architectural patterns & principles
– Layered Architecture: separation of core code-generation logic, host orchestration, and client integrations.
– Plugin/Handler Pattern: command handlers decouple CLI verbs from implementation; PluginsGenerationService decouples extension points.
– Strategy Pattern: language-specific writers (ICodeElementWriter + ConventionService) plugged into Kiota.Builder.
– Dependency Inversion: abstractions for HTTP, serialization, authentication, search providers.
– RPC & IPC: supports editor extensions without embedding C#.
Final checklist
– Clearly separate layers.
– Annotate key framework/technology (C#, dotnet CLI, TypeScript, Java, HTTP clients, RPC).
– Capture essential modules: SearchProviders, Abstractions, Kiota.Builder, Command Handlers, CodeRenderers, Writers, Plugins, Telemetry, Integrations.
– Keep it detailed enough to see extension points and module boundaries but simple enough to read at a glance.