# vivekmane57/greatcards-bot architecture

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

- Interactive diagram: https://gitdiagram.com/vivekmane57/greatcards-bot
- Repository: https://github.com/vivekmane57/greatcards-bot

## Overview

Great.cards is a credit-card advice chatbot with Streamlit and CLI interfaces. A user describes their spending or asks about cards; the bot builds a provider-specific LLM conversation, dispatches requested Great.cards MCP tools, and returns an answer with tool-call traces and warnings. Guardrails validate amounts and flag risky claims, while postchecks add caveats derived from tool data. The README documents additional tool capabilities not individually visible in the sampled bot excerpt; those are shown as external MCP operations. The MCP implementation itself is outside this repository.

Main entry points: [`bot.py`](https://github.com/vivekmane57/greatcards-bot/blob/main/bot.py) (Turn orchestrator), [`app.py`](https://github.com/vivekmane57/greatcards-bot/blob/main/app.py) (Streamlit chat), [`cli.py`](https://github.com/vivekmane57/greatcards-bot/blob/main/cli.py) (Command-line chat), [`prompts.py`](https://github.com/vivekmane57/greatcards-bot/blob/main/prompts.py) (System prompts)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_interfaces["User interfaces"]
  node_web["Streamlit chat<br/>[app.py]"]
  node_cli["Command-line chat<br/>[cli.py]"]
end

subgraph group_assistant["Assistant runtime"]
  node_bot["Turn orchestrator<br/>[bot.py]"]
  node_prompts["System prompts<br/>[prompts.py]"]
end

subgraph group_safeguards["Answer safeguards"]
  node_guardrails["Code guardrails<br/>[guardrails.py]"]
  node_postchecks["Tool-data notes<br/>[postchecks.py]"]
end

node_user(("Card seeker"))
node_llm["LLM provider"]
node_mcp["Great.cards MCP"]
node_recommend["Spend recommendations"]
node_details["Card details"]
node_compare["Card comparison"]
node_eligibility["Eligibility check"]
node_resolve["Card-name resolver"]
node_listcards["Card listing"]
node_advisor["Advisor context"]

node_user -->|"enters request"| node_web
node_user -->|"enters request"| node_cli
node_web -->|"submits turn"| node_bot
node_cli -->|"submits turn"| node_bot
node_bot -->|"selects prompt"| node_prompts
node_bot -->|"sends conversation"| node_llm
node_llm -->|"returns response"| node_bot
node_bot -->|"calls tools"| node_mcp
node_mcp -->|"provides operation"| node_recommend
node_mcp -->|"provides operation"| node_details
node_mcp -->|"provides operation"| node_compare
node_mcp -->|"provides operation"| node_eligibility
node_mcp -->|"provides operation"| node_resolve
node_mcp -->|"provides operation"| node_listcards
node_mcp -->|"provides operation"| node_advisor
node_bot -->|"validates answer"| node_guardrails
node_bot -->|"adds caveats"| node_postchecks
node_bot -->|"returns reply and trace"| node_web
node_bot -->|"returns reply and warnings"| node_cli

click node_web "https://github.com/vivekmane57/greatcards-bot/blob/main/app.py"
click node_cli "https://github.com/vivekmane57/greatcards-bot/blob/main/cli.py"
click node_bot "https://github.com/vivekmane57/greatcards-bot/blob/main/bot.py"
click node_prompts "https://github.com/vivekmane57/greatcards-bot/blob/main/prompts.py"
click node_guardrails "https://github.com/vivekmane57/greatcards-bot/blob/main/guardrails.py"
click node_postchecks "https://github.com/vivekmane57/greatcards-bot/blob/main/postchecks.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_web,node_cli toneBlue
class node_bot,node_prompts toneAmber
class node_guardrails,node_postchecks toneMint
class node_user,node_llm,node_mcp,node_recommend,node_details,node_compare,node_eligibility,node_resolve,node_listcards,node_advisor toneIndigo
```

## Components

### User interfaces

- [Streamlit chat](https://github.com/vivekmane57/greatcards-bot/blob/main/app.py): `app.py`
- [Command-line chat](https://github.com/vivekmane57/greatcards-bot/blob/main/cli.py): `cli.py`

### Assistant runtime

- [Turn orchestrator](https://github.com/vivekmane57/greatcards-bot/blob/main/bot.py): `bot.py`
- [System prompts](https://github.com/vivekmane57/greatcards-bot/blob/main/prompts.py): `prompts.py`

### Answer safeguards

- [Code guardrails](https://github.com/vivekmane57/greatcards-bot/blob/main/guardrails.py): `guardrails.py`
- [Tool-data notes](https://github.com/vivekmane57/greatcards-bot/blob/main/postchecks.py): `postchecks.py`

### Other components

- **Card seeker**
- **LLM provider**
- **Great.cards MCP**
- **Spend recommendations**
- **Card details**
- **Card comparison**
- **Eligibility check**
- **Card-name resolver**
- **Card listing**
- **Advisor context**

## Connections

- Card seeker → Streamlit chat: enters request (evidence: `app.py`)
- Card seeker → Command-line chat: enters request (evidence: `cli.py`)
- Streamlit chat → Turn orchestrator: submits turn (evidence: `app.py`)
- Command-line chat → Turn orchestrator: submits turn (evidence: `cli.py`)
- Turn orchestrator → System prompts: selects prompt (evidence: `bot.py`)
- Turn orchestrator → LLM provider: sends conversation (evidence: `bot.py`)
- LLM provider → Turn orchestrator: returns response (evidence: `bot.py`)
- Turn orchestrator → Great.cards MCP: calls tools (evidence: `bot.py`)
- Great.cards MCP → Spend recommendations: provides operation (evidence: `README.md`)
- Great.cards MCP → Card details: provides operation (evidence: `README.md`)
- Great.cards MCP → Card comparison: provides operation (evidence: `README.md`)
- Great.cards MCP → Eligibility check: provides operation (evidence: `README.md`)
- Great.cards MCP → Card-name resolver: provides operation (evidence: `README.md`)
- Great.cards MCP → Card listing: provides operation (evidence: `README.md`)
- Great.cards MCP → Advisor context: provides operation
- Turn orchestrator → Code guardrails: validates answer (evidence: `README.md`)
- Turn orchestrator → Tool-data notes: adds caveats (evidence: `README.md`)
- Turn orchestrator → Streamlit chat: returns reply and trace (evidence: `app.py`)
- Turn orchestrator → Command-line chat: returns reply and warnings (evidence: `cli.py`)
