# tienld-0801/tilokit architecture

> Architecture diagram of the GitHub repository tienld-0801/tilokit, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-06). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/tienld-0801/tilokit
- Repository: https://github.com/tienld-0801/tilokit

## Overview

##### Project type and purpose
- TiLoKit is a Go-based CLI tool for bootstrapping multi-language, multi-framework projects.
- It exposes commands (via cmd/root.go and internal/cli) that invoke a central engine to discover plugins (builders, frameworks, tools, templates) and generate project scaffolds.

##### File structure
- Top-level:
- cmd/ + main.go → entrypoint, Cobra-style command definitions
- internal/cli → CLI parsing, handlers, “manager” coordinating commands
- internal/core → context (app state), engine (orchestrator), registry (plugin lookup)
- internal/plugins → plugin subpackages by category (builders, frameworks, templates, tools)
- internal/utils → filesystem helpers, common utilities
- config → YAML defaults
- templates → static template files per language/framework
- Dockerfile, Makefile, scripts → build/release pipeline
- Patterns: plugin architecture using a Registry, separation of concerns between CLI, core, plugins, and I/O layers.

##### Key README insights
- Plugin-based, extensible design
- Interactive mode and direct CLI commands
- Planned config and plugin ecosystems
- Multi-framework support via discrete plugin packages

##### Core components
a. CLI Layer
- cmd package (root.go, subcommands)
- internal/cli (handlers, manager)
b. Core Engine Layer
- Context (application state, options)
- Engine (invokes generation flow)
- Registry (discovers and returns plugin instances)
c. Plugin Subsystem
- Builders (rollup, vite, webpack)
- Frameworks (react, vue, go, python, etc.)
- Templates (generic template logic)
- Tools (git, package managers)
d. Resources & I/O
- Templates directory (language/framework templates)
- File system (writes generated code)
- External tools (Git init, package installs)
e. Configuration
- YAML config loader (config/tilokit.yaml)
- Environment variables (.env)

##### Relationships and interactions
1. User invokes “tilokit” CLI → cmd.Root executes
2. CLI Layer parses flags/args → builds Context
3. CLI Manager calls Engine.Generate(context)
4. Engine queries Registry for selected plugins (framework + builder + tools)
5. Plugins apply templates, emit files via utils.FileWrite
6. If requested, Tool plugins invoke external binaries (git, npm, pip)
7. Generation complete → output summary to user

##### Architectural patterns & design principles
- Plugin Architecture / Inversion of Control (Registry injects plugins at runtime)
- Layered separation: Presentation (CLI) → Application (Engine) → Plugins → I/O
- Single binary deployment (Go static compile)
- Use of a Context object to carry options and state

