# gobyebye/zedex architecture

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

- Interactive diagram: https://gitdiagram.com/gobyebye/zedex
- Repository: https://github.com/gobyebye/zedex

## Overview

This project is a command-line tool implemented in Rust that functions as a local mirror for Zed extensions. Its primary purpose is to let users run Zed “fully independently” by downloading extensions and serving them locally or acting as a proxy. The tool is modularized into separate components handling CLI commands, extension management, web server operations, and error/version management.

##### Main Components
- CLI Interface: Represented by the main entry point (src/main.rs) that parses the user commands (e.g., "zedex get", "zedex serve", "zedex release download").
- Extension Management Module: In the “src/zed” directory, files like extension.rs and the extension-index functionality handle downloading and managing individual extensions.
- Local Server / Proxy Module: The local_server.rs module implements the functionality to start a server (normal mode or proxy mode) that listens on a configurable host/port. This component is central for serving the extensions to Zed.
- Error Handling and Versioning: error.rs provides custom error management, while version.rs likely keeps track of releases or versions of the tool.
- Configuration & External Dependencies: Although not coded in-depth in the file tree, the project utilizes configuration files (e.g., Dockerfile, docker-compose.yml, GitHub CI workflows, Cargo configuration files) that manage building, deploying, and dependency handling.

##### Relationships and Interactions
- The CLI Interface acts as the entry gate, interpreting commands and delegating tasks.
- For “get” commands, the CLI calls the Extension Management Module to fetch all extensions, a specific extension, or the extension index.
- For “serve” commands, the CLI instructs the Local Server Module to spin up an HTTP server which could be running in a standard or proxy mode, serving content or facilitating API calls.
- The Error Handling Module is accessed by all modules to ensure robust error propagation and logging.
- Version information is accessed to support auto-update features as indicated in the README.

##### Architectural Patterns and Design Principles
- Modularity: The separation of concerns is clear (CLI, backend extension management, server operations), making it easier to test and maintain.
- Command Dispatch: The application follows a command dispatch pattern where the user input (through CLI) triggers different workflows.
- Configuration and Extensibility: The project is built with potential extensibility in mind (e.g., caching and improved error handling are on the wishlist).
- Containerization / DevOps Integration: Presence of Dockerfiles and GitHub workflows indicates that the project also supports containerized deployment and continuous integration setups.

##### Relevant Technologies, Frameworks, or Libraries
- Rust (Cargo building and Rust’s module system)
- Docker: With the Dockerfile and docker-compose.yml for containerized deployment.
- GitHub Actions: For CI/CD pipelines.
- HTTP Server libraries, possibly using Hyper, Actix, or similar (as implied for the local server component)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Command Processing Layer
    subgraph "User Command Processing"
        CLI["CLI Interface"]:::cli
    end

    %% Business Logic Layer
    subgraph "Business Logic"
        EXT["Extension Manager"]:::manager
        SERVER["Local Server / Proxy"]:::manager
    end

    %% Support Modules Layer
    subgraph "Support Modules"
        ERROR["Error Handling"]:::support
        VERSION["Versioning"]:::support
    end

    %% DevOps & Configuration Layer
    subgraph "DevOps & Configuration"
        DOCKER["Dockerfile"]:::devops
        COMPOSE["docker-compose.yml"]:::devops
        GITHUB[".github"]:::devops
        CARGO_TOML["Cargo.toml"]:::devops
        CARGO_LOCK["Cargo.lock"]:::devops
    end

    %% Relationships between layers
    CLI -->|"get-command"| EXT
    CLI -->|"serve-command"| SERVER
    CLI -->|"release-download"| VERSION

    EXT -->|"error-propagation"| ERROR
    SERVER -->|"error-propagation"| ERROR
    VERSION -->|"error-propagation"| ERROR

    %% DevOps supporting configuration for core modules
    DOCKER ---|"config"| CLI
    DOCKER ---|"config"| EXT
    DOCKER ---|"config"| SERVER

    %% Internal connections within DevOps group
    DOCKER --- COMPOSE
    COMPOSE --- GITHUB
    GITHUB --- CARGO_TOML
    CARGO_TOML --- CARGO_LOCK

    %% Click Events
    click CLI "https://github.com/gobyebye/zedex/blob/main/src/main.rs"
    click EXT "https://github.com/gobyebye/zedex/blob/main/src/zed/extension.rs"
    click SERVER "https://github.com/gobyebye/zedex/blob/main/src/zed/local_server.rs"
    click ERROR "https://github.com/gobyebye/zedex/blob/main/src/zed/error.rs"
    click VERSION "https://github.com/gobyebye/zedex/blob/main/src/zed/version.rs"
    click DOCKER "https://github.com/gobyebye/zedex/tree/main/Dockerfile"
    click COMPOSE "https://github.com/gobyebye/zedex/blob/main/docker-compose.yml"
    click GITHUB "https://github.com/gobyebye/zedex/blob/main/.github"
    click CARGO_TOML "https://github.com/gobyebye/zedex/blob/main/Cargo.toml"
    click CARGO_LOCK "https://github.com/gobyebye/zedex/blob/main/Cargo.lock"

    %% Class Definitions for Colors
    classDef cli fill:#ADD8E6,stroke:#000080,stroke-width:2px;
    classDef manager fill:#90EE90,stroke:#006400,stroke-width:2px;
    classDef support fill:#FFD700,stroke:#B8860B,stroke-width:2px;
    classDef devops fill:#D3D3D3,stroke:#696969,stroke-width:2px;
```
