# m-e-u-e/documentation-using-ai-agent architecture

> Architecture diagram of the GitHub repository m-e-u-e/documentation-using-ai-agent, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-04-21). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/m-e-u-e/documentation-using-ai-agent
- Repository: https://github.com/m-e-u-e/documentation-using-ai-agent

## Overview

##### Project Type and Purpose
- This is a Python‑based CLI tool + documentation pipeline that:
- Fetches Markdown source from GitHub or GitLab repos (or local folders)
- Parses & potentially “enhances” them via AI agents
- Assembles final Markdown files (e.g. `final_github_md_file.py`)
- Serves them via MkDocs as a static documentation site
- It is not a web‑app server or microservices architecture; rather it is a single “monolithic” data‑processing pipeline + static site generator.

##### File Structure
- Top‑level:
- `.gitignore`, `mkdocs.yml`, `requirements.txt`, README
- `agentic_parser/` – all Python modules
- `docs/` – sources and MkDocs content
- Within `agentic_parser/`:
- Entry‐point scripts: `final_github_md_file.py`, `GitLabScrappper.py`, `localmd.py`, `EnahncedDocsSearchTool.py`
- Core engine: `baseWorking.py` (base classes and orchestration)
- Agent definitions: `agents.py` (AI integration)
- Parsing helpers: `rootmd.py`, `repositorymd.py`
- The presence of API‑key env vars in README shows external dependencies: GitHub/GitLab REST APIs, Gemini AI.

##### Extract Architecture Insights from the README
- Three “modes” of operation:
1. Fetch & assemble GitHub docs
2. Fetch & assemble GitLab docs (token vs. scraper fallback)
3. Read local Markdown directory
- MkDocs is used to serve the final docs (`mkdocs serve`).

##### Main Components
a. CLI / User Interface
- User runs Python scripts with env vars.
b. Configuration Layer
- Environment variables for API keys, repo URLs, branch names.
c. Fetchers / API Clients
- GitHubClient (in `final_github_md_file.py`)
- GitLabClient & Scraper (in `GitLabScrappper.py`)
- LocalFileLoader (`localmd.py`)
d. Core Processing Pipeline
- BaseWorking orchestrator (`baseWorking.py`)
- RepositoryMD & RootMD parsers (`repositorymd.py`, `rootmd.py`)
- Agent‐driven enhancements (`agents.py`, `EnahncedDocsSearchTool.py`)
e. Output Generator
- Final Markdown composer (`final_github_md_file.py` or local equivalent)
- Writes to `docs/` folder or another build folder
f. Documentation Server
- MkDocs → builds & serves static site from `docs/`

##### Relationships & Data Flows
- User → CLI entrypoint → Config
- Config → Fetcher → External API or FileSystem
- Fetched MD → Core Pipeline → Agents → Final MD
- Final MD → MkDocs build → Static HTML
- User ↔ Browser (view docs)

##### Architectural Patterns & Design Principles
- Pipeline / stages pattern: each stage focuses on one task (fetch, parse, enhance, render)
- Dependency injection via env vars for credentials & endpoints
- Single‐process orchestration – no microservices
- Separation of concerns: IO (fetch), logic (parse, AI), presentation (MkDocs)

