# shahzaibkaramat67-coder/law_memory_agent architecture

> Architecture diagram of the GitHub repository shahzaibkaramat67-coder/law_memory_agent, 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/shahzaibkaramat67-coder/law_memory_agent
- Repository: https://github.com/shahzaibkaramat67-coder/law_memory_agent

## Overview

This is a small interactive chat program that asks a Gemini model questions and keeps the conversation in an in-memory message list. The user enters questions in a terminal; the agent adds each question to the history, invokes the model with that history, prints the reply, and appends it for the next turn. The initial system message says the assistant is medical, despite the terminal prompt describing legal questions. The graph reflects only the shown runtime; no README was provided.

Main entry points: [`agent.py`](https://github.com/shahzaibkaramat67-coder/law_memory_agent/blob/main/agent.py) (Chat loop), [`memorySystem.py`](https://github.com/shahzaibkaramat67-coder/law_memory_agent/blob/main/memorySystem.py) (System prompt), [`mian.py`](https://github.com/shahzaibkaramat67-coder/law_memory_agent/blob/main/mian.py) (Model setup)

## Diagram (Mermaid)

```mermaid
flowchart TD

node_user(("Terminal user"))
node_agent["Chat loop<br/>[agent.py]"]
node_memory_init["System prompt<br/>[memorySystem.py]"]
node_history["Message history<br/>[agent.py]"]
node_model_factory["Model setup<br/>[mian.py]"]
node_gemini["Gemini model"]

node_user -->|"enters questions"| node_agent
node_agent -->|"gets model"| node_model_factory
node_agent -->|"creates prompt"| node_memory_init
node_memory_init -->|"seeds history"| node_history
node_agent -->|"appends messages"| node_history
node_agent -->|"invokes with history"| node_gemini
node_model_factory -->|"configures model"| node_gemini
node_gemini -->|"returns reply"| node_agent

click node_agent "https://github.com/shahzaibkaramat67-coder/law_memory_agent/blob/main/agent.py"
click node_memory_init "https://github.com/shahzaibkaramat67-coder/law_memory_agent/blob/main/memorySystem.py"
click node_history "https://github.com/shahzaibkaramat67-coder/law_memory_agent/blob/main/agent.py"
click node_model_factory "https://github.com/shahzaibkaramat67-coder/law_memory_agent/blob/main/mian.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_user toneBlue
class node_agent,node_memory_init,node_history toneTeal
class node_model_factory,node_gemini toneIndigo
```

## Components

### Other components

- **Terminal user**
- [Chat loop](https://github.com/shahzaibkaramat67-coder/law_memory_agent/blob/main/agent.py): `agent.py`
- [System prompt](https://github.com/shahzaibkaramat67-coder/law_memory_agent/blob/main/memorySystem.py): `memorySystem.py`
- [Message history](https://github.com/shahzaibkaramat67-coder/law_memory_agent/blob/main/agent.py): `agent.py`
- [Model setup](https://github.com/shahzaibkaramat67-coder/law_memory_agent/blob/main/mian.py): `mian.py`
- **Gemini model**

## Connections

- Terminal user → Chat loop: enters questions (evidence: `agent.py`)
- Chat loop → Model setup: gets model (evidence: `agent.py`)
- Chat loop → System prompt: creates prompt (evidence: `agent.py`)
- System prompt → Message history: seeds history (evidence: `memorySystem.py`)
- Chat loop → Message history: appends messages (evidence: `agent.py`)
- Chat loop → Gemini model: invokes with history (evidence: `agent.py`)
- Model setup → Gemini model: configures model (evidence: `mian.py`)
- Gemini model → Chat loop: returns reply (evidence: `agent.py`)
