# yangmi-shin/swift-depends architecture

> Architecture diagram of the GitHub repository yangmi-shin/swift-depends, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-01-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/yangmi-shin/swift-depends
- Repository: https://github.com/yangmi-shin/swift-depends

## Overview

##### Main Components

a) Input Processing Layer:
- Configuration Handler (swift-depends.config)
- Source File List Handler
- Command-Line Interface (SwiftDependsCLI)

b) Core Processing Layer:
- AST Generation Pipeline
- Swift Frontend Integration
- SIL (Swift Intermediate Language) Processing
- AST Generation Components

c) Analysis Layer:
- Parser Components
- Dependency Extraction
- Component Management

d) Output Generation Layer:
- Repository Handlers (JSON, Lattix)
- Result Formatters

##### Architectural Pattern
The project follows a clean architecture pattern with clear separation of concerns:

- Presentation Layer (CLI)
- Application Layer (Services)
- Domain Layer (Core Business Logic)
- Infrastructure Layer (Implementation Details)

**[Input] → [Processing] → [Analysis] → [Output]**
- ↓           ↓            ↓           ↓
**[Config]  [AST Generator] [Parser]   [Repositories]**

**[CLI]     [SIL Process]  [Dependency] [Formatters]**

##### Component Relationships

- Command flow: CLI → Application Service → Domain Components
- Data flow: Source Files → AST Generator → Parser → Repository
- Dependency relationships between components

##### Key Elements to Highlight

- Configuration management
- Swift frontend integration
- AST processing pipeline
- Dependency analysis logic
- Output generation system

**[Presentation Layer]**
- ↓
**[Application Layer]**
- ↓
**[Domain Layer]**
- ↓
**[Infrastructure Layer]**

Each layer should show its main components and their interactions. Use standard UML notation where appropriate, but focus on clarity and readability over strict UML compliance.

Remember to include:
- Component names from the actual codebase
- Interaction patterns between components
- Data flow directions
- Key external dependencies
- Configuration points

## Diagram (Mermaid)

