# kobeevb05-del/shell_project architecture

> Architecture diagram of the GitHub repository kobeevb05-del/shell_project, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-09-25). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/kobeevb05-del/shell_project
- Repository: https://github.com/kobeevb05-del/shell_project
- Video tour (about a minute): https://gitdiagram.com/kobeevb05-del/shell_project/video

## Overview

This is an educational shell command-line analyzer, not a command executor. The main workflow reads command text, tokenizes it, optionally parses the tokens into an AST, and prints tokens or the AST; lexical and syntax errors are reported to stderr. The parser excerpt shows the grammar stages and AST operations, while the README documents supported syntax and explicitly excludes execution. The graph omits unsupported runtime behavior.

Main entry points: [`src/main.c`](https://github.com/kobeevb05-del/shell_project/blob/main/src/main.c) (CLI entry), [`src/parser.c`](https://github.com/kobeevb05-del/shell_project/blob/main/src/parser.c) (Parser entry), [`src/lexer.c`](https://github.com/kobeevb05-del/shell_project/blob/main/src/lexer.c) (Lexer), [`src/token.h`](https://github.com/kobeevb05-del/shell_project/blob/main/src/token.h) (Token stream)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interface["CLI interface"]
  node_main["CLI entry<br/>[main.c]"]
  node_input["Input reader<br/>[main.c]"]
end

subgraph group_analysis["Command analysis"]
  node_lexer["Lexer<br/>[lexer.c]"]
  node_parser["Parser entry<br/>[parser.c]"]
  node_list["Command lists<br/>[parser.c]"]
  node_andor["And-or stage<br/>[parser.c]"]
  node_pipeline["Pipeline stage<br/>[parser.c]"]
  node_command["Command stage<br/>[parser.c]"]
end

subgraph group_representation["Token and AST"]
  node_tokens["Token stream<br/>[token.h]"]
  node_ast["Command AST<br/>[ast.h]"]
  node_ast_output["AST printer<br/>[ast.c]"]
end

node_user(("Shell user"))
node_terminal(("Terminal"))

node_user -->|"provides command"| node_main
node_main -->|"reads input"| node_input
node_input -->|"returns text"| node_main
node_main -->|"tokenizes input"| node_lexer
node_lexer -->|"produces tokens"| node_tokens
node_main -->|"prints tokens"| node_tokens
node_main -->|"parses tokens"| node_parser
node_parser -->|"reads tokens"| node_tokens
node_parser -->|"parses list"| node_list
node_list -->|"parses items"| node_andor
node_andor -->|"parses operands"| node_pipeline
node_pipeline -->|"parses commands"| node_command
node_parser -->|"builds tree"| node_ast
node_main -->|"prints AST"| node_ast_output
node_ast_output -->|"reads tree"| node_ast
node_main -->|"writes output"| node_terminal
node_lexer -->|"returns errors"| node_main
node_parser -->|"returns errors"| node_main

click node_main "https://github.com/kobeevb05-del/shell_project/blob/main/src/main.c"
click node_input "https://github.com/kobeevb05-del/shell_project/blob/main/src/main.c"
click node_lexer "https://github.com/kobeevb05-del/shell_project/blob/main/src/lexer.c"
click node_tokens "https://github.com/kobeevb05-del/shell_project/blob/main/src/token.h"
click node_parser "https://github.com/kobeevb05-del/shell_project/blob/main/src/parser.c"
click node_list "https://github.com/kobeevb05-del/shell_project/blob/main/src/parser.c"
click node_andor "https://github.com/kobeevb05-del/shell_project/blob/main/src/parser.c"
click node_pipeline "https://github.com/kobeevb05-del/shell_project/blob/main/src/parser.c"
click node_command "https://github.com/kobeevb05-del/shell_project/blob/main/src/parser.c"
click node_ast "https://github.com/kobeevb05-del/shell_project/blob/main/src/ast.h"
click node_ast_output "https://github.com/kobeevb05-del/shell_project/blob/main/src/ast.c"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_main,node_input,node_user toneBlue
class node_lexer,node_parser,node_list,node_andor,node_pipeline,node_command toneAmber
class node_tokens,node_ast,node_ast_output toneMint
class node_terminal toneIndigo
```

## Components

### CLI interface

- [CLI entry](https://github.com/kobeevb05-del/shell_project/blob/main/src/main.c): `src/main.c`
- [Input reader](https://github.com/kobeevb05-del/shell_project/blob/main/src/main.c): `src/main.c`

### Command analysis

- [Lexer](https://github.com/kobeevb05-del/shell_project/blob/main/src/lexer.c): `src/lexer.c`
- [Parser entry](https://github.com/kobeevb05-del/shell_project/blob/main/src/parser.c): `src/parser.c`
- [Command lists](https://github.com/kobeevb05-del/shell_project/blob/main/src/parser.c): `src/parser.c`
- [And-or stage](https://github.com/kobeevb05-del/shell_project/blob/main/src/parser.c): `src/parser.c`
- [Pipeline stage](https://github.com/kobeevb05-del/shell_project/blob/main/src/parser.c): `src/parser.c`
- [Command stage](https://github.com/kobeevb05-del/shell_project/blob/main/src/parser.c): `src/parser.c`

### Token and AST

- [Token stream](https://github.com/kobeevb05-del/shell_project/blob/main/src/token.h): `src/token.h`
- [Command AST](https://github.com/kobeevb05-del/shell_project/blob/main/src/ast.h): `src/ast.h`
- [AST printer](https://github.com/kobeevb05-del/shell_project/blob/main/src/ast.c): `src/ast.c`

### Other components

- **Shell user**
- **Terminal**

## Connections

- Shell user → CLI entry: provides command
- CLI entry → Input reader: reads input
- Input reader → CLI entry: returns text
- CLI entry → Lexer: tokenizes input
- Lexer → Token stream: produces tokens
- CLI entry → Token stream: prints tokens
- CLI entry → Parser entry: parses tokens
- Parser entry → Token stream: reads tokens
- Parser entry → Command lists: parses list
- Command lists → And-or stage: parses items
- And-or stage → Pipeline stage: parses operands
- Pipeline stage → Command stage: parses commands
- Parser entry → Command AST: builds tree
- CLI entry → AST printer: prints AST
- AST printer → Command AST: reads tree
- CLI entry → Terminal: writes output
- Lexer → CLI entry: returns errors
- Parser entry → CLI entry: returns errors
