# vinivendra/gryphon architecture

> Architecture diagram of the GitHub repository vinivendra/gryphon, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-07). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/vinivendra/gryphon
- Repository: https://github.com/vinivendra/gryphon

## Overview

Gryphon is a Swift-to-Kotlin command-line transpiler. Its main workflow is to accept source and options, have the driver coordinate compilation, decode Swift syntax into Gryphon’s AST, transform that AST, translate it to Kotlin, and write output. The README also describes Xcode integration and customization through comments and templates. The graph uses indexed references and the shown entry-point calls for relationships; unsampled implementation details are represented by subsystem paths, and optional or undocumented links are omitted.

Main entry points: [`Sources/GryphonLib/Driver.swift`](https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/Driver.swift) (Driver), [`Sources/GryphonLib/Compiler.swift`](https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/Compiler.swift) (Compiler orchestration), [`Sources/GryphonLib/KotlinTranslator.swift`](https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/KotlinTranslator.swift) (Kotlin translator), [`Sources/GryphonLib/TranspilationContext.swift`](https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/TranspilationContext.swift) (Translation context)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["Command line"]
  node_main["CLI entry<br/>[main.swift]"]
  node_driver["Driver<br/>[Driver.swift]"]
end

subgraph group_front["Swift front end"]
  node_compiler["Compiler orchestration<br/>[Compiler.swift]"]
  node_sourcefile["Source files<br/>[SourceFile.swift]"]
  node_decoder["Swift syntax decoder"]
  node_ast["Gryphon AST<br/>[GryphonAST.swift]"]
end

subgraph group_transform["Translation pipeline"]
  node_passes["AST transformation passes"]
  node_librarypass["Library translation pass"]
  node_translator["Kotlin translator"]
  node_result["Kotlin translation result"]
end

subgraph group_support["Translation support"]
  node_context["Translation context"]
  node_auxfiles["Templates and support files"]
  node_swiftlibrary["Swift library mappings"]
  node_utilities["File utilities<br/>[Utilities.swift]"]
  node_shell["Shell commands<br/>[Shell.swift]"]
  node_tree["AST tree printing"]
end

node_user(("CLI user"))
node_swift["Swift source"]
node_output["Kotlin output"]
node_xcode["Xcode project"]

node_user -->|"invokes"| node_main
node_main -->|"runs"| node_driver
node_driver -->|"coordinates"| node_compiler
node_driver -->|"writes files"| node_utilities
node_driver -->|"runs commands"| node_shell
node_swift -.->|"provides input"| node_driver
node_xcode -.->|"integrates with"| node_driver
node_compiler -->|"reads source"| node_sourcefile
node_compiler -->|"creates decoder"| node_decoder
node_decoder -->|"reads source"| node_sourcefile
node_decoder -->|"builds"| node_ast
node_compiler -->|"runs passes"| node_passes
node_passes -->|"transforms"| node_ast
node_passes -->|"records translations"| node_context
node_compiler -->|"translates AST"| node_translator
node_translator -->|"reads"| node_ast
node_translator -->|"uses settings"| node_context
node_translator -.->|"produces"| node_result
node_driver -->|"writes Kotlin"| node_output
node_compiler -->|"references"| node_librarypass
node_context -->|"queries SDK"| node_shell
node_context -->|"loads templates"| node_auxfiles
node_translator -.->|"uses mappings"| node_swiftlibrary
node_compiler -->|"formats diagnostics"| node_tree
node_driver -->|"configures"| node_context
node_user -.->|"customizes translation"| node_auxfiles

