# casweeney/resolver architecture

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

- Interactive diagram: https://gitdiagram.com/casweeney/resolver
- Repository: https://github.com/casweeney/resolver

## Overview

##### Project type and purpose
- This is a command‐line application (“resolver-cli”) written in Rust.
- Its purpose is to scaffold new projects (React, Next.js, Hardhat, etc.), clone standard templates from GitHub, and install developer tools.

##### File structure
- Top‐level Cargo files: Cargo.toml/Cargo.lock define dependencies and metadata.
- `src/main.rs` contains the CLI entry point.
- `src/lib.rs` holds core business logic exposed to the binary.
- `src/utils/` contains helper submodules:
- `command_arguments.rs` – argument and subcommand parsing
- `constants.rs` – static values (flags, URLs, template names)
- `helpers.rs` – file operations, shell invocations, Git interactions
- `mod.rs` – reexports for utils

##### README for architectural insights
- Commands: `get`, `scaffold`, `install`
- External interactions:
- GitHub (cloning boilerplate repositories)
- Local file system (creating project folders)
- Shell commands (calling cargo install, curl, npm, brew, etc.)

##### Main components
a. CLI Frontend
- Single binary (`resolver-cli`)
- Argument parser (from `command_arguments.rs`, possibly using `clap` or similar)
b. Command Dispatcher
- Routes input to one of three handlers: GetHandler, ScaffoldHandler, InstallHandler
c. GetHandler (Template Cloner)
- Uses Git helpers to clone from GitHub
- Reads `constants` for repository URLs
- FileSystem helpers to rename/move directories
d. ScaffoldHandler (Project Generator)
- Contains template definitions (React, Vue, etc.)
- Copies or generates files via helpers
- May include template rendering or file copying logic
e. InstallHandler (Tool Installer)
- Maps tool names to install scripts/commands
- Executes shell commands (curl, brew, npm, cargo)
f. Utils module
- Shared across handlers: file operations, logging, error handling, constants
g. External Systems
- GitHub (template repositories)
- Operating system shell (bash/powershell)
- Package managers (cargo, npm, homebrew, choco, etc.)

##### Relationships and interactions
- User inputs on CLI → CLI Frontend → Command Dispatcher
- Dispatcher → appropriate Handler
- Handlers rely on Utils for all file and shell operations
- Handlers communicate with external services:
- GitHub over HTTPS for `get`
- Local OS shell for `install`

##### Architectural patterns and principles
- Single-responsibility: each subcommand has its own handler module
- Layered structure:
- Presentation (main.rs & CLI parsing)
- Application (lib.rs & command dispatch)
- Infrastructure (utils: file system, network, shell)
- Dependency injection (pass helpers into handlers) to facilitate testing
- Error handling centralized in helpers

##### Final advice
- Be exhaustive: represent every logical component (argument parser, each subcommand, helpers).
- Data/control flow clearly with arrowheads.

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Presentation Layer
    subgraph "Presentation Layer"
        CLI["CLI Frontend\n(src/main.rs)"]:::core
    end

    %% Application Layer
    CLI -->|"invoke"| Dispatcher["Command Dispatcher\n(src/lib.rs)"]:::core

    %% Handlers
    subgraph "Handlers"
        Get["GetHandler"]:::core
        Scaffold["ScaffoldHandler"]:::core
        Install["InstallHandler"]:::core
    end

    Dispatcher -->|"get"| Get
    Dispatcher -->|"scaffold"| Scaffold
    Dispatcher -->|"install"| Install

    %% Utils Module
    subgraph "Utils Module"
        Args["Argument Parsing\n(src/utils/command_arguments.rs)"]:::util
        Const["Constants\n(src/utils/constants.rs)"]:::util
        Helpers["Helpers\n(src/utils/helpers.rs)"]:::util
    end

    CLI -->|"parse args"| Args
    Get -->|"read URLs"| Const

    Get -->|"clone()"| Helpers
    Scaffold -->|"copy_template()"| Helpers
    Install -->|"exec_install()"| Helpers

    %% Infrastructure
    Helpers -->|"file ops"| FS["File System"]:::infra
    Helpers -->|"shell cmd"| Shell["OS Shell & Package Managers"]:::infra

    %% External Systems
    Get -->|"fetch templates"| GitHub["GitHub"]:::external

    %% Legend
    subgraph "Legend"
        L1["Blue: Core Modules"]:::core
        L2["Green: Utils"]:::util
        L3["Orange: Infra/External"]:::external
    end

    %% Click Events
    click CLI "https://github.com/casweeney/resolver/blob/main/src/main.rs"
    click Dispatcher "https://github.com/casweeney/resolver/blob/main/src/lib.rs"
    click Utils "https://github.com/casweeney/resolver/blob/main/src/utils/mod.rs"
    click Args "https://github.com/casweeney/resolver/blob/main/src/utils/command_arguments.rs"
    click Const "https://github.com/casweeney/resolver/blob/main/src/utils/constants.rs"
    click Helpers "https://github.com/casweeney/resolver/blob/main/src/utils/helpers.rs"

    %% Styles
    classDef core fill:#ADD8E6,stroke:#333,stroke-width:1px;
    classDef util fill:#90EE90,stroke:#333,stroke-width:1px;
    classDef infra fill:#FFD580,stroke:#333,stroke-width:1px;
    classDef external fill:#FFA500,stroke:#333,stroke-width:1px;
```
