# mohamedhishm/ai-prompt-library architecture

> Architecture diagram of the GitHub repository mohamedhishm/ai-prompt-library, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-10-15). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/mohamedhishm/ai-prompt-library
- Repository: https://github.com/mohamedhishm/ai-prompt-library

## Overview

AI Prompt Library is a terminal application for managing a local prompt collection and optionally improving prompts through Groq. The user starts at the menu; the main loop dispatches management, search, display, and enhancement actions. Prompt management and enhancement update the JSON library, while Markdown imports pass through a parser. The graph preserves README-documented capabilities; links involving the prompt-file collection and external Groq service reflect documented behavior, since those integrations were not fully sampled in source.

Main entry points: [`main.py`](https://github.com/mohamedhishm/ai-prompt-library/blob/main/main.py) (Menu Controller), [`prompt_manager.py`](https://github.com/mohamedhishm/ai-prompt-library/blob/main/prompt_manager.py) (Prompt Management), [`api_manager.py`](https://github.com/mohamedhishm/ai-prompt-library/blob/main/api_manager.py) (Enhancement Workflow), [`file_handler.py`](https://github.com/mohamedhishm/ai-prompt-library/blob/main/file_handler.py) (JSON Persistence)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_cli["Terminal Interface"]
  node_main["Menu Controller<br/>[main.py]"]
  node_display["Terminal Display<br/>[display.py]"]
end

subgraph group_library["Prompt Library"]
  node_manager["Prompt Management<br/>[prompt_manager.py]"]
  node_search["Prompt Search<br/>[search.py]"]
  node_parser["Markdown Parser<br/>[file_parser.py]"]
  node_storage["JSON Persistence<br/>[file_handler.py]"]
  node_store[("Prompt Collection<br/>[prompts.json]")]
  node_markdown["Bundled Markdown"]
end

subgraph group_enhancement["AI Enhancement"]
  node_ai_flow["Enhancement Workflow<br/>[api_manager.py]"]
  node_ai_handler["Groq Client<br/>[api_handler.py]"]
end

node_user(("User"))
node_groq{{"Groq API"}}

node_user -->|"chooses menu actions"| node_main
node_main -->|"shows menu"| node_display
node_main -->|"dispatches management"| node_manager
node_main -->|"dispatches searches"| node_search
node_main -->|"starts enhancement"| node_ai_flow
node_main -->|"loads collection"| node_storage
node_manager -->|"shows prompt details"| node_display
node_manager -->|"parses imports"| node_parser
node_manager -->|"saves changes"| node_storage
node_search -->|"shows matches"| node_display
node_storage -->|"reads and writes"| node_store
node_user -.->|"selects import file"| node_markdown
node_ai_flow -->|"shows selection"| node_display
node_ai_flow -->|"requests enhancement"| node_ai_handler
node_ai_flow -->|"saves result"| node_storage
node_ai_handler -->|"sends prompt"| node_groq
node_groq -->|"returns completion"| node_ai_handler

click node_main "https://github.com/mohamedhishm/ai-prompt-library/blob/main/main.py"
click node_display "https://github.com/mohamedhishm/ai-prompt-library/blob/main/display.py"
click node_manager "https://github.com/mohamedhishm/ai-prompt-library/blob/main/prompt_manager.py"
click node_search "https://github.com/mohamedhishm/ai-prompt-library/blob/main/search.py"
click node_parser "https://github.com/mohamedhishm/ai-prompt-library/blob/main/file_parser.py"
click node_storage "https://github.com/mohamedhishm/ai-prompt-library/blob/main/file_handler.py"
click node_store "https://github.com/mohamedhishm/ai-prompt-library/blob/main/prompts.json"
click node_markdown "https://github.com/mohamedhishm/ai-prompt-library/tree/main/prompts"
click node_ai_flow "https://github.com/mohamedhishm/ai-prompt-library/blob/main/api_manager.py"
click node_ai_handler "https://github.com/mohamedhishm/ai-prompt-library/blob/main/api_handler.py"

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_display,node_user toneBlue
class node_manager,node_search,node_parser,node_storage,node_store,node_markdown toneAmber
class node_ai_flow,node_ai_handler,node_groq toneMint
```

## Components

### Terminal Interface

- [Menu Controller](https://github.com/mohamedhishm/ai-prompt-library/blob/main/main.py): `main.py`
- [Terminal Display](https://github.com/mohamedhishm/ai-prompt-library/blob/main/display.py): `display.py`

### Prompt Library

- [Prompt Management](https://github.com/mohamedhishm/ai-prompt-library/blob/main/prompt_manager.py): `prompt_manager.py`
- [Prompt Search](https://github.com/mohamedhishm/ai-prompt-library/blob/main/search.py): `search.py`
- [Markdown Parser](https://github.com/mohamedhishm/ai-prompt-library/blob/main/file_parser.py): `file_parser.py`
- [JSON Persistence](https://github.com/mohamedhishm/ai-prompt-library/blob/main/file_handler.py): `file_handler.py`
- [Prompt Collection](https://github.com/mohamedhishm/ai-prompt-library/blob/main/prompts.json): `prompts.json`
- [Bundled Markdown](https://github.com/mohamedhishm/ai-prompt-library/tree/main/prompts): `prompts`

### AI Enhancement

- [Enhancement Workflow](https://github.com/mohamedhishm/ai-prompt-library/blob/main/api_manager.py): `api_manager.py`
- [Groq Client](https://github.com/mohamedhishm/ai-prompt-library/blob/main/api_handler.py): `api_handler.py`

### Other components

- **User**
- **Groq API**

## Connections

- User → Menu Controller: chooses menu actions (evidence: `README.md`)
- Menu Controller → Terminal Display: shows menu (evidence: `main.py`)
- Menu Controller → Prompt Management: dispatches management (evidence: `main.py`)
- Menu Controller → Prompt Search: dispatches searches (evidence: `main.py`)
- Menu Controller → Enhancement Workflow: starts enhancement (evidence: `main.py`)
- Menu Controller → JSON Persistence: loads collection (evidence: `main.py`)
- Prompt Management → Terminal Display: shows prompt details (evidence: `prompt_manager.py`)
- Prompt Management → Markdown Parser: parses imports (evidence: `prompt_manager.py`)
- Prompt Management → JSON Persistence: saves changes (evidence: `prompt_manager.py`)
- Prompt Search → Terminal Display: shows matches (evidence: `search.py`)
- JSON Persistence → Prompt Collection: reads and writes (evidence: `file_handler.py`)
- User → Bundled Markdown: selects import file (evidence: `README.md`)
- Enhancement Workflow → Terminal Display: shows selection (evidence: `api_manager.py`)
- Enhancement Workflow → Groq Client: requests enhancement (evidence: `api_manager.py`)
- Enhancement Workflow → JSON Persistence: saves result (evidence: `api_manager.py`)
- Groq Client → Groq API: sends prompt (evidence: `api_handler.py`)
- Groq API → Groq Client: returns completion (evidence: `api_handler.py`)
