# jehbath/al-musaid-2.0 architecture

> Architecture diagram of the GitHub repository jehbath/al-musaid-2.0, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-30). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/jehbath/al-musaid-2.0
- Repository: https://github.com/jehbath/al-musaid-2.0

## Overview

Al-Musaid 2.0 is an Arabic banking assistant with chat, account-aware banking tools, general banking answers, location search, exchange rates, and authenticated or guest conversations. The main workflow runs from the React chat through the API to the FastAPI chat route and Assistant, which interprets requests, consults memory, and can use Gemini, RAG, or MCP tools before returning a response. The graph also includes authentication, conversation history, and UI components. Some MCP server dispatch details and unsampled capabilities are documented but not verified in excerpts.

Main entry points: [`frontend/src/App.jsx`](https://github.com/jehbath/al-musaid-2.0/blob/main/frontend/src/App.jsx) (Chat interface), [`main.py`](https://github.com/jehbath/al-musaid-2.0/blob/main/main.py) (FastAPI routes), [`application/assistant.py`](https://github.com/jehbath/al-musaid-2.0/blob/main/application/assistant.py) (Request orchestrator), [`application/mcp_client.py`](https://github.com/jehbath/al-musaid-2.0/blob/main/application/mcp_client.py) (MCP tool manager)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_client["Chat interface"]
  node_webapp["Chat interface<br/>[App.jsx]"]
  node_authmodal["Login modal<br/>[AuthModal.jsx]"]
  node_messageformat["Message rendering"]
  node_locationcard["Location cards<br/>[LocationCard.jsx]"]
  node_confirmdialog["Confirm dialog<br/>[ConfirmDialog.jsx]"]
  node_alternateui["Alternate interface<br/>[app2.jsx]"]
  node_api["HTTP client<br/>[api.js]"]
end

subgraph group_api["API and identity"]
  node_backend["FastAPI routes<br/>[main.py]"]
  node_auth["Login endpoint<br/>[auth.py]"]
  node_identity["JWT validation<br/>[dependencies.py]"]
  node_security["Password and tokens<br/>[security.py]"]
  node_conversations["Conversation routes<br/>[conversations.py]"]
end

subgraph group_assistant["Assistant runtime"]
  node_assistant["Request orchestrator<br/>[assistant.py]"]
  node_gemini["Intent and response<br/>[gemini_client.py]"]
  node_memory[("Conversation memory<br/>[memory_manager.py]")]
end

subgraph group_data["Banking data"]
  node_bankdb[("Bank database<br/>[database.py]")]
end

subgraph group_tools["Domain tools"]
  node_rag["Banking knowledge search<br/>[rag.py]"]
  node_knowledge["FAQ knowledge base<br/>[banking_faq.md]"]
  node_mcpclient["MCP tool manager<br/>[mcp_client.py]"]
  node_banktools["Core banking tools<br/>[server.py]"]
  node_currencytools["Currency tools<br/>[server.py]"]
  node_locationtools["Branch and ATM tools<br/>[server.py]"]
end

node_user(("User"))
node_geminiservice{{"Google Gemini"}}

node_user -->|"sends messages"| node_webapp
node_webapp -->|"sends chat"| node_api
node_api -->|"calls endpoints"| node_backend
node_webapp -->|"opens login"| node_authmodal
node_authmodal -->|"requests login"| node_api
node_webapp -->|"renders replies"| node_messageformat
node_webapp -->|"renders locations"| node_locationcard
node_backend -->|"registers routes"| node_auth
node_backend -->|"validates chat identity"| node_identity
node_backend -->|"registers routes"| node_conversations
node_backend -->|"processes chat"| node_assistant
node_auth -->|"looks up user"| node_bankdb
node_auth -->|"verifies password"| node_security
node_identity -->|"loads user"| node_bankdb
node_identity -->|"uses token settings"| node_security
node_assistant -->|"requests decisions"| node_gemini
node_gemini -.->|"generates responses"| node_geminiservice
node_assistant -->|"dispatches tools"| node_mcpclient
node_assistant -->|"searches knowledge"| node_rag
node_assistant -->|"loads conversation state"| node_memory
node_conversations -->|"uses conversation store"| node_memory
node_rag -.->|"searches FAQ"| node_knowledge
node_mcpclient -.->|"dispatches banking tools"| node_banktools
node_mcpclient -.->|"dispatches currency tools"| node_currencytools
node_mcpclient -.->|"dispatches location tools"| node_locationtools
node_banktools -->|"reads banking data"| node_bankdb
node_locationtools -->|"reads locations"| node_bankdb

click node_webapp "https://github.com/jehbath/al-musaid-2.0/blob/main/frontend/src/App.jsx"
click node_authmodal "https://github.com/jehbath/al-musaid-2.0/blob/main/frontend/src/AuthModal.jsx"
click node_messageformat "https://github.com/jehbath/al-musaid-2.0/blob/main/frontend/src/FormattedMessage.jsx"
click node_locationcard "https://github.com/jehbath/al-musaid-2.0/blob/main/frontend/src/LocationCard.jsx"
click node_confirmdialog "https://github.com/jehbath/al-musaid-2.0/blob/main/frontend/src/ConfirmDialog.jsx"
click node_alternateui "https://github.com/jehbath/al-musaid-2.0/blob/main/frontend/src/improvement/app2.jsx"
click node_api "https://github.com/jehbath/al-musaid-2.0/blob/main/frontend/src/services/api.js"
click node_backend "https://github.com/jehbath/al-musaid-2.0/blob/main/main.py"
click node_auth "https://github.com/jehbath/al-musaid-2.0/blob/main/application/auth.py"
click node_identity "https://github.com/jehbath/al-musaid-2.0/blob/main/application/dependencies.py"
click node_security "https://github.com/jehbath/al-musaid-2.0/blob/main/application/security.py"
click node_conversations "https://github.com/jehbath/al-musaid-2.0/blob/main/application/conversations.py"
click node_assistant "https://github.com/jehbath/al-musaid-2.0/blob/main/application/assistant.py"
click node_gemini "https://github.com/jehbath/al-musaid-2.0/blob/main/application/gemini_client.py"
click node_memory "https://github.com/jehbath/al-musaid-2.0/blob/main/application/memory/memory_manager.py"
click node_rag "https://github.com/jehbath/al-musaid-2.0/blob/main/application/rag.py"
click node_knowledge "https://github.com/jehbath/al-musaid-2.0/blob/main/Knowledge_base/banking_faq.md"
click node_mcpclient "https://github.com/jehbath/al-musaid-2.0/blob/main/application/mcp_client.py"
click node_banktools "https://github.com/jehbath/al-musaid-2.0/blob/main/mcp_servers/core_banking/server.py"
click node_currencytools "https://github.com/jehbath/al-musaid-2.0/blob/main/mcp_servers/currency/server.py"
click node_locationtools "https://github.com/jehbath/al-musaid-2.0/blob/main/mcp_servers/location/server.py"
click node_bankdb "https://github.com/jehbath/al-musaid-2.0/blob/main/database/database.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_webapp,node_authmodal,node_messageformat,node_locationcard,node_confirmdialog,node_alternateui,node_api,node_user toneBlue
class node_backend,node_auth,node_identity,node_security,node_conversations toneAmber
class node_assistant,node_gemini,node_memory toneMint
class node_bankdb toneRose
class node_rag,node_knowledge,node_mcpclient,node_banktools,node_currencytools,node_locationtools,node_geminiservice toneIndigo
```

## Components

### Chat interface

- [Chat interface](https://github.com/jehbath/al-musaid-2.0/blob/main/frontend/src/App.jsx): `frontend/src/App.jsx`
- [Login modal](https://github.com/jehbath/al-musaid-2.0/blob/main/frontend/src/AuthModal.jsx): `frontend/src/AuthModal.jsx`
- [Message rendering](https://github.com/jehbath/al-musaid-2.0/blob/main/frontend/src/FormattedMessage.jsx): `frontend/src/FormattedMessage.jsx`
- [Location cards](https://github.com/jehbath/al-musaid-2.0/blob/main/frontend/src/LocationCard.jsx): `frontend/src/LocationCard.jsx`
- [Confirm dialog](https://github.com/jehbath/al-musaid-2.0/blob/main/frontend/src/ConfirmDialog.jsx): `frontend/src/ConfirmDialog.jsx`
- [Alternate interface](https://github.com/jehbath/al-musaid-2.0/blob/main/frontend/src/improvement/app2.jsx): `frontend/src/improvement/app2.jsx`
- [HTTP client](https://github.com/jehbath/al-musaid-2.0/blob/main/frontend/src/services/api.js): `frontend/src/services/api.js`

### API and identity

- [FastAPI routes](https://github.com/jehbath/al-musaid-2.0/blob/main/main.py): `main.py`
- [Login endpoint](https://github.com/jehbath/al-musaid-2.0/blob/main/application/auth.py): `application/auth.py`
- [JWT validation](https://github.com/jehbath/al-musaid-2.0/blob/main/application/dependencies.py): `application/dependencies.py`
- [Password and tokens](https://github.com/jehbath/al-musaid-2.0/blob/main/application/security.py): `application/security.py`
- [Conversation routes](https://github.com/jehbath/al-musaid-2.0/blob/main/application/conversations.py): `application/conversations.py`

### Assistant runtime

- [Request orchestrator](https://github.com/jehbath/al-musaid-2.0/blob/main/application/assistant.py): `application/assistant.py`
- [Intent and response](https://github.com/jehbath/al-musaid-2.0/blob/main/application/gemini_client.py): `application/gemini_client.py`
- [Conversation memory](https://github.com/jehbath/al-musaid-2.0/blob/main/application/memory/memory_manager.py): `application/memory/memory_manager.py`

### Banking data

- [Bank database](https://github.com/jehbath/al-musaid-2.0/blob/main/database/database.py): `database/database.py`

### Domain tools

- [Banking knowledge search](https://github.com/jehbath/al-musaid-2.0/blob/main/application/rag.py): `application/rag.py`
- [FAQ knowledge base](https://github.com/jehbath/al-musaid-2.0/blob/main/Knowledge_base/banking_faq.md): `Knowledge_base/banking_faq.md`
- [MCP tool manager](https://github.com/jehbath/al-musaid-2.0/blob/main/application/mcp_client.py): `application/mcp_client.py`
- [Core banking tools](https://github.com/jehbath/al-musaid-2.0/blob/main/mcp_servers/core_banking/server.py): `mcp_servers/core_banking/server.py`
- [Currency tools](https://github.com/jehbath/al-musaid-2.0/blob/main/mcp_servers/currency/server.py): `mcp_servers/currency/server.py`
- [Branch and ATM tools](https://github.com/jehbath/al-musaid-2.0/blob/main/mcp_servers/location/server.py): `mcp_servers/location/server.py`

### Other components

- **User**
- **Google Gemini**

## Connections

- User → Chat interface: sends messages (evidence: `frontend/src/App.jsx`)
- Chat interface → HTTP client: sends chat (evidence: `frontend/src/App.jsx`)
- HTTP client → FastAPI routes: calls endpoints (evidence: `frontend/src/services/api.js`)
- Chat interface → Login modal: opens login (evidence: `frontend/src/App.jsx`)
- Login modal → HTTP client: requests login (evidence: `frontend/src/AuthModal.jsx`)
- Chat interface → Message rendering: renders replies (evidence: `frontend/src/App.jsx`)
- Chat interface → Location cards: renders locations (evidence: `frontend/src/App.jsx`)
- FastAPI routes → Login endpoint: registers routes (evidence: `main.py`)
- FastAPI routes → JWT validation: validates chat identity (evidence: `main.py`)
- FastAPI routes → Conversation routes: registers routes (evidence: `main.py`)
- FastAPI routes → Request orchestrator: processes chat (evidence: `main.py`)
- Login endpoint → Bank database: looks up user (evidence: `application/auth.py`)
- Login endpoint → Password and tokens: verifies password (evidence: `application/auth.py`)
- JWT validation → Bank database: loads user (evidence: `application/dependencies.py`)
- JWT validation → Password and tokens: uses token settings (evidence: `application/dependencies.py`)
- Request orchestrator → Intent and response: requests decisions (evidence: `application/assistant.py`)
- Intent and response → Google Gemini: generates responses
- Request orchestrator → MCP tool manager: dispatches tools (evidence: `application/assistant.py`)
- Request orchestrator → Banking knowledge search: searches knowledge (evidence: `application/assistant.py`)
- Request orchestrator → Conversation memory: loads conversation state (evidence: `application/assistant.py`)
- Conversation routes → Conversation memory: uses conversation store (evidence: `application/conversations.py`)
- Banking knowledge search → FAQ knowledge base: searches FAQ
- MCP tool manager → Core banking tools: dispatches banking tools
- MCP tool manager → Currency tools: dispatches currency tools
- MCP tool manager → Branch and ATM tools: dispatches location tools
- Core banking tools → Bank database: reads banking data (evidence: `mcp_servers/core_banking/server.py`)
- Branch and ATM tools → Bank database: reads locations (evidence: `mcp_servers/location/server.py`)
