# m507/ramigpt architecture

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

- Interactive diagram: https://gitdiagram.com/m507/ramigpt
- Repository: https://github.com/m507/ramigpt

## Overview

##### Project Type and Purpose
- RamiGPT is a defensive/offensive security tool that automates privilege escalation testing by combining AI (using OpenAI’s API), automation via PwnTools, and integration with external enumeration tools (e.g., BeRoot, LinPEAS).
- It is structured as a full-stack application where a web GUI drives backend logic, which in turn calls external scripts and tools to perform security tasks. Docker is also used for containerized deployment.

##### File Structure
- At the root, you see main Python scripts such as app.py, ai.py, PrivEscPrompt.py, and common.py. These files form the core application logic.
- The templates and static directories house the frontend components (HTML, CSS, and JavaScript) for the user interface.
- The external_tools directory is extensive and contains two major sets of tools:
- BeRoot (for both Linux and Windows) with multiple modules indicating a modular design for performing different privilege escalation checks.
- Linpeas (and possibly other tools) for auditing system configurations.
- The presence of configuration files (e.g., .env.example, docker-compose.yml) and setup scripts (like generate_certs.sh) indicate support for both local and containerized deployments.
- Additional files like setup_logger.py and root_detection.py suggest helper routines for logging and environment validation.

##### Extract Key README Insights
- The README emphasizes workflows including setup (both Docker and local), API key configuration, and integrated tools usage.
- The “Integrated Tools” section tells you that RamiGPT leverages external enumeration tools automatically or recommends them based on the target environment.
- The screenshots and GUI instructions imply that the visual interaction is an important part of the user experience.

##### Instructing the Principal Software Engineer
- From the user’s browser (Frontend) to the backend server.
- From the backend to the AI module and back, indicating outbound API calls.
- From the backend to the operating system/external tools (with a note that these are sub-process calls or integrations).
- UI components (e.g., rounded rectangles for frontend elements),
- Detail any middleware or integration points explicitly, such as the certificate generation process (generate_certs.sh) and the API key configuration (via .env).

## Diagram (Mermaid)

```mermaid
graph TD
    User["User Browser"]:::user

    subgraph "Frontend (UI – Templates and Static Assets)"
        Templates["Templates"]:::frontend
        Static["Static"]:::frontend
    end

    subgraph "Web Server / Backend"
        App["app.py"]:::backend
        AIBackend["ai.py"]:::backend
        Common["common.py"]:::backend
        Prompt["PrivEscPrompt.py"]:::backend
    end

    AI_Service["OpenAI API"]:::api

    subgraph "External Tools Suite"
        ExtTools["external_tools"]:::external
    end

    DockerEnv["Docker Container Environment"]:::docker

    subgraph "Auxiliary Services"
        Logger["setup_logger.py"]:::aux
        Cert["generate_certs.sh"]:::aux
        Root["root_detection.py"]:::aux
    end

    %% Connections
    User -->|"sendsRequest"| Templates
    Templates -->|"submits"| App
    App -->|"triggers"| ExtTools
    App -->|"logsVia"| Logger
    App -->|"generatesCert"| Cert
    App -->|"envValidates"| Root
    AIBackend -->|"callsAPI"| AI_Service
    AI_Service -->|"returns"| AIBackend
    App -->|"sendsResponse"| Templates
    DockerEnv -->|"hosts"| App
    DockerEnv -->|"orchestrates"| ExtTools

    %% Click Events
    click Templates "https://github.com/m507/ramigpt/tree/master/templates"
    click Static "https://github.com/m507/ramigpt/tree/master/static"
    click App "https://github.com/m507/ramigpt/blob/master/app.py"
    click AIBackend "https://github.com/m507/ramigpt/blob/master/ai.py"
    click Common "https://github.com/m507/ramigpt/blob/master/common.py"
    click Prompt "https://github.com/m507/ramigpt/blob/master/PrivEscPrompt.py"
    click ExtTools "https://github.com/m507/ramigpt/tree/master/external_tools"
    click DockerEnv "https://github.com/m507/ramigpt/blob/master/docker-compose.yml"
    click Logger "https://github.com/m507/ramigpt/blob/master/setup_logger.py"
    click Cert "https://github.com/m507/ramigpt/blob/master/generate_certs.sh"
    click Root "https://github.com/m507/ramigpt/blob/master/root_detection.py"

    %% Styles
    classDef user fill:#fffd82,stroke:#f9c74f,stroke-width:2px;
    classDef frontend fill:#a2d5f2,stroke:#07689f,stroke-width:2px;
    classDef backend fill:#f4d35e,stroke:#ee964b,stroke-width:2px;
    classDef api fill:#f7a072,stroke:#e85a4f,stroke-width:2px;
    classDef external fill:#e29578,stroke:#d96459,stroke-width:2px;
    classDef docker fill:#d5e8d4,stroke:#82b366,stroke-width:2px;
    classDef aux fill:#c9ada7,stroke:#9a8c98,stroke-width:2px;
```