##### Technologies & Frameworks to Label
- Python 3.x
- Requests or GitHub/GitLab API libraries
- Gemini AI (via `GEMINI_API_KEY`) in `agents.py`
- MkDocs for static site
- Virtualenv for environment isolation

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% User Layer
    User["User"]:::user
    User --> FG
    User --> GS
    User --> LM
    User --> ED

    %% CLI / User Interface
    FG["final_github_md_file.py"]:::cli
    GS["GitLabScrappper.py"]:::cli
    LM["localmd.py"]:::cli
    ED["EnahncedDocsSearchTool.py"]:::cli

    %% Configuration Layer
    subgraph "Configuration"
        env["Environment Variables\n(GEMINI_API_KEY, REPO_URL, TOKEN)"]:::config
        mkYml["mkdocs.yml"]:::config
        readme["README.md"]:::config
        req["requirements.txt"]:::config
    end

    FG -->|reads| env
    GS -->|reads| env
    LM -->|reads| env
    ED -->|reads| env
    FG -->|reads| mkYml
    FG -->|reads| readme
    FG -->|reads| req

    %% Fetchers / API Clients
    subgraph "Fetchers / API Clients"
        GHClient["GitHubClient"]:::fetch
        GLClient["GitLabClient & Scraper"]:::fetch
        LocalLoader["LocalFileLoader"]:::fetch
    end

    FG --> GHClient
    GS --> GLClient
    LM --> LocalLoader

    GHClient -->|API JSON| GitHubAPI[(GitHub API)]:::external
    GLClient -->|API JSON / HTML| GitLabAPI[(GitLab API)]:::external
    GLClient -->|Scraped HTML| GitLabAPI
    LocalLoader -->|Files| LocalFS["Local Markdown Files"]:::fs

    %% Core Processing Pipeline
    subgraph "Core Processing Pipeline"
        Base["BaseWorking\n(baseWorking.py)"]:::process
        RepoMD["RepositoryMD\n(repositorymd.py)"]:::process
        RootMD["RootMD\n(rootmd.py)"]:::process
        Agents["Agents\n(agents.py)"]:::process
    end

    GHClient --> Base
    GLClient --> Base
    LocalLoader --> Base

    Base --> RepoMD
    Base --> RootMD
    RepoMD --> Agents
    RootMD --> Agents
    ED --> Agents

    %% Output Generator
    subgraph "Output Generator"
        Composer["Markdown Composer\n(final_github_md_file.py)"]:::process
        DocsFolder["docs/"]:::fs
    end

    Agents --> Composer
    Composer --> DocsFolder

    %% Documentation Server
    subgraph "Documentation Server"
        MkDocs["MkDocs Server\n(static site)"]:::server
    end

    DocsFolder --> MkDocs
    MkDocs -->|Static HTML| Browser["User's Browser"]:::user

    %% Click Events
    click FG "https://github.com/m-e-u-e/documentation-using-ai-agent/blob/main/agentic_parser/final_github_md_file.py"
    click GS "https://github.com/m-e-u-e/documentation-using-ai-agent/blob/main/agentic_parser/GitLabScrappper.py"
    click LM "https://github.com/m-e-u-e/documentation-using-ai-agent/blob/main/agentic_parser/localmd.py"
    click ED "https://github.com/m-e-u-e/documentation-using-ai-agent/blob/main/agentic_parser/EnahncedDocsSearchTool.py"
    click Base "https://github.com/m-e-u-e/documentation-using-ai-agent/blob/main/agentic_parser/baseWorking.py"
    click RepoMD "https://github.com/m-e-u-e/documentation-using-ai-agent/blob/main/agentic_parser/repositorymd.py"
    click RootMD "https://github.com/m-e-u-e/documentation-using-ai-agent/blob/main/agentic_parser/rootmd.py"
    click Agents "https://github.com/m-e-u-e/documentation-using-ai-agent/blob/main/agentic_parser/agents.py"
    click mkYml "https://github.com/m-e-u-e/documentation-using-ai-agent/blob/main/mkdocs.yml"
    click DocsFolder "https://github.com/m-e-u-e/documentation-using-ai-agent/tree/main/docs/"

    %% Styles
    classDef user fill:#f9f,stroke:#333,stroke-width:1px
    classDef cli fill:#bbf,stroke:#333,stroke-width:1px
    classDef config fill:#bfb,stroke:#333,stroke-width:1px
    classDef fetch fill:#add8e6,stroke:#333,stroke-width:1px
    classDef external fill:#f96,stroke:#333,stroke-width:1px,stroke-dasharray: 5 5
    classDef fs fill:#ccc,stroke:#333,stroke-width:1px,stroke-dasharray: 2 2
    classDef process fill:#8fb,stroke:#333,stroke-width:1px
    classDef server fill:#fcf,stroke:#333,stroke-width:1px,stroke-dasharray: 4 2
```
