# rexim/expr architecture

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

- Interactive diagram: https://gitdiagram.com/rexim/expr
- Repository: https://github.com/rexim/expr

## Overview

##### File Structure Analysis
- Top-level files:
– `nobuild.c` / `nobuild.h`: the primary application source and its public interface.
– `expr.cpp`: a C++ module, likely providing expression parsing, AST construction, and evaluation routines.
– `README.md`, `.gitignore`, `LICENSE`: documentation and metadata.
- No separate “src/” or “lib/” folders—everything lives at the root, so the project is compact.

##### README Insights
- Shows exactly two steps: compile and run.
- No additional configuration or external dependencies—implies all functionality is embedded in `nobuild.c` (with helpers in `expr.cpp`).

##### Main Components
a. CLI Front-End (nobuild.c)
- Parses command-line arguments (`run`, maybe others).
- Exposes API in `nobuild.h`.
b. Expression Engine (expr.cpp)
- Lexer/tokenizer
- Parser → AST
- Evaluator/interpreter
c. Operating System Interface
- Standard I/O, file system if tasks or scripts are loaded
- Process execution (if the tool spawns sub-commands)
d. Public API (nobuild.h)
- Extension points, function signatures

##### Relationships and Data Flow
1) User invokes `./nobuild run` → CLI Front-End
2) CLI Front-End uses Expression Engine to parse any inline or script-based expressions
3) AST is passed to the Evaluator
4) Evaluator performs computations or dispatches OS calls
5) Results printed to stdout or used to control workflow

##### Architectural Patterns and Design Principles
- Single-process, modular architecture
- Clear separation: CLI vs. core logic (expression engine) vs. OS interface
- Header (`.h`) / implementation separation for public API (allows future extensions)

##### Essential Elements to Capture
- Component names (exact file names or module names)

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% Components
    subgraph "CLI Front-End"
        CLI["CLI Front-End\n(nobuild.c)"]:::cli
    end

    subgraph "Expression Engine"
        Lexer["Lexer/Tokenizer"]:::core
        Parser["Parser → AST"]:::core
        Evaluator["Evaluator"]:::core
    end

    PublicAPI["Public API\n(nobuild.h)"]:::api
    OS["OS Interface\n(System Calls & I/O)"]:::os

    %% Connections
    CLI -->|"function calls"| PublicAPI
    CLI -->|"parseExpression()"| Lexer
    Lexer -->|"tokens"| Parser
    Parser -->|"AST"| Evaluator
    Evaluator -->|"evaluateAST() / system calls"| OS
    OS -->|"writeOutput()"| CLI

    %% Click Events
    click CLI "https://github.com/rexim/expr/blob/master/nobuild.c"
    click PublicAPI "https://github.com/rexim/expr/blob/master/nobuild.h"
    click Lexer "https://github.com/rexim/expr/blob/master/expr.cpp"
    click Parser "https://github.com/rexim/expr/blob/master/expr.cpp"
    click Evaluator "https://github.com/rexim/expr/blob/master/expr.cpp"
    click OS "https://github.com/rexim/expr/blob/master/nobuild.c"

    %% Styles
    classDef cli fill:#89CFF0,stroke:#036,stroke-width:2px;
    classDef core fill:#8FBC8F,stroke:#060,stroke-width:2px;
    classDef api fill:#FFA500,stroke:#A60,stroke-width:2px;
    classDef os fill:#D3D3D3,stroke:#666,stroke-width:2px;
```
