# wasifsohail5/easy-terminal architecture

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

- Interactive diagram: https://gitdiagram.com/wasifsohail5/easy-terminal
- Repository: https://github.com/wasifsohail5/easy-terminal

## Overview

##### Project Type & Purpose
- This is a Windows-only, AI-powered terminal emulator that accepts natural-language input and translates it into CMD or PowerShell commands via Google Gemini.
- Core features: NLP input detection, real-time AI translation, classic terminal UI, command history, tab completion, and safety checks.

##### Main Components
a. User Interface Layer
- Terminal frontend (console or GUI wrapper in main.py)
- Keyboard handler (Up/Down, Tab, Ctrl+C, etc.)
b. Input Processing Layer
- Input Detector: “is this raw CMD or natural language?”
- Safety Checker: scans for dangerous commands
c. AI Translation Layer
- Google Gemini client/service (HTTP or SDK wrapper)
- Translation orchestrator functions in main.py
d. Execution Layer
- CMD Adapter (terminal_for_cmd.py)
- PowerShell Adapter (terminal_for_powershell.py)
- OS dispatcher: spawns subprocess, captures stdout/stderr
e. Persistence & Utilities
- Command history store (in-memory or file)
- Configuration (API key, UI theme variables)
- Logging/error-handling module
f. External Service
- Google AI Studio (Gemini API)

##### Relationships & Data Flows
- User → UI → Input Detector
- If NL: Detector → AI Translation → Translated CMD → Execution Layer
If raw CMD: Detector → Execution Layer directly
- Execution Layer → Shell (CMD/PowerShell) → Output → UI
- Throughout: History Logger ← Input & Execution events
- AI Translation → Gemini API (cloud round-trip)

##### Architectural Patterns & Technologies
- Modular “Facade” in main.py orchestrating submodules
- Adapter pattern for multiple shell interfaces
- Event-driven input/output loop
- Externalized AI logic via service integration

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% User Interface Layer
    subgraph "User Interface Layer"
        direction TB
        UI["Terminal Frontend"]:::ui
        KB["Keyboard Handler"]:::ui
    end

    %% Input Processing Layer
    subgraph "Input Processing Layer"
        direction TB
        ID["Input Detector"]:::processing
        SC["Safety Checker"]:::processing
    end

    %% AI Translation Layer
    subgraph "AI Translation Layer"
        direction TB
        AT["AI Translator"]:::processing
        GC["Gemini Client"]:::processing
    end

    %% External Service
    GEMINI(("Gemini API")):::cloud

    %% Execution Layer
    subgraph "Execution Layer"
        direction TB
        CMD["CMD Adapter"]:::exec
        PS["PowerShell Adapter"]:::exec
    end

    %% Persistence & Utilities
    subgraph "Persistence & Utilities"
        direction TB
        HIST(("Command History")):::store
        CONF(("Configuration")):::store
    end

    %% Documentation & Tests
    RD["Readme.md"]:::doc
    TS["Test Suite"]:::doc

    %% Main Flow
    UI --> KB
    KB --> ID
    ID --> SC
    SC -->|NL?| AT
    SC -->|raw CMD| CMD
    AT --> GC
    GC -->|call Gemini| GEMINI
    GEMINI --> GC
    GC -->|translated CMD| CMD
    CMD -->|spawn subprocess| SC
    CMD --> UI
    PS --> UI

    %% Logging (dashed)
    ID -.-> HIST
    SC -.-> HIST
    AT -.-> HIST
    CMD -.-> HIST
    GS-.->HIST

    %% Configuration injection
    CONF --> AT
    CONF --> UI

    %% Click Events
    click UI "https://github.com/wasifsohail5/easy-terminal/blob/main/main.py"
    click KB "https://github.com/wasifsohail5/easy-terminal/blob/main/main.py"
    click ID "https://github.com/wasifsohail5/easy-terminal/blob/main/main.py"
    click SC "https://github.com/wasifsohail5/easy-terminal/blob/main/main.py"
    click AT "https://github.com/wasifsohail5/easy-terminal/blob/main/main.py"
    click GC "https://github.com/wasifsohail5/easy-terminal/blob/main/main.py"
    click CMD "https://github.com/wasifsohail5/easy-terminal/blob/main/terminal_for_cmd.py"
    click TS "https://github.com/wasifsohail5/easy-terminal/blob/main/test.py"
    click RD "https://github.com/wasifsohail5/easy-terminal/blob/main/Readme.md"

    %% Styles
    classDef ui fill:#cce5ff,stroke:#004085,color:#004085;
    classDef processing fill:#d4edda,stroke:#155724,color:#155724;
    classDef exec fill:#fff3cd,stroke:#856404,color:#856404;
    classDef store fill:#e2e3e5,stroke:#6c757d,color:#6c757d;
    classDef cloud fill:#f5c6cb,stroke:#721c24,color:#721c24;
    classDef doc fill:#e2e9f3,stroke:#1a3b5d,color:#1a3b5d;
```
