# lhy-pkueecs/test_repository architecture

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

- Interactive diagram: https://gitdiagram.com/lhy-pkueecs/test_repository
- Repository: https://github.com/lhy-pkueecs/test_repository

## Overview

##### Project type and purpose
- This is a command-line “shell” or small interpreter framework written in Python.
- It parses user input, builds an AST, evaluates it via a core engine and runtime, and dispatches commands to built-in “apps.”

##### File structure
- Top-level:
- README.md (very brief, just a placeholder)
- src/ – all code lives here
- src/core/:
- api.py – public APIs for external callers
- app.py, app_factory.py – definitions of “apps” (commands) and how to instantiate them
- builtinapp_executor.py – logic to run built-in apps
- engine.py – the evaluator, takes an AST and drives execution
- runtime.py – execution context (variables, I/O state)
- eval_tree.py, eval_node.py – AST representation and node evaluation logic
- error_handling.py – centralized error classes and handlers
- shell_parser/grammar.lark, parser.py – the Lark grammar and parser for user input
- utils.py – shared helper functions
- src/shell.py – the entry-point that ties core pieces together
- src/user/:
- prompt.py – reads user input, handles line editing
- shell.py – a “user-facing” shell wrapper that leverages core

##### README for additional insights
- Very minimal; it only indicates “this repo is for testing.”
- No architecture notes in README.

##### Detail level
– Capture every layer and major module.
– Do not over-simplify: show the distinction between AST representation (eval_tree.py) and evaluation logic (engine.py, eval_node.py).
– Show how app modules are discovered and invoked via app_factory/builtinapp_executor.

## Diagram (Mermaid)

```mermaid
flowchart TD
    subgraph "User Layer"
        USR["Shell Wrapper"]:::user
        PRM["Prompt/Input Handler"]:::user
    end

    subgraph "Core CLI Engine"
        EP["Entry Point"]:::core
        API["API Layer"]:::core

        subgraph "Parser & AST"
            GRM["Grammar File"]:::parser
            PAR["Parser Implementation"]:::parser
            ATREE["Tree Definition"]:::parser
            ANODE["Node Evaluation Logic"]:::parser
        end

        subgraph "Evaluation Runtime"
            ENG["Engine"]:::runtime
            RT["Runtime Environment"]:::runtime
        end

        subgraph "App Execution"
            AF["App Factory"]:::apps
            EXE["Built-in App Executor"]:::apps
            subgraph "Built-in Apps"
                BA["Basic Apps"]:::apps
                AA["Additional Apps"]:::apps
            end
        end
    end

    USR --> PRM
    PRM --> EP
    EP --> API
    EP -->|"parses input"| GRM
    EP -->|"parses input"| PAR
    PAR --> ATREE
    ATREE --> ANODE
    ANODE --> ENG
    ENG --> RT
    ENG --> AF
    AF --> EXE
    EXE --> BA
    EXE --> AA
    BA -->|result| ENG
    AA -->|result| ENG
    ENG -->|output| PRM

    click USR "https://github.com/lhy-pkueecs/test_repository/blob/main/src/user/shell.py"
    click PRM "https://github.com/lhy-pkueecs/test_repository/blob/main/src/user/prompt.py"
    click EP "https://github.com/lhy-pkueecs/test_repository/blob/main/src/shell.py"
    click API "https://github.com/lhy-pkueecs/test_repository/blob/main/src/core/api.py"
    click GRM "https://github.com/lhy-pkueecs/test_repository/blob/main/src/core/shell_parser/grammar.lark"
    click PAR "https://github.com/lhy-pkueecs/test_repository/blob/main/src/core/shell_parser/parser.py"
    click ATREE "https://github.com/lhy-pkueecs/test_repository/blob/main/src/core/eval_tree.py"
    click ANODE "https://github.com/lhy-pkueecs/test_repository/blob/main/src/core/eval_node.py"
    click ENG "https://github.com/lhy-pkueecs/test_repository/blob/main/src/core/engine.py"
    click RT "https://github.com/lhy-pkueecs/test_repository/blob/main/src/core/runtime.py"
    click AF "https://github.com/lhy-pkueecs/test_repository/blob/main/src/core/app_factory.py"
    click EXE "https://github.com/lhy-pkueecs/test_repository/blob/main/src/core/builtinapp_executor.py"
    click BA "https://github.com/lhy-pkueecs/test_repository/blob/main/src/core/apps/basic_apps.py"
    click AA "https://github.com/lhy-pkueecs/test_repository/blob/main/src/core/apps/additional_apps.py"

    classDef user fill:#f9f,stroke:#333,stroke-width:1px
    classDef parser fill:#ccf,stroke:#333,stroke-width:1px
    classDef runtime fill:#cfc,stroke:#333,stroke-width:1px
    classDef apps fill:#ffc,stroke:#333,stroke-width:1px
    classDef core fill:#eee,stroke:#333,stroke-width:1px
```
