# agentunicorn/banking-fastmcp architecture

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

- Interactive diagram: https://gitdiagram.com/agentunicorn/banking-fastmcp
- Repository: https://github.com/agentunicorn/banking-fastmcp

## Overview

##### File structure
Top-level files & dirs:
- `server.py` & `mcp_server.py` – main entrypoints for HTTP servers
- `routes/` – HTTP route definitions (`healthz.py`, `jwks.py`)
- `middlewares/` – request/response interception (auth, tool_call)
- `services/` – higher-level operations (e.g., auth)
- `tools/` – reusable business-logic functions (banking_tools, util_tools)
- `database/` – ORM models and manager for SQLite
- `configs/` – central config loader
- `import_banks.py` + `data/banks.csv` – offline data-import script
- `jwks.json` – JSON Web Key Set for token verification

##### README
- (No content supplied.) We infer from filenames that this is an internal banking-API microservice with JWT-based auth, a health endpoint, and a one-time data import utility.

##### Elements
- Blue for API & Routing
- Green for Middleware
- Orange for Services & Tools
- Gray for External Systems (e.g., clients, JWKS store)
- Brown for Data Store (SQLite)

##### Detail
- Every directory/module as its own component or subcomponent
- Don’t omit the import utility or config loader—they are crucial for local development and deployment

## Diagram (Mermaid)

```mermaid
flowchart TB
    %% External Entities
    Client["Client (Frontends/Services)"]:::external
    JWKSConsumer["External JWKS Consumer"]:::external

    %% Configuration Module
    subgraph "Configuration"
        ConfigInit["__init__.py"]:::api
        Config["config.py"]:::api
    end

    %% API Servers
    subgraph "API Servers" 
        direction TB
        Server["server.py"]:::api
        MCPServer["mcp_server.py"]:::api
    end

    %% Routing Layer
    subgraph "Routing Layer"
        direction TB
        RoutesInit["__init__.py"]:::api
        HealthRoute["healthz.py"]:::api
        JWKSRoute["jwks.py"]:::api
    end

    %% Middleware Layer
    subgraph "Middleware Layer"
        direction TB
        AuthMW["auth.py"]:::middleware
        ToolCallMW["tool_call.py"]:::middleware
    end

    %% Service Layer
    subgraph "Service Layer"
        direction TB
        AuthService["auth.py"]:::service
    end

    %% Tools Library
    subgraph "Tools Library"
        direction TB
        BankingTools["banking_tools.py"]:::tool
        UtilTools["util_tools.py"]:::tool
    end

    %% Database Manager & Models
    subgraph "Database Module"
        direction TB
        DBManager["manager.py"]:::datastore
        DBModels["models.py"]:::datastore
        SQLiteDB["banking.db"]:::datastore
    end

    %% Data Import Utility
    subgraph "Data Import Utility"
        direction TB
        ImportScript["import_banks.py"]:::api
        BanksCSV["data/banks.csv"]:::datastore
    end

    %% JWKS Store
    JWKSFile["jwks.json"]:::datastore

    %% Connections
    Client -->|"HTTP Request"| Server
    Client -->|"HTTP Request"| MCPServer
    Server -->|"mount routes"| RoutesInit
    MCPServer -->|"mount routes"| RoutesInit
    RoutesInit -->|"includes"| HealthRoute
    RoutesInit -->|"includes"| JWKSRoute

    HealthRoute -->|"pass through"| AuthMW
    JWKSRoute -->|"serve keys or verify"| AuthMW
    AuthMW -->|"calls"| AuthService
    AuthMW -->|"reads config and JWKS"| Config
    AuthMW -->|"reads keys"| JWKSFile
    AuthService -->|"invokes"| BankingTools
    AuthService -->|"invokes"| UtilTools
    AuthService -->|"uses"| DBManager
    DBManager -->|"defines ORM"| DBModels
    DBManager -->|"CRUD on"| SQLiteDB

    ImportScript -->|"loads config"| Config
    ImportScript -->|"reads CSV"| BanksCSV
    ImportScript -->|"uses DB mgr"| DBManager

    JWKSConsumer -->|"fetches keys"| JWKSRoute
    JWKSConsumer -->|"fetches jwks.json"| JWKSFile

    %% Click Events
    click Server "https://github.com/agentunicorn/banking-fastmcp/blob/master/server.py"
    click MCPServer "https://github.com/agentunicorn/banking-fastmcp/blob/master/mcp_server.py"
    click RoutesInit "https://github.com/agentunicorn/banking-fastmcp/blob/master/routes/__init__.py"
    click HealthRoute "https://github.com/agentunicorn/banking-fastmcp/blob/master/routes/healthz.py"
    click JWKSRoute "https://github.com/agentunicorn/banking-fastmcp/blob/master/routes/jwks.py"
    click AuthMW "https://github.com/agentunicorn/banking-fastmcp/blob/master/middlewares/auth.py"
    click ToolCallMW "https://github.com/agentunicorn/banking-fastmcp/blob/master/middlewares/tool_call.py"
    click AuthService "https://github.com/agentunicorn/banking-fastmcp/blob/master/services/auth.py"
    click BankingTools "https://github.com/agentunicorn/banking-fastmcp/blob/master/tools/banking_tools.py"
    click UtilTools "https://github.com/agentunicorn/banking-fastmcp/blob/master/tools/util_tools.py"
    click DBManager "https://github.com/agentunicorn/banking-fastmcp/blob/master/database/manager.py"
    click DBModels "https://github.com/agentunicorn/banking-fastmcp/blob/master/database/models.py"
    click ImportScript "https://github.com/agentunicorn/banking-fastmcp/blob/master/import_banks.py"
    click BanksCSV "https://github.com/agentunicorn/banking-fastmcp/blob/master/data/banks.csv"
    click ConfigInit "https://github.com/agentunicorn/banking-fastmcp/blob/master/configs/__init__.py"
    click Config "https://github.com/agentunicorn/banking-fastmcp/blob/master/configs/config.py"
    click JWKSFile "https://github.com/agentunicorn/banking-fastmcp/blob/master/jwks.json"

    %% Styles
    classDef external fill:#EEEEEE,stroke:#999999
    classDef api fill:#CEE7FF,stroke:#3166BB
    classDef middleware fill:#DFFFE0,stroke:#339933
    classDef service fill:#FFDDAA,stroke:#CC6600
    classDef tool fill:#FFE4B5,stroke:#CC6600
    classDef datastore fill:#E0D3B5,stroke:#996600
```
