# r-pavan-2503/own_shell architecture

> Architecture diagram of the GitHub repository r-pavan-2503/own_shell, 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/r-pavan-2503/own_shell
- Repository: https://github.com/r-pavan-2503/own_shell

## Overview

##### Main Components
- Shell Entry Point: This is your main application (src/main.cpp) that starts the shell.
- Input Handler: A component that captures user input. It could be abstracted as a “Command Input” module.
- Command Parser: A module that processes the raw input string into tokens/commands. It will determine if the command is a built-in function or an external command.
- Built-in Methods Manager: Since there is a file named inbuiltmethods.txt, you may have a mechanism to load and manage built-in commands. Add a module that reads this file and maps commands.
- Command Executor: This is responsible for executing either the built-in commands or, for external commands, using system calls like fork/exec (if implemented).

##### Relationships and Interactions
- Flow starts at the Shell’s Entry Point, which initializes the shell and then continuously reads input.
- The Input Handler obtains the command from the user and forwards it to the Command Parser.
- The Command Parser decides whether the command matches one of the built-in commands (by referencing the Built-in Methods Manager, potentially sourced from inbuiltmethods.txt).
- Depending on the match, the command is passed to the Command Executor that performs the appropriate action—either processes a built-in operation or executes an external command.
- The results (output, errors) are sent back to the output handler to display to the user, completing the cycle.

##### Architectural Patterns and Principles
- Modular design: Even in a small project, separate the concerns (input, parsing, execution) into distinct modules.
- Error Handling: Although simple, any failure in parsing or execution should lead to appropriate user feedback.

##### Relevant Technologies
- Programming Language: C++
- Build System: CMake (as indicated by CMakeLists.txt)
- Development Environment: VS Code (folder .vscode) for possible debugging or workspace settings.

## Diagram (Mermaid)

```mermaid
flowchart TD
    ShellEntry["Shell Entry Point"]:::entry
    InputHandler["Input Handler"]:::input
    CommandParser["Command Parser"]:::parse
    Decision{"Is_Built-in_Command?"}:::decision
    BuiltinManager["Built-in Methods Manager"]:::builtin
    CommandExecutor["Command Executor"]:::execute
    ErrorOutputHandler["Error/Output Handler"]:::output

    ShellEntry -->|"start"| InputHandler
    InputHandler -->|"command_input"| CommandParser
    CommandParser -->|"check_command"| Decision
    Decision -- "yes" --> BuiltinManager
    BuiltinManager -->|"process_builtin"| CommandExecutor
    Decision -- "no" --> CommandExecutor
    CommandExecutor -->|"result"| ErrorOutputHandler
    ErrorOutputHandler -->|"display & loop_back"| InputHandler

    click ShellEntry "https://github.com/r-pavan-2503/own_shell/blob/main/src/main.cpp"
    click InputHandler "https://github.com/r-pavan-2503/own_shell/blob/main/src/main.cpp"
    click CommandParser "https://github.com/r-pavan-2503/own_shell/blob/main/src/main.cpp"
    click CommandExecutor "https://github.com/r-pavan-2503/own_shell/blob/main/src/main.cpp"
    click ErrorOutputHandler "https://github.com/r-pavan-2503/own_shell/blob/main/src/main.cpp"
    click BuiltinManager "https://github.com/r-pavan-2503/own_shell/blob/main/inbuiltmethods.txt"

    classDef entry fill:#f9c74f,stroke:#333,stroke-width:2px;
    classDef input fill:#90be6d,stroke:#333,stroke-width:2px;
    classDef parse fill:#f94144,stroke:#333,stroke-width:2px;
    classDef builtin fill:#577590,stroke:#333,stroke-width:2px;
    classDef execute fill:#43aa8b,stroke:#333,stroke-width:2px;
    classDef output fill:#f3722c,stroke:#333,stroke-width:2px;
    classDef decision fill:#277da1,stroke:#333,stroke-width:2px,stroke-dasharray:5 5;
```