```mermaid
graph TB
    %% Styles
    classDef presentation fill:#B3E0FF,stroke:#333,stroke-width:2px
    classDef application fill:#B8FFB8,stroke:#333,stroke-width:2px
    classDef domain fill:#FFB3B3,stroke:#333,stroke-width:2px
    classDef infrastructure fill:#E6E6E6,stroke:#333,stroke-width:2px
    
    subgraph Presentation
        CLI["Command-Line Interface"]:::presentation
    end
    
    subgraph Application
        AppService["Application Service"]:::application
        IAppService["ISwiftDependsApplicationService"]:::application
    end
    
    subgraph Domain
        ASTGen["AST Generator"]:::domain
        ASTParser["AST Parser"]:::domain
        CompFactory["Component Factory"]:::domain
        CompRepo["Component Repository"]:::domain
        
        subgraph DomainModels
            Component["Component"]:::domain
            Dependency["Dependency"]:::domain
            Module["Module"]:::domain
        end
    end
    
    subgraph Infrastructure
        SwiftASTGen["Swift AST Generator"]:::infrastructure
        SwiftASTParser["Swift AST Parser"]:::infrastructure
        
        subgraph Parser
            ASTExtractor["AST Extractor"]:::infrastructure
            DependencyExtractor["Dependency Extractor"]:::infrastructure
            ExtCompManager["External Component Manager"]:::infrastructure
        end
        
        subgraph ASTNodes
            CompNode["AST Component Node"]:::infrastructure
            MapNode["AST Map Node"]:::infrastructure
            MapTree["AST Map Tree"]:::infrastructure
        end
        
        subgraph Output
            JsonRepo["JSON Repository"]:::infrastructure
            LattixRepo["Lattix Repository"]:::infrastructure
        end
        
        XcConfig["XC Config Extractor"]:::infrastructure
    end
    
    %% Relationships
    CLI --> AppService
    AppService --> IAppService
    AppService --> ASTGen
    ASTGen --> SwiftASTGen
    SwiftASTGen --> ASTParser
    ASTParser --> SwiftASTParser
    SwiftASTParser --> ASTExtractor
    ASTExtractor --> DependencyExtractor
    DependencyExtractor --> ExtCompManager
    SwiftASTParser --> CompNode
    CompNode --> MapNode
    MapNode --> MapTree
    ExtCompManager --> CompFactory
    CompFactory --> CompRepo
    CompRepo --> JsonRepo
    CompRepo --> LattixRepo
    XcConfig --> SwiftASTGen
    
    %% Click Events
    click CLI "https://github.com/yangmi-shin/swift-depends/blob/main/src/main/java/com/lge/swiftdepends/presentation/SwiftDependsCLI.java"
    click IAppService "https://github.com/yangmi-shin/swift-depends/blob/main/src/main/java/com/lge/swiftdepends/application/ISwiftDependsApplicationService.java"
    click AppService "https://github.com/yangmi-shin/swift-depends/blob/main/src/main/java/com/lge/swiftdepends/application/SwiftDependsApplicationService.java"
    click ASTGen "https://github.com/yangmi-shin/swift-depends/blob/main/src/main/java/com/lge/swiftdepends/domain/ASTGenerator.java"
    click SwiftASTGen "https://github.com/yangmi-shin/swift-depends/blob/main/src/main/java/com/lge/swiftdepends/infrastructure/generator/SwiftASTGenerator.java"
    click ASTParser "https://github.com/yangmi-shin/swift-depends/blob/main/src/main/java/com/lge/swiftdepends/domain/ASTParser.java"
    click SwiftASTParser "https://github.com/yangmi-shin/swift-depends/blob/main/src/main/java/com/lge/swiftdepends/infrastructure/parser/SwiftASTParser.java"
    click ASTExtractor "https://github.com/yangmi-shin/swift-depends/blob/main/src/main/java/com/lge/swiftdepends/infrastructure/parser/extractor/ASTExtractor.java"
    click DependencyExtractor "https://github.com/yangmi-shin/swift-depends/tree/main/src/main/java/com/lge/swiftdepends/infrastructure/parser/dependency/"
    click CompFactory "https://github.com/yangmi-shin/swift-depends/blob/main/src/main/java/com/lge/swiftdepends/domain/ComponentFactory.java"
    click CompRepo "https://github.com/yangmi-shin/swift-depends/blob/main/src/main/java/com/lge/swiftdepends/domain/ComponentRepository.java"
    click ExtCompManager "https://github.com/yangmi-shin/swift-depends/blob/main/src/main/java/com/lge/swiftdepends/infrastructure/parser/dependency/ExternalComponentManager.java"
    click JsonRepo "https://github.com/yangmi-shin/swift-depends/blob/main/src/main/java/com/lge/swiftdepends/infrastructure/persistence/JsonRepository.java"
    click LattixRepo "https://github.com/yangmi-shin/swift-depends/blob/main/src/main/java/com/lge/swiftdepends/infrastructure/persistence/LattixRepository.java"
    click Component "https://github.com/yangmi-shin/swift-depends/blob/main/src/main/java/com/lge/swiftdepends/domain/Component.java"
    click Dependency "https://github.com/yangmi-shin/swift-depends/blob/main/src/main/java/com/lge/swiftdepends/domain/Dependency.java"
    click Module "https://github.com/yangmi-shin/swift-depends/blob/main/src/main/java/com/lge/swiftdepends/domain/Module.java"
    click XcConfig "https://github.com/yangmi-shin/swift-depends/blob/main/src/main/java/com/lge/swiftdepends/infrastructure/generator/XcConfigExtractor.java"
    click CompNode "https://github.com/yangmi-shin/swift-depends/blob/main/src/main/java/com/lge/swiftdepends/infrastructure/parser/node/ASTComponentNode.java"
    click MapNode "https://github.com/yangmi-shin/swift-depends/blob/main/src/main/java/com/lge/swiftdepends/infrastructure/parser/node/ASTMapNode.java"
    click MapTree "https://github.com/yangmi-shin/swift-depends/blob/main/src/main/java/com/lge/swiftdepends/infrastructure/parser/node/ASTMapTree.java"
```