click node_main "https://github.com/vinivendra/gryphon/blob/release/Sources/Gryphon/main.swift"
click node_driver "https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/Driver.swift"
click node_compiler "https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/Compiler.swift"
click node_sourcefile "https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/SourceFile.swift"
click node_decoder "https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/SwiftSyntaxDecoder.swift"
click node_ast "https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/GryphonAST.swift"
click node_passes "https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/TranspilationPass.swift"
click node_librarypass "https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/LibraryTranspilationPass.swift"
click node_translator "https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/KotlinTranslator.swift"
click node_result "https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/KotlinTranslationResult.swift"
click node_context "https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/TranspilationContext.swift"
click node_auxfiles "https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/AuxiliaryFileContents.swift"
click node_swiftlibrary "https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/GryphonSwiftLibrary.swift"
click node_utilities "https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/Utilities.swift"
click node_shell "https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/Shell.swift"
click node_tree "https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/PrintableAsTree.swift"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_driver,node_user toneBlue
class node_compiler,node_sourcefile,node_decoder,node_ast toneAmber
class node_passes,node_librarypass,node_translator,node_result toneMint
class node_context,node_auxfiles,node_swiftlibrary,node_utilities,node_shell,node_tree toneRose
class node_swift,node_output,node_xcode toneIndigo
```

## Components

### Command line

- [CLI entry](https://github.com/vinivendra/gryphon/blob/release/Sources/Gryphon/main.swift): `Sources/Gryphon/main.swift`
- [Driver](https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/Driver.swift): `Sources/GryphonLib/Driver.swift`

### Swift front end

- [Compiler orchestration](https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/Compiler.swift): `Sources/GryphonLib/Compiler.swift`
- [Source files](https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/SourceFile.swift): `Sources/GryphonLib/SourceFile.swift`
- [Swift syntax decoder](https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/SwiftSyntaxDecoder.swift): `Sources/GryphonLib/SwiftSyntaxDecoder.swift`
- [Gryphon AST](https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/GryphonAST.swift): `Sources/GryphonLib/GryphonAST.swift`

### Translation pipeline

- [AST transformation passes](https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/TranspilationPass.swift): `Sources/GryphonLib/TranspilationPass.swift`
- [Library translation pass](https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/LibraryTranspilationPass.swift): `Sources/GryphonLib/LibraryTranspilationPass.swift`
- [Kotlin translator](https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/KotlinTranslator.swift): `Sources/GryphonLib/KotlinTranslator.swift`
- [Kotlin translation result](https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/KotlinTranslationResult.swift): `Sources/GryphonLib/KotlinTranslationResult.swift`

### Translation support

- [Translation context](https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/TranspilationContext.swift): `Sources/GryphonLib/TranspilationContext.swift`
- [Templates and support files](https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/AuxiliaryFileContents.swift): `Sources/GryphonLib/AuxiliaryFileContents.swift`
- [Swift library mappings](https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/GryphonSwiftLibrary.swift): `Sources/GryphonLib/GryphonSwiftLibrary.swift`
- [File utilities](https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/Utilities.swift): `Sources/GryphonLib/Utilities.swift`
- [Shell commands](https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/Shell.swift): `Sources/GryphonLib/Shell.swift`
- [AST tree printing](https://github.com/vinivendra/gryphon/blob/release/Sources/GryphonLib/PrintableAsTree.swift): `Sources/GryphonLib/PrintableAsTree.swift`

### Other components

- **CLI user**
- **Swift source**
- **Kotlin output**
- **Xcode project**

## Connections

- CLI user → CLI entry: invokes (evidence: `Sources/Gryphon/main.swift`)
- CLI entry → Driver: runs (evidence: `Sources/Gryphon/main.swift`)
- Driver → Compiler orchestration: coordinates (evidence: `Sources/GryphonLib/Driver.swift`)
- Driver → File utilities: writes files (evidence: `Sources/GryphonLib/Driver.swift`)
- Driver → Shell commands: runs commands (evidence: `Sources/GryphonLib/Driver.swift`)
- Swift source → Driver: provides input (evidence: `README.md`)
- Xcode project → Driver: integrates with (evidence: `README.md`)
- Compiler orchestration → Source files: reads source (evidence: `Sources/GryphonLib/Compiler.swift`)
- Compiler orchestration → Swift syntax decoder: creates decoder (evidence: `Sources/GryphonLib/Compiler.swift`)
- Swift syntax decoder → Source files: reads source (evidence: `Sources/GryphonLib/SwiftSyntaxDecoder.swift`)
- Swift syntax decoder → Gryphon AST: builds (evidence: `Sources/GryphonLib/Compiler.swift`)
- Compiler orchestration → AST transformation passes: runs passes (evidence: `Sources/GryphonLib/Compiler.swift`)
- AST transformation passes → Gryphon AST: transforms (evidence: `Sources/GryphonLib/TranspilationPass.swift`)
- AST transformation passes → Translation context: records translations (evidence: `Sources/GryphonLib/TranspilationPass.swift`)
- Compiler orchestration → Kotlin translator: translates AST (evidence: `Sources/GryphonLib/Compiler.swift`)
- Kotlin translator → Gryphon AST: reads (evidence: `Sources/GryphonLib/KotlinTranslator.swift`)
- Kotlin translator → Translation context: uses settings (evidence: `Sources/GryphonLib/KotlinTranslator.swift`)
- Kotlin translator → Kotlin translation result: produces
- Driver → Kotlin output: writes Kotlin (evidence: `Sources/GryphonLib/Driver.swift`)
- Compiler orchestration → Library translation pass: references (evidence: `Sources/GryphonLib/Compiler.swift`)
- Translation context → Shell commands: queries SDK (evidence: `Sources/GryphonLib/TranspilationContext.swift`)
- Translation context → Templates and support files: loads templates (evidence: `Sources/GryphonLib/TranspilationContext.swift`)
- Kotlin translator → Swift library mappings: uses mappings
- Compiler orchestration → AST tree printing: formats diagnostics (evidence: `Sources/GryphonLib/Compiler.swift`)
- Driver → Translation context: configures (evidence: `Sources/GryphonLib/Driver.swift`)
- CLI user → Templates and support files: customizes translation (evidence: `README.md`)
