# atharva557/prompt-chaining architecture

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

- Interactive diagram: https://gitdiagram.com/atharva557/prompt-chaining
- Repository: https://github.com/atharva557/prompt-chaining

## Overview

PromptChain combines a Streamlit two-model workflow—task entry, prompt drafting and human review, code generation, refinement, and saving—with a reusable model-management library and MCP server. The graph preserves README-described capabilities such as chats, presets, profiles, history, and model discovery. Some connections are documented by the README or SOURCE INDEX rather than sampled call sites; unsampled internals are not inferred beyond those references.

Main entry points: [`app.py`](https://github.com/atharva557/prompt-chaining/blob/master/app.py) (App workflow), [`core/api.py`](https://github.com/atharva557/prompt-chaining/blob/master/core/api.py) (App API facade), [`src/promptchain/manager.py`](https://github.com/atharva557/prompt-chaining/blob/master/src/promptchain/manager.py) (Model manager), [`src/promptchain/streaming.py`](https://github.com/atharva557/prompt-chaining/blob/master/src/promptchain/streaming.py) (Generation streaming)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_app["Streamlit app"]
  node_app_entry["App workflow<br/>[app.py]"]
  node_task["Task and presets<br/>[task_input.py]"]
  node_review["Prompt review<br/>[prompt_review.py]"]
  node_output["Code output<br/>[code_output.py]"]
  node_chat["Direct chats<br/>[chat.py]"]
  node_settings["Settings<br/>[settings.py]"]
  node_landing["Landing page<br/>[landing.py]"]
  node_styles["UI styling<br/>[styles.py]"]
end

subgraph group_app_support["App support"]
  node_config["Configuration and profiles<br/>[config.py]"]
  node_history[("Run history<br/>[history.py]")]
  node_suggest["Preset suggestions<br/>[suggest.py]"]
  node_preset_data["Built-in presets<br/>[presets.json]"]
  node_app_api["App API facade<br/>[api.py]"]
  node_app_stream["App streaming adapter<br/>[streaming.py]"]
end

subgraph group_library["Model control"]
  node_manager["Model manager<br/>[manager.py]"]
  node_endpoint["Endpoint definitions<br/>[endpoint.py]"]
  node_endpoint_file["Endpoint persistence<br/>[endpoints_file.py]"]
  node_lifecycle["Model lifecycle<br/>[lifecycle.py]"]
  node_discovery["Model discovery<br/>[discovery.py]"]
  node_streaming["Generation streaming<br/>[streaming.py]"]
  node_costs["Token and cost estimates<br/>[costs.py]"]
end

subgraph group_integrations["Backends and MCP"]
  node_backends["Backend registry<br/>[backends.py]"]
  node_mcp["MCP server<br/>[mcp_server.py]"]
end

node_user(("User"))
node_local_models[("Local model servers")]
node_cloud_models[("Cloud model APIs")]
node_agent(("Coding agent"))

node_user -->|"uses"| node_app_entry
node_app_entry -->|"renders"| node_task
node_app_entry -->|"renders"| node_review
node_app_entry -->|"renders"| node_output
node_app_entry -->|"routes to"| node_chat
node_app_entry -->|"renders"| node_settings
node_app_entry -->|"renders"| node_landing
node_app_entry -->|"uses"| node_styles
node_app_entry -->|"loads"| node_config
node_app_entry -->|"reads"| node_history
node_task -->|"requests suggestions"| node_suggest
node_task -->|"updates profiles"| node_config
node_task -.->|"uses presets"| node_preset_data
node_app_entry -->|"calls"| node_app_api
node_app_entry -->|"calls"| node_app_stream
node_app_api -->|"re-exports"| node_backends
node_app_api -->|"re-exports"| node_discovery
node_app_api -->|"re-exports"| node_lifecycle
node_app_api -->|"re-exports"| node_streaming
node_app_api -->|"re-exports"| node_costs
node_app_stream -->|"delegates to"| node_streaming
node_output -->|"uses"| node_app_api
node_chat -->|"uses"| node_app_api
node_chat -->|"uses"| node_app_stream
node_settings -->|"uses"| node_app_api
node_settings -->|"uses"| node_config
node_manager -->|"manages"| node_lifecycle
node_manager -->|"uses"| node_endpoint
node_manager -->|"streams via"| node_streaming
node_manager -->|"estimates costs"| node_costs
node_endpoint -->|"uses"| node_backends
node_endpoint_file -->|"loads and saves"| node_endpoint
node_endpoint_file -.->|"configures"| node_manager
node_discovery -->|"uses"| node_backends
node_lifecycle -->|"uses"| node_backends
node_streaming -->|"uses"| node_backends
node_discovery -->|"queries models"| node_local_models
node_discovery -->|"queries models"| node_cloud_models
node_lifecycle -->|"loads and unloads"| node_local_models
node_streaming -->|"streams requests"| node_local_models
node_streaming -->|"streams requests"| node_cloud_models
node_agent -->|"invokes tools"| node_mcp
node_mcp -->|"controls models"| node_manager
node_mcp -->|"calls"| node_lifecycle
node_mcp -->|"calls"| node_discovery
node_mcp -->|"uses"| node_endpoint_file

click node_app_entry "https://github.com/atharva557/prompt-chaining/blob/master/app.py"
click node_task "https://github.com/atharva557/prompt-chaining/blob/master/ui/task_input.py"
click node_review "https://github.com/atharva557/prompt-chaining/blob/master/ui/prompt_review.py"
click node_output "https://github.com/atharva557/prompt-chaining/blob/master/ui/code_output.py"
click node_chat "https://github.com/atharva557/prompt-chaining/blob/master/ui/chat.py"
click node_settings "https://github.com/atharva557/prompt-chaining/blob/master/ui/settings.py"
click node_landing "https://github.com/atharva557/prompt-chaining/blob/master/ui/landing.py"
click node_styles "https://github.com/atharva557/prompt-chaining/blob/master/ui/styles.py"
click node_config "https://github.com/atharva557/prompt-chaining/blob/master/core/config.py"
click node_history "https://github.com/atharva557/prompt-chaining/blob/master/core/history.py"
click node_suggest "https://github.com/atharva557/prompt-chaining/blob/master/core/suggest.py"
click node_preset_data "https://github.com/atharva557/prompt-chaining/blob/master/presets/presets.json"
click node_app_api "https://github.com/atharva557/prompt-chaining/blob/master/core/api.py"
click node_app_stream "https://github.com/atharva557/prompt-chaining/blob/master/core/streaming.py"
click node_manager "https://github.com/atharva557/prompt-chaining/blob/master/src/promptchain/manager.py"
click node_endpoint "https://github.com/atharva557/prompt-chaining/blob/master/src/promptchain/endpoint.py"
click node_endpoint_file "https://github.com/atharva557/prompt-chaining/blob/master/src/promptchain/endpoints_file.py"
click node_lifecycle "https://github.com/atharva557/prompt-chaining/blob/master/src/promptchain/lifecycle.py"
click node_discovery "https://github.com/atharva557/prompt-chaining/blob/master/src/promptchain/discovery.py"
click node_streaming "https://github.com/atharva557/prompt-chaining/blob/master/src/promptchain/streaming.py"
click node_costs "https://github.com/atharva557/prompt-chaining/blob/master/src/promptchain/costs.py"
click node_backends "https://github.com/atharva557/prompt-chaining/blob/master/src/promptchain/backends.py"
click node_mcp "https://github.com/atharva557/prompt-chaining/blob/master/src/promptchain/mcp_server.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_app_entry,node_task,node_review,node_output,node_chat,node_settings,node_landing,node_styles,node_user toneBlue
class node_config,node_history,node_suggest,node_preset_data,node_app_api,node_app_stream,node_local_models,node_cloud_models toneAmber
class node_manager,node_endpoint,node_endpoint_file,node_lifecycle,node_discovery,node_streaming,node_costs toneMint
class node_backends,node_mcp toneRose
class node_agent toneIndigo
```

## Components

### Streamlit app

- [App workflow](https://github.com/atharva557/prompt-chaining/blob/master/app.py): `app.py`
- [Task and presets](https://github.com/atharva557/prompt-chaining/blob/master/ui/task_input.py): `ui/task_input.py`
- [Prompt review](https://github.com/atharva557/prompt-chaining/blob/master/ui/prompt_review.py): `ui/prompt_review.py`
- [Code output](https://github.com/atharva557/prompt-chaining/blob/master/ui/code_output.py): `ui/code_output.py`
- [Direct chats](https://github.com/atharva557/prompt-chaining/blob/master/ui/chat.py): `ui/chat.py`
- [Settings](https://github.com/atharva557/prompt-chaining/blob/master/ui/settings.py): `ui/settings.py`
- [Landing page](https://github.com/atharva557/prompt-chaining/blob/master/ui/landing.py): `ui/landing.py`
- [UI styling](https://github.com/atharva557/prompt-chaining/blob/master/ui/styles.py): `ui/styles.py`

### App support

- [Configuration and profiles](https://github.com/atharva557/prompt-chaining/blob/master/core/config.py): `core/config.py`
- [Run history](https://github.com/atharva557/prompt-chaining/blob/master/core/history.py): `core/history.py`
- [Preset suggestions](https://github.com/atharva557/prompt-chaining/blob/master/core/suggest.py): `core/suggest.py`
- [Built-in presets](https://github.com/atharva557/prompt-chaining/blob/master/presets/presets.json): `presets/presets.json`
- [App API facade](https://github.com/atharva557/prompt-chaining/blob/master/core/api.py): `core/api.py`
- [App streaming adapter](https://github.com/atharva557/prompt-chaining/blob/master/core/streaming.py): `core/streaming.py`

### Model control

- [Model manager](https://github.com/atharva557/prompt-chaining/blob/master/src/promptchain/manager.py): `src/promptchain/manager.py`
- [Endpoint definitions](https://github.com/atharva557/prompt-chaining/blob/master/src/promptchain/endpoint.py): `src/promptchain/endpoint.py`
- [Endpoint persistence](https://github.com/atharva557/prompt-chaining/blob/master/src/promptchain/endpoints_file.py): `src/promptchain/endpoints_file.py`
- [Model lifecycle](https://github.com/atharva557/prompt-chaining/blob/master/src/promptchain/lifecycle.py): `src/promptchain/lifecycle.py`
- [Model discovery](https://github.com/atharva557/prompt-chaining/blob/master/src/promptchain/discovery.py): `src/promptchain/discovery.py`
- [Generation streaming](https://github.com/atharva557/prompt-chaining/blob/master/src/promptchain/streaming.py): `src/promptchain/streaming.py`
- [Token and cost estimates](https://github.com/atharva557/prompt-chaining/blob/master/src/promptchain/costs.py): `src/promptchain/costs.py`

### Backends and MCP

- [Backend registry](https://github.com/atharva557/prompt-chaining/blob/master/src/promptchain/backends.py): `src/promptchain/backends.py`
- [MCP server](https://github.com/atharva557/prompt-chaining/blob/master/src/promptchain/mcp_server.py): `src/promptchain/mcp_server.py`

### Other components

- **User**
- **Local model servers**
- **Cloud model APIs**
- **Coding agent**

## Connections

- User → App workflow: uses (evidence: `README.md`)
- App workflow → Task and presets: renders (evidence: `app.py`)
- App workflow → Prompt review: renders (evidence: `app.py`)
- App workflow → Code output: renders (evidence: `app.py`)
- App workflow → Direct chats: routes to (evidence: `app.py`)
- App workflow → Settings: renders (evidence: `app.py`)
- App workflow → Landing page: renders (evidence: `app.py`)
- App workflow → UI styling: uses (evidence: `app.py`)
- App workflow → Configuration and profiles: loads (evidence: `app.py`)
- App workflow → Run history: reads (evidence: `app.py`)
- Task and presets → Preset suggestions: requests suggestions (evidence: `ui/task_input.py`)
- Task and presets → Configuration and profiles: updates profiles (evidence: `ui/task_input.py`)
- Task and presets → Built-in presets: uses presets (evidence: `README.md`)
- App workflow → App API facade: calls (evidence: `app.py`)
- App workflow → App streaming adapter: calls (evidence: `app.py`)
- App API facade → Backend registry: re-exports (evidence: `core/api.py`)
- App API facade → Model discovery: re-exports (evidence: `core/api.py`)
- App API facade → Model lifecycle: re-exports (evidence: `core/api.py`)
- App API facade → Generation streaming: re-exports (evidence: `core/api.py`)
- App API facade → Token and cost estimates: re-exports (evidence: `core/api.py`)
- App streaming adapter → Generation streaming: delegates to (evidence: `core/streaming.py`)
- Code output → App API facade: uses (evidence: `ui/code_output.py`)
- Direct chats → App API facade: uses (evidence: `ui/chat.py`)
- Direct chats → App streaming adapter: uses (evidence: `ui/chat.py`)
- Settings → App API facade: uses (evidence: `ui/settings.py`)
- Settings → Configuration and profiles: uses (evidence: `ui/settings.py`)
- Model manager → Model lifecycle: manages (evidence: `src/promptchain/manager.py`)
- Model manager → Endpoint definitions: uses (evidence: `src/promptchain/manager.py`)
- Model manager → Generation streaming: streams via (evidence: `src/promptchain/manager.py`)
- Model manager → Token and cost estimates: estimates costs (evidence: `src/promptchain/manager.py`)
- Endpoint definitions → Backend registry: uses (evidence: `src/promptchain/endpoint.py`)
- Endpoint persistence → Endpoint definitions: loads and saves (evidence: `src/promptchain/endpoints_file.py`)
- Endpoint persistence → Model manager: configures (evidence: `src/promptchain/endpoints_file.py`)
- Model discovery → Backend registry: uses (evidence: `src/promptchain/discovery.py`)
- Model lifecycle → Backend registry: uses (evidence: `src/promptchain/lifecycle.py`)
- Generation streaming → Backend registry: uses (evidence: `src/promptchain/streaming.py`)
- Model discovery → Local model servers: queries models (evidence: `src/promptchain/discovery.py`)
- Model discovery → Cloud model APIs: queries models (evidence: `src/promptchain/discovery.py`)
- Model lifecycle → Local model servers: loads and unloads (evidence: `src/promptchain/lifecycle.py`)
- Generation streaming → Local model servers: streams requests (evidence: `src/promptchain/streaming.py`)
- Generation streaming → Cloud model APIs: streams requests (evidence: `src/promptchain/streaming.py`)
- Coding agent → MCP server: invokes tools (evidence: `README.md`)
- MCP server → Model manager: controls models (evidence: `src/promptchain/mcp_server.py`)
- MCP server → Model lifecycle: calls (evidence: `src/promptchain/mcp_server.py`)
- MCP server → Model discovery: calls (evidence: `src/promptchain/mcp_server.py`)
- MCP server → Endpoint persistence: uses (evidence: `src/promptchain/mcp_server.py`)