##### Technologies, frameworks, libraries
- Go modules, Cobra (or similar CLI framework)
- YAML config parsing (e.g., go-yaml)
- Standard library for file I/O

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User
    User["User Terminal"]:::external

    %% CLI Layer
    subgraph "CLI Layer"
        direction TB
        RootCmd["Root Command"]:::cli
        CobraCmds["Cobra Commands\n(cmd/)"]:::cli
        CLIManager["CLI Handlers & Manager"]:::cli
    end

    %% Core Engine Layer
    subgraph "Core Engine Layer"
        direction TB
        Context["Context"]:::core
        Engine["Engine"]:::core
        Registry["Registry"]:::core
    end

    %% Configuration
    subgraph "Configuration"
        direction TB
        YAMLConfig["YAML Defaults"]:::io
        GoConfig["Go Config Package"]:::core
    end

    %% Plugin Subsystem
    subgraph "Plugin Subsystem"
        direction TB
        subgraph "Builders"
            direction TB
            Rollup["Rollup Plugin"]:::plugin
            Vite["Vite Plugin"]:::plugin
            Webpack["Webpack Plugin"]:::plugin
        end
        subgraph "Frameworks"
            direction TB
            React["React"]:::plugin
            Vue["Vue"]:::plugin
            GoLang["Go"]:::plugin
            Python["Python"]:::plugin
            Java["Java"]:::plugin
            CSharp["C#"]:::plugin
            Desktop["Desktop"]:::plugin
            Mobile["Mobile"]:::plugin
            NodeJS["Node.js"]:::plugin
            PHP["PHP"]:::plugin
            Ruby["Ruby"]:::plugin
            Rust["Rust"]:::plugin
        end
        TemplatesPlugin["Templates Logic"]:::plugin
        ToolsPlugin["Git Tool Plugin"]:::plugin
    end

    %% Resources & I/O
    subgraph "Resources & I/O"
        direction TB
        TemplatesFS["Templates FS"]:::io
        FileIO["File Utilities"]:::io
        ExternalCmds["External Tools\n(Git, NPM, Pip)"]:::io
        Generated["Generated Project"]:::io
    end

    %% Connections
    User -->|"invoke CLI"| RootCmd
    RootCmd -->|"uses commands in"| CobraCmds
    CobraCmds -->|"calls"| CLIManager
    CLIManager -->|"builds Context"| Context
    CLIManager -->|"calls Generate() on"| Engine
    Engine -->|"loads config from"| YAMLConfig
    Engine -->|"uses loader"| GoConfig
    Engine -->|"queries"| Registry
    Registry -->|"discovers"| Rollup
    Registry -->|"discovers"| Vite
    Registry -->|"discovers"| Webpack
    Registry -->|"discovers"| React
    Registry -->|"discovers"| Vue
    Registry -->|"discovers"| GoLang
    Registry -->|"discovers"| Python
    Registry -->|"discovers"| Java
    Registry -->|"discovers"| CSharp
    Registry -->|"discovers"| Desktop
    Registry -->|"discovers"| Mobile
    Registry -->|"discovers"| NodeJS
    Registry -->|"discovers"| PHP
    Registry -->|"discovers"| Ruby
    Registry -->|"discovers"| Rust
    Registry -->|"discovers"| TemplatesPlugin
    Registry -->|"discovers"| ToolsPlugin
    TemplatesPlugin -->|"reads templates from"| TemplatesFS
    Rollup -->|"writes files via"| FileIO
    Vite -->|"writes files via"| FileIO
    Webpack -->|"writes files via"| FileIO
    React -->|"writes files via"| FileIO
    Vue -->|"writes files via"| FileIO
    GoLang -->|"writes files via"| FileIO
    Python -->|"writes files via"| FileIO
    Java -->|"writes files via"| FileIO
    CSharp -->|"writes files via"| FileIO
    Desktop -->|"writes files via"| FileIO
    Mobile -->|"writes files via"| FileIO
    NodeJS -->|"writes files via"| FileIO
    PHP -->|"writes files via"| FileIO
    Ruby -->|"writes files via"| FileIO
    Rust -->|"writes files via"| FileIO
    ToolsPlugin -->|"executes"| ExternalCmds
    FileIO -->|"outputs"| Generated
    ExternalCmds -->|"augments"| Generated

    %% Click Events
    click RootCmd "https://github.com/tienld-0801/tilokit/blob/develop/cmd/root.go"
    click CobraCmds "https://github.com/tienld-0801/tilokit/tree/develop/cmd/"
    click CLIManager "https://github.com/tienld-0801/tilokit/blob/develop/internal/cli/handlers.go"
    click CLIManager "https://github.com/tienld-0801/tilokit/blob/develop/internal/cli/manager.go"
    click CLIManager "https://github.com/tienld-0801/tilokit/blob/develop/internal/cli/project.go"
    click CLIManager "https://github.com/tienld-0801/tilokit/blob/develop/internal/cli/update.go"
    click CLIManager "https://github.com/tienld-0801/tilokit/blob/develop/internal/cli/validation.go"
    click CLIManager "https://github.com/tienld-0801/tilokit/blob/develop/internal/cli/constants.go"
    click Context "https://github.com/tienld-0801/tilokit/blob/develop/internal/core/context/context.go"
    click Engine "https://github.com/tienld-0801/tilokit/blob/develop/internal/core/engine/engine.go"
    click Registry "https://github.com/tienld-0801/tilokit/blob/develop/internal/core/registry/registry.go"
    click YAMLConfig "https://github.com/tienld-0801/tilokit/blob/develop/config/tilokit.yaml"
    click GoConfig "https://github.com/tienld-0801/tilokit/blob/develop/internal/config/config.go"
    click Rollup "https://github.com/tienld-0801/tilokit/blob/develop/internal/plugins/builders/rollup.go"
    click Vite "https://github.com/tienld-0801/tilokit/blob/develop/internal/plugins/builders/vite.go"
    click Webpack "https://github.com/tienld-0801/tilokit/blob/develop/internal/plugins/builders/webpack.go"
    click React "https://github.com/tienld-0801/tilokit/blob/develop/internal/plugins/frameworks/react.go"
    click Vue "https://github.com/tienld-0801/tilokit/blob/develop/internal/plugins/frameworks/vue.go"
    click GoLang "https://github.com/tienld-0801/tilokit/blob/develop/internal/plugins/frameworks/golang.go"
    click Python "https://github.com/tienld-0801/tilokit/blob/develop/internal/plugins/frameworks/python.go"
    click Java "https://github.com/tienld-0801/tilokit/blob/develop/internal/plugins/frameworks/java.go"
    click CSharp "https://github.com/tienld-0801/tilokit/blob/develop/internal/plugins/frameworks/csharp.go"
    click Desktop "https://github.com/tienld-0801/tilokit/blob/develop/internal/plugins/frameworks/desktop.go"
    click Mobile "https://github.com/tienld-0801/tilokit/blob/develop/internal/plugins/frameworks/mobile.go"
    click NodeJS "https://github.com/tienld-0801/tilokit/blob/develop/internal/plugins/frameworks/nodejs.go"
    click PHP "https://github.com/tienld-0801/tilokit/blob/develop/internal/plugins/frameworks/php.go"
    click Ruby "https://github.com/tienld-0801/tilokit/blob/develop/internal/plugins/frameworks/ruby.go"
    click Rust "https://github.com/tienld-0801/tilokit/blob/develop/internal/plugins/frameworks/rust.go"
    click TemplatesPlugin "https://github.com/tienld-0801/tilokit/blob/develop/internal/plugins/templates/template.go"
    click ToolsPlugin "https://github.com/tienld-0801/tilokit/blob/develop/internal/plugins/tools/git.go"
    click TemplatesFS "https://github.com/tienld-0801/tilokit/tree/develop/templates/"
    click FileIO "https://github.com/tienld-0801/tilokit/blob/develop/internal/utils/file.go"
    click FileIO "https://github.com/tienld-0801/tilokit/blob/develop/internal/utils/helpers.go"
    click Generated "https://github.com/tienld-0801/tilokit/blob/develop/main.go"

    %% Styles
    classDef cli fill:#cfe2f3,stroke:#3b70af,color:#0b2e61
    classDef core fill:#d5e8d4,stroke:#82b366,color:#345d23
    classDef plugin fill:#ffe6cc,stroke:#f5a623,color:#974f0c
    classDef io fill:#eeeeee,stroke:#999999,color:#333333
    classDef external fill:#ffffff,stroke:#cccccc,color:#666666,stroke-dasharray: 4 2
```
