A dual-pipeline bank responsibility platform utilizing a LangGraph multi-agent network. Features background automation cron loops and real-time interactive SSE chat streaming with state retention.
This repository houses an enterprise-grade compliance intelligence backend built to map shifting financial regulations, banking laws, and corporate governance guidelines directly to corporate roles and institutional targets [finance].
The platform departs from rigid, unmanaged linear LLM wrappers by deploying a State-Managed Multi-Agent Network built on top of LangGraph. The system splits workloads into two distinct operational execution layers:
- Background Automation Pipeline (
run_cron.py): A non-interactive batch process triggered by external OS daemons (e.g., Linux crontab) to scrape legislative updates, evaluate role impacts, and flag compliance vulnerabilities. - Interactive Auditing Cockpit (
api.py): An asynchronous FastAPI engine providing real-time communication via Server-Sent Events (SSE). It retains conversation states across graph execution nodes, streaming deterministic, RAG-enriched reasoning paths directly to compliance officers under high concurrency.
The backend establishes an event-driven network pipeline to process incoming multi-variable request states and push dynamic token streams back to the client interface.
- The Engineering Problem: Complex regulatory matching across massive legal frameworks takes considerable time. Standard synchronous REST APIs keep client sockets hanging, leading to high timeouts, poor UI performance, and severe thread blocking on the corporate server.
- The Solution: Leveraged LangGraph's asynchronous graph engine combined with FastAPI's
StreamingResponseto create an explicit Server-Sent Events (SSE) pipe. By using.astream(..., stream_mode="values"), the system tracks variable mutations across node execution boundaries in real time, converting final analytical tokens into structured JSON payloads (text/event-stream) and pushing them down the port pipe instantly to eliminate latency.
- The Architectural Advantage: Instead of running unmanaged linear structures, the graph acts as an isolated state machine tracking multi-variable contexts concurrently:
- Global Structural Triggers:
updated_law_ids,updated_laws_target_users,updated_law_changes. - Target Verification Trackers:
target_id,target_name,target_classification,target_law_changes,target_knowledge. - History Retention:
target_last_responsemaps conversation state chains directly into the graph context to preserve structural continuity and state retention.
- Global Structural Triggers:
- The Execution Advantage: Incorporates a modular background syncing process (
run_cron.py). It utilizes native OS return parameters (sys.exit(1)) to plug seamlessly into Linuxcrontab, Kubernetes CronJobs, or Apache Airflow schedulers, enabling headless batch synchronization without manual microservice interference.
The backend translates internal utility helpers directly into deterministic state execution blocks as outlined in schema.txt:
preprocessing_law_changes+fetch_law_change_http➔ Feedsfetch_law_changes_nodeget_db_connection➔ Feedsfetch_target_users_node(Identifies target compliance roles)notification➔ Feedssend_notifications_node(Dispatches alerts)
IntentSchema+get_local_llm➔ Feedsclassify_intent_node(Routes execution)- Classification 1 ➔ Routes to
fetch_law_list_node - Classification 2 ➔ Routes to
fetch_specific_law_node➔analyze_law_changes_node(LLM Analysis) - Classification 3 ➔ Routes to
fetch_all_laws_node➔analyze_law_changes_node(LLM Analysis) - Classification 4 ➔ Routes to
generate_optimized_search_query_node➔retrieve_rag_context_node➔analyze_todo_list_node - Classification 5 ➔ Routes to
fallback_router_node
BankResponsibilityMapping/
│
├── api.py # Master FastAPI application & SSE Streaming Endpoint
├── agent_graph.py # Compiled LangGraph Multi-Agent State Machine workflow
├── state.py # Pydantic data schema defining the unified AgentState
├── nodes.py # Independent functional multi-agent logical execution nodes
├── run_cron.py # Production batch synchronization engine (Background automation)
├── schema.txt # Structural blueprint mapping helper functions to core execution nodes
├── static/ # Local directory housing native UI front-end assets
│ └── index.html # Core dashboard interface index entry point
├── .gitignore # Explicitly masks virtual environments, cache files, and logs
├── requirements.txt # Verified production-grade package dependency stack
└── LICENSE # MIT open-source certificationEnsure your local Linux or WSL2 terminal environment is active, then initialize your runtime dependencies:
# Clone the repository
git clone https://github.com/kb0422bk/PythonAgentAI_ResponsibilityMapping
cd BankResponsibilityMapping
# Initialize and launch the virtual environment
python3 -m venv .venv
source .venv/bin/activate
# Install the verified performance packages
pip install fastapi uvicorn langgraph langchain pydantic python-dotenvDeploy the asynchronous server daemon via Uvicorn. Bind it natively to your private local network host IP to open up internal compliance access ports:
# Fire up the Uvicorn live-reloading daemon
uvicorn api:api_app --host 0.0.0.0 --port 0000 --reloadThe server will initialize your LangGraph state models, mount the static visual directories, and listen for inbound network streaming blocks at http://0.0.0.0:0000.
# Trigger the batch automation flow manually
python run_cron.pyDistributed under the MIT License. See LICENSE for more information.