# mkatika37/credit-memo-assistant architecture

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

- Interactive diagram: https://gitdiagram.com/mkatika37/credit-memo-assistant
- Repository: https://github.com/mkatika37/credit-memo-assistant

## Overview

This is an AI mortgage credit-memo assistant: it automates memo assembly, not lending decisions. An underwriter submits an application through the Streamlit console; the API validates it, runs a bounded LangGraph assessment, checks the drafted memo, persists an audit record, and returns it for human review. The graph computes metrics and retrieves policy before triage, which may investigate missing or borderline cases or gather supporting documents. Portfolio policy-impact simulation is a separate capability. Relationships follow the documented workflow and shown source calls; some unsampled implementation details are represented only at subsystem level.

Main entry points: [`app/agent.py`](https://github.com/mkatika37/credit-memo-assistant/blob/master/app/agent.py) (LangGraph workflow), [`app/main.py`](https://github.com/mkatika37/credit-memo-assistant/blob/master/app/main.py) (FastAPI service), [`app/policy_impact.py`](https://github.com/mkatika37/credit-memo-assistant/blob/master/app/policy_impact.py) (Policy impact simulation), [`frontend/app.py`](https://github.com/mkatika37/credit-memo-assistant/blob/master/frontend/app.py) (Streamlit console)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_console["Underwriter console"]
  node_console_ui["Streamlit console<br/>[app.py]"]
  node_ui_pages["Assessment and portfolio pages"]
  node_policy_page["Policy impact page"]
  node_api_client["API client helpers<br/>[common.py]"]
end

subgraph group_assessment["Credit assessment"]
  node_api["FastAPI service<br/>[main.py]"]
  node_agent["LangGraph workflow<br/>[agent.py]"]
  node_ingest["Application ingest<br/>[nodes.py]"]
  node_metrics["Deterministic scoring<br/>[metrics.py]"]
  node_risk_triage["Risk assessment and triage<br/>[nodes.py]"]
  node_investigation["Case investigation<br/>[nodes.py]"]
  node_memo_drafting["Memo drafting<br/>[nodes.py]"]
  node_llm_client["LLM provider client<br/>[llm.py]"]
end

subgraph group_evidence["Policy and evidence"]
  node_policy_retrieval["Policy retrieval<br/>[rag.py]"]
  node_policy_corpus["Lending policy corpus"]
  node_evidence_gathering["Document evidence gathering<br/>[nodes.py]"]
  node_loan_documents["Loan evidence documents"]
end

subgraph group_governance["Controls and audit"]
  node_input_controls{{"Input guardrails<br/>[guardrails.py]"}}
  node_review_gate["Human-review gate<br/>[nodes.py]"]
  node_output_controls{{"Output grounding checks<br/>[guardrails.py]"}}
  node_audit_store[("Audit and portfolio store<br/>[db.py]")]
  node_observability["Request observability<br/>[observability.py]"]
  node_evaluation["Evaluation suite<br/>[run.py]"]
end

subgraph group_portfolio["Portfolio analysis"]
  node_portfolio_impact["Policy impact simulation<br/>[policy_impact.py]"]
  node_policy_rules["Policy thresholds<br/>[policy.py]"]
end

node_underwriter(("Underwriter"))
node_llm_provider{{"Anthropic or OpenAI"}}

node_underwriter -->|"uses"| node_console_ui
node_console_ui -->|"navigates"| node_ui_pages
node_console_ui -->|"navigates"| node_policy_page
node_ui_pages -->|"calls"| node_api_client
node_policy_page -->|"calls"| node_api_client
node_api_client -->|"sends requests"| node_api
node_api -->|"validates input"| node_input_controls
node_api -->|"runs workflow"| node_agent
node_agent -->|"dispatches"| node_ingest
node_ingest -->|"computes ratios"| node_metrics
node_agent -->|"dispatches scoring"| node_metrics
node_agent -->|"dispatches retrieval"| node_policy_retrieval
node_policy_retrieval -->|"retrieves chunks"| node_policy_corpus
node_agent -->|"dispatches"| node_risk_triage
node_risk_triage -->|"routes cases"| node_investigation
node_investigation -->|"reassesses via"| node_metrics
node_risk_triage -->|"routes cases"| node_evidence_gathering
node_evidence_gathering -->|"fetches evidence"| node_loan_documents
node_agent -->|"dispatches"| node_memo_drafting
node_memo_drafting -->|"drafts with"| node_llm_client
node_llm_client -->|"invokes"| node_llm_provider
node_agent -->|"dispatches"| node_review_gate
node_api -->|"checks memo"| node_output_controls
node_api -->|"persists audit"| node_audit_store
node_agent -->|"instruments nodes"| node_observability
node_api -->|"reports metrics"| node_observability
node_policy_page -->|"requests simulation"| node_portfolio_impact
node_api -->|"runs analysis"| node_portfolio_impact
node_portfolio_impact -->|"loads portfolio"| node_audit_store
node_portfolio_impact -->|"applies changes"| node_policy_rules
node_portfolio_impact -->|"drafts report"| node_llm_client
node_underwriter -.->|"can run evaluation"| node_evaluation

click node_console_ui "https://github.com/mkatika37/credit-memo-assistant/blob/master/frontend/app.py"
click node_ui_pages "https://github.com/mkatika37/credit-memo-assistant/blob/master/frontend/pages_new_assessment.py"
click node_policy_page "https://github.com/mkatika37/credit-memo-assistant/blob/master/frontend/pages_policy_impact.py"
click node_api_client "https://github.com/mkatika37/credit-memo-assistant/blob/master/frontend/common.py"
click node_api "https://github.com/mkatika37/credit-memo-assistant/blob/master/app/main.py"
click node_input_controls "https://github.com/mkatika37/credit-memo-assistant/blob/master/app/guardrails.py"
click node_agent "https://github.com/mkatika37/credit-memo-assistant/blob/master/app/agent.py"
click node_ingest "https://github.com/mkatika37/credit-memo-assistant/blob/master/app/nodes.py"
click node_metrics "https://github.com/mkatika37/credit-memo-assistant/blob/master/app/metrics.py"
click node_policy_retrieval "https://github.com/mkatika37/credit-memo-assistant/blob/master/app/rag.py"
click node_policy_corpus "https://github.com/mkatika37/credit-memo-assistant/tree/master/data/policies"
click node_risk_triage "https://github.com/mkatika37/credit-memo-assistant/blob/master/app/nodes.py"
click node_investigation "https://github.com/mkatika37/credit-memo-assistant/blob/master/app/nodes.py"
click node_evidence_gathering "https://github.com/mkatika37/credit-memo-assistant/blob/master/app/nodes.py"
click node_loan_documents "https://github.com/mkatika37/credit-memo-assistant/tree/master/data/documents"
click node_memo_drafting "https://github.com/mkatika37/credit-memo-assistant/blob/master/app/nodes.py"
click node_llm_client "https://github.com/mkatika37/credit-memo-assistant/blob/master/app/llm.py"
click node_review_gate "https://github.com/mkatika37/credit-memo-assistant/blob/master/app/nodes.py"
click node_output_controls "https://github.com/mkatika37/credit-memo-assistant/blob/master/app/guardrails.py"
click node_audit_store "https://github.com/mkatika37/credit-memo-assistant/blob/master/app/db.py"
click node_observability "https://github.com/mkatika37/credit-memo-assistant/blob/master/app/observability.py"
click node_portfolio_impact "https://github.com/mkatika37/credit-memo-assistant/blob/master/app/policy_impact.py"
click node_policy_rules "https://github.com/mkatika37/credit-memo-assistant/blob/master/app/policy.py"
click node_evaluation "https://github.com/mkatika37/credit-memo-assistant/blob/master/eval/run.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_console_ui,node_ui_pages,node_policy_page,node_api_client toneBlue
class node_api,node_agent,node_ingest,node_metrics,node_risk_triage,node_investigation,node_memo_drafting,node_llm_client toneAmber
class node_policy_retrieval,node_policy_corpus,node_evidence_gathering,node_loan_documents toneMint
class node_input_controls,node_review_gate,node_output_controls,node_audit_store,node_observability,node_evaluation toneRose
class node_portfolio_impact,node_policy_rules,node_underwriter,node_llm_provider toneIndigo
```

## Components

### Underwriter console

- [Streamlit console](https://github.com/mkatika37/credit-memo-assistant/blob/master/frontend/app.py): `frontend/app.py`
- [Assessment and portfolio pages](https://github.com/mkatika37/credit-memo-assistant/blob/master/frontend/pages_new_assessment.py): `frontend/pages_new_assessment.py`
- [Policy impact page](https://github.com/mkatika37/credit-memo-assistant/blob/master/frontend/pages_policy_impact.py): `frontend/pages_policy_impact.py`
- [API client helpers](https://github.com/mkatika37/credit-memo-assistant/blob/master/frontend/common.py): `frontend/common.py`

### Credit assessment

- [FastAPI service](https://github.com/mkatika37/credit-memo-assistant/blob/master/app/main.py): `app/main.py`
- [LangGraph workflow](https://github.com/mkatika37/credit-memo-assistant/blob/master/app/agent.py): `app/agent.py`
- [Application ingest](https://github.com/mkatika37/credit-memo-assistant/blob/master/app/nodes.py): `app/nodes.py`
- [Deterministic scoring](https://github.com/mkatika37/credit-memo-assistant/blob/master/app/metrics.py): `app/metrics.py`
- [Risk assessment and triage](https://github.com/mkatika37/credit-memo-assistant/blob/master/app/nodes.py): `app/nodes.py`
- [Case investigation](https://github.com/mkatika37/credit-memo-assistant/blob/master/app/nodes.py): `app/nodes.py`
- [Memo drafting](https://github.com/mkatika37/credit-memo-assistant/blob/master/app/nodes.py): `app/nodes.py`
- [LLM provider client](https://github.com/mkatika37/credit-memo-assistant/blob/master/app/llm.py): `app/llm.py`

### Policy and evidence

- [Policy retrieval](https://github.com/mkatika37/credit-memo-assistant/blob/master/app/rag.py): `app/rag.py`
- [Lending policy corpus](https://github.com/mkatika37/credit-memo-assistant/tree/master/data/policies): `data/policies`
- [Document evidence gathering](https://github.com/mkatika37/credit-memo-assistant/blob/master/app/nodes.py): `app/nodes.py`
- [Loan evidence documents](https://github.com/mkatika37/credit-memo-assistant/tree/master/data/documents): `data/documents`

### Controls and audit

- [Input guardrails](https://github.com/mkatika37/credit-memo-assistant/blob/master/app/guardrails.py): `app/guardrails.py`
- [Human-review gate](https://github.com/mkatika37/credit-memo-assistant/blob/master/app/nodes.py): `app/nodes.py`
- [Output grounding checks](https://github.com/mkatika37/credit-memo-assistant/blob/master/app/guardrails.py): `app/guardrails.py`
- [Audit and portfolio store](https://github.com/mkatika37/credit-memo-assistant/blob/master/app/db.py): `app/db.py`
- [Request observability](https://github.com/mkatika37/credit-memo-assistant/blob/master/app/observability.py): `app/observability.py`
- [Evaluation suite](https://github.com/mkatika37/credit-memo-assistant/blob/master/eval/run.py): `eval/run.py`

### Portfolio analysis

- [Policy impact simulation](https://github.com/mkatika37/credit-memo-assistant/blob/master/app/policy_impact.py): `app/policy_impact.py`
- [Policy thresholds](https://github.com/mkatika37/credit-memo-assistant/blob/master/app/policy.py): `app/policy.py`

### Other components

- **Underwriter**
- **Anthropic or OpenAI**

## Connections

- Underwriter → Streamlit console: uses (evidence: `README.md`)
- Streamlit console → Assessment and portfolio pages: navigates (evidence: `frontend/app.py`)
- Streamlit console → Policy impact page: navigates (evidence: `frontend/app.py`)
- Assessment and portfolio pages → API client helpers: calls (evidence: `frontend/common.py`)
- Policy impact page → API client helpers: calls (evidence: `frontend/common.py`)
- API client helpers → FastAPI service: sends requests (evidence: `frontend/common.py`)
- FastAPI service → Input guardrails: validates input (evidence: `README.md`)
- FastAPI service → LangGraph workflow: runs workflow (evidence: `README.md`)
- LangGraph workflow → Application ingest: dispatches (evidence: `app/agent.py`)
- Application ingest → Deterministic scoring: computes ratios (evidence: `app/nodes.py`)
- LangGraph workflow → Deterministic scoring: dispatches scoring (evidence: `app/agent.py`)
- LangGraph workflow → Policy retrieval: dispatches retrieval (evidence: `app/agent.py`)
- Policy retrieval → Lending policy corpus: retrieves chunks (evidence: `README.md`)
- LangGraph workflow → Risk assessment and triage: dispatches (evidence: `app/agent.py`)
- Risk assessment and triage → Case investigation: routes cases (evidence: `app/agent.py`)
- Case investigation → Deterministic scoring: reassesses via (evidence: `app/nodes.py`)
- Risk assessment and triage → Document evidence gathering: routes cases (evidence: `app/agent.py`)
- Document evidence gathering → Loan evidence documents: fetches evidence (evidence: `README.md`)
- LangGraph workflow → Memo drafting: dispatches (evidence: `app/agent.py`)
- Memo drafting → LLM provider client: drafts with (evidence: `app/nodes.py`)
- LLM provider client → Anthropic or OpenAI: invokes (evidence: `app/llm.py`)
- LangGraph workflow → Human-review gate: dispatches (evidence: `app/agent.py`)
- FastAPI service → Output grounding checks: checks memo (evidence: `app/main.py`)
- FastAPI service → Audit and portfolio store: persists audit (evidence: `app/main.py`)
- LangGraph workflow → Request observability: instruments nodes (evidence: `app/agent.py`)
- FastAPI service → Request observability: reports metrics (evidence: `app/main.py`)
- Policy impact page → Policy impact simulation: requests simulation (evidence: `README.md`)
- FastAPI service → Policy impact simulation: runs analysis (evidence: `app/main.py`)
- Policy impact simulation → Audit and portfolio store: loads portfolio (evidence: `app/policy_impact.py`)
- Policy impact simulation → Policy thresholds: applies changes (evidence: `app/policy_impact.py`)
- Policy impact simulation → LLM provider client: drafts report (evidence: `app/policy_impact.py`)
- Underwriter → Evaluation suite: can run evaluation (evidence: `README.md`)
