# ashoktallapelli/retail_banking_mcp architecture

> Architecture diagram of the GitHub repository ashoktallapelli/retail_banking_mcp, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2025-08-16). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/ashoktallapelli/retail_banking_mcp
- Repository: https://github.com/ashoktallapelli/retail_banking_mcp

## Overview

##### Project Type and Purpose
- This is a backend‐focused retail banking system written in Python, exposing both a REST API and an MCP (Mainframe Control Program)-style CLI interface for account management and transactions. It persists data in a local SQLite database (`banking.db`).

##### Top-Level Components
a. Clients
- HTTP Clients (Postman, Browser) calling REST endpoints
- MCP CLI tools invoking Python functions directly
b. API Server
- Entry point script (`combined_server.py` or `banking_server.py`)
- Web framework (e.g., FastAPI + Uvicorn) hosting the REST endpoints
- OpenAPI docs at `/docs`
c. Business Logic Layer
- Endpoint handlers in `main.py` or `banking_server.py`
- Transaction and account‐management services
d. Data Access Layer
- `accounts_db.py` implementing CRUD operations against SQLite
e. Database
- `banking.db` (SQLite) with Accounts and Transactions tables

##### Relationships and Data Flow
- HTTP Client → REST API Server
- Client issues HTTP requests → Endpoint handlers
- Handler invokes service logic → Data access layer → SQLite
- Results flow back up to client as JSON
- MCP CLI Tool → Service Layer
- MCP calls Python functions (`mcp_open_new_account()`, etc.)
- These functions map directly to the same service and DAO code paths
- All mutations and reads go through `accounts_db.py` to `banking.db`

##### Architectural Patterns and Principles
- Layered Architecture: Presentation (API & MCP interface) → Business Logic → Data Access → Persistence
- Single-service, single-database, no distributed microservices
- Clear separation of concerns and single responsibility per module

##### Technologies and Frameworks
- Python 3.x
- FastAPI (or similar) + Uvicorn for REST API
- MCP Python interface for CLI tooling
- SQLite (`banking.db`) as embedded persistence
- SQLAlchemy or raw `sqlite3` in `accounts_db.py`

## Diagram (Mermaid)

```mermaid
flowchart TD
    %% External Actors
    HTTPClient["HTTP Client"]:::external
    MCPUser["MCP CLI User"]:::external

    %% Interface Layer
    subgraph "Interface Layer"
        APIServer["API Server"]:::backend
        OpenAPI["OpenAPI Docs (/docs)"]:::backend
        MCPInterface["MCP Interface"]:::backend
    end

    %% Business Logic Layer
    BusinessLogic["Business Logic Module"]:::backend

    %% Data Access Layer
    DataAccess["Data Access Module"]:::backend

    %% Persistence
    SQLiteDB[("SQLite DB\nbanking.db")]:::db

    %% Connections
    HTTPClient -->|"HTTP request/response"| APIServer
    APIServer -->|"invokes endpoints"| BusinessLogic
    APIServer -->|"serves /docs"| OpenAPI
    MCPUser -.->|"MCP call"| MCPInterface
    MCPInterface -->|"direct function call"| BusinessLogic
    BusinessLogic -->|"SQL CRUD"| DataAccess
    DataAccess -->|"reads/writes"| SQLiteDB

    %% Click Events
    click APIServer "https://github.com/ashoktallapelli/retail_banking_mcp/blob/main/banking_server.py"
    click APIServer "https://github.com/ashoktallapelli/retail_banking_mcp/blob/main/main.py"
    click BusinessLogic "https://github.com/ashoktallapelli/retail_banking_mcp/blob/main/main.py"
    click DataAccess "https://github.com/ashoktallapelli/retail_banking_mcp/blob/main/accounts_db.py"
    click SQLiteDB "https://github.com/ashoktallapelli/retail_banking_mcp/blob/main/banking.db"

    %% Styles
    classDef backend fill:#ADD8E6,stroke:#000,stroke-width:1px
    classDef db fill:#90EE90,stroke:#000,stroke-width:1px
    classDef external fill:#FFA500,stroke:#000,stroke-width:1px
```
