# brack-lang/brack architecture

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

- Interactive diagram: https://gitdiagram.com/brack-lang/brack
- Repository: https://github.com/brack-lang/brack

## Overview

##### Project Type & Purpose
- The project is a highly modular, extensible markup language implementation written in Rust. Its purpose is to compile input written in Brack syntax into various text-based formats (HTML, LaTeX, etc.) by leveraging a plugin system based on WebAssembly.
- Key capabilities include syntax parsing/tokenizing, transforming from abstract syntax trees (AST), code generation, and a language server that supports development tooling. It also provides a project manager and release tooling—making it a multi-component, full-toolchain system for both development and deployment of the language.

##### Analyzing the File Structure
- Top-level items include configuration files (Cargo.toml, build scripts, GitHub workflows, Nix and flake files), which hint at automated builds and testing.
- The significant “crates” directory is clearly subdivided into several Rust crates:
- brack-codegen – likely responsible for converting ASTs into target formats.
- brack-expander – for handling macro/expansion logic.
- brack-language-server – providing editor features and real-time document transformation.
- brack-parser – containing tokenizing and parsing logic.
- brack-plugin – handling the WebAssembly based plugin system.
- brack-project-manager – managing projects, configurations, and document structures.
- brack-release – for managing releases and semantic versioning.
- brack-tokenizer – specific for breaking down the input text into tokens.
- brack-transformer – for processing and simplifying ASTs.
- Besides the “crates” folder, there is a “src” directory which contains core components such as the command-line interface (CLI) logic, compiling routines, debug tools, and sub-commands.

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% Compiler Core Pipeline
    subgraph "Compiler Core Pipeline"
        CLI["CLI/Driver"]:::core
        TKN["Tokenizer"]:::core
        PRS["Parser"]:::core
        TRF["Transformer"]:::core
        CG["Codegen"]:::core
        EXP["Expander"]:::core
    end

    %% Supporting Tools
    subgraph "Supporting Tools"
        PLG["Plugin System"]:::integration
        LS["Language Server"]:::integration
        PM["Project Manager"]:::integration
        RM["Release Manager"]:::integration
    end

    %% Core Pipeline Flow
    CLI -->|"input"| TKN
    TKN -->|"tokens"| PRS
    PRS -->|"parse-tree"| TRF
    TRF -->|"AST"| CG
    TRF -->|"AST"| EXP

    %% Supporting Tools Integration
    CG -->|"artifacts"| RM
    EXP -->|"artifacts"| RM
    CLI -->|"manages"| PM
    LS <-->|"feedback"| CLI
    PLG -->|"extends"| TKN
    PLG -->|"extends"| TRF

    %% Styles
    classDef core fill:#bbdefb,stroke:#0d47a1,stroke-width:2px;
    classDef integration fill:#c8e6c9,stroke:#2e7d32,stroke-width:2px;

    %% Click Events
    click CLI "https://github.com/brack-lang/brack/blob/develop/src/main.rs"
    click TKN "https://github.com/brack-lang/brack/tree/develop/crates/brack-tokenizer"
    click PRS "https://github.com/brack-lang/brack/tree/develop/crates/brack-parser"
    click TRF "https://github.com/brack-lang/brack/tree/develop/crates/brack-transformer"
    click CG "https://github.com/brack-lang/brack/tree/develop/crates/brack-codegen"
    click EXP "https://github.com/brack-lang/brack/tree/develop/crates/brack-expander"
    click PLG "https://github.com/brack-lang/brack/tree/develop/crates/brack-plugin"
    click LS "https://github.com/brack-lang/brack/tree/develop/crates/brack-language-server"
    click PM "https://github.com/brack-lang/brack/tree/develop/crates/brack-project-manager"
    click RM "https://github.com/brack-lang/brack/tree/develop/crates/brack-release"
```
