# dragee-io/dragee-cli architecture

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

- Interactive diagram: https://gitdiagram.com/dragee-io/dragee-cli
- Repository: https://github.com/dragee-io/dragee-cli

## Overview

##### Main Components Identification

a) CLI Interface Layer
- Entry point (index.ts)
- Command Handlers (src/commands/*)
- Configuration (src/cli.config.ts)

b) Core Services
- Dragee Lookup Service (src/dragee-lookup.ts)
- Namespace Lookup Service (src/namespace-lookup.ts)

c) Command Processing Units
- Report Generation
- Graph Drawing
- Registry Management
- Asserter/Grapher Generation

**Top Layer: CLI Interface**
**Middle Layer: Command Processors**
**Bottom Layer: Core Services**

##### Specific Components

- CLI Entry Point (Main Controller)
- Command Handlers:
- Report Command Handler
- Clear Registry Command Handler
- Generate Asserter Command Handler
- Generate Grapher Command Handler
- Core Services:
- Dragee Lookup Service
- Namespace Lookup Service

##### Data Flow Representation

Following flows:
- Input flow: Command line arguments → Command Handlers
- Processing flow: Command Handlers → Core Services
- Output flow: Core Services → File System (for report/graph generation)

##### Additional Elements

Include:
- Input/Output file formats (JSON)
- Directory interactions (--from-dir, --to-dir)

##### Important Notes

- Command-based architecture
- Relationship between commands and their handlers
- How the lookup services support the command operations
- File system interaction points
- Test structure relationship (for validation)

##### Technical Details

- Bun runtime environment
- TypeScript implementation
- JSON configuration handling
- File system operations
- Test coverage relationship

Remember to include:
- Version information
- Runtime environment (Bun)
- Configuration files (biome.json, tsconfig.json)
- Test structure relationship

This architecture should clearly show how the tool processes commands and interacts with the dragee ecosystem while maintaining a clean separation of concerns between the CLI interface, command processing, and core services.

## Diagram (Mermaid)

```mermaid
flowchart TB
    subgraph CLI
        Entry["CLI Entry Point"]
        Config["CLI Configuration"]
        
        Entry --> Config
    end

    subgraph CommandHandlers
        Report["Report Command Handler"]
        Draw["Draw Command Handler"]
        Clear["Clear Registry Command Handler"]
        GenAssert["Generate Asserter Handler"]
        GenGraph["Generate Grapher Handler"]
    end

    subgraph CoreServices
        DrageeService["Dragee Lookup Service"]
        NamespaceService["Namespace Lookup Service"]
    end

    subgraph Testing
        ReportTest["Report Tests"]
        DrawTest["Draw Tests"]
        ClearTest["Clear Registry Tests"]
        DrageeTest["Dragee Lookup Tests"]
        SampleData["Sample Data"]
        ExpectedResults["Expected Results"]
    end

    subgraph Configuration
        TSConfig["TypeScript Config"]
        BiomeConfig["Code Style Config"]
    end

    %% CLI to Command Handlers
    Entry --> Report
    Entry --> Draw
    Entry --> Clear
    Entry --> GenAssert
    Entry --> GenGraph

    %% Command Handlers to Services
    Report --> DrageeService
    Report --> NamespaceService
    Draw --> DrageeService
    Draw --> NamespaceService
    Clear --> DrageeService
    GenAssert --> DrageeService
    GenGraph --> DrageeService

    %% Test Relationships
    Report -.-> ReportTest
    Draw -.-> DrawTest
    Clear -.-> ClearTest
    DrageeService -.-> DrageeTest
    ReportTest -.-> SampleData
    DrawTest -.-> SampleData
    ClearTest -.-> SampleData
    ReportTest -.-> ExpectedResults
    DrawTest -.-> ExpectedResults
    ClearTest -.-> ExpectedResults

    %% Click Events
    click Entry "https://github.com/dragee-io/dragee-cli/blob/main/index.ts"
    click Config "https://github.com/dragee-io/dragee-cli/blob/main/src/cli.config.ts"
    click Report "https://github.com/dragee-io/dragee-cli/blob/main/src/commands/report-command.handler.ts"
    click Draw "https://github.com/dragee-io/dragee-cli/blob/main/src/commands/draw-command.handler.ts"
    click Clear "https://github.com/dragee-io/dragee-cli/blob/main/src/commands/clear-registry-command.handler.ts"
    click DrageeService "https://github.com/dragee-io/dragee-cli/blob/main/src/dragee-lookup.ts"
    click NamespaceService "https://github.com/dragee-io/dragee-cli/blob/main/src/namespace-lookup.ts"
    click ReportTest "https://github.com/dragee-io/dragee-cli/blob/main/test/report-command.spec.ts"
    click DrawTest "https://github.com/dragee-io/dragee-cli/blob/main/test/draw-command.spec.ts"
    click ClearTest "https://github.com/dragee-io/dragee-cli/blob/main/test/clear-registry-command.spec.ts"
    click DrageeTest "https://github.com/dragee-io/dragee-cli/blob/main/test/dragee-lookup.spec.ts"
    click SampleData "https://github.com/dragee-io/dragee-cli/tree/main/test/approval/sample"
    click ExpectedResults "https://github.com/dragee-io/dragee-cli/tree/main/test/approval/expected-result"
    click TSConfig "https://github.com/dragee-io/dragee-cli/blob/main/tsconfig.json"
    click BiomeConfig "https://github.com/dragee-io/dragee-cli/blob/main/biome.json"

    classDef cli fill:#2196F3,stroke:#1565C0,color:white
    classDef handler fill:#4CAF50,stroke:#388E3C,color:white
    classDef service fill:#FFC107,stroke:#FFA000,color:black
    classDef test fill:#9E9E9E,stroke:#616161,color:white
    classDef config fill:#607D8B,stroke:#455A64,color:white

    class Entry,Config cli
    class Report,Draw,Clear,GenAssert,GenGraph handler
    class DrageeService,NamespaceService service
    class ReportTest,DrawTest,ClearTest,DrageeTest,SampleData,ExpectedResults test
    class TSConfig,BiomeConfig config
```
