How yumjiin/bank-ontology-layer works
Bank Ontology Layer lets users ask banking-data questions through an LLM agent, which uses constrained ontology tools rather than writing SQL. The service exposes ontology description, object and linked-object searches, metric calculations, role-based masking/filter restrictions, and approval-governed actions; it also records agent traces. Ontology metadata drives SQL compilation and query execution against PostgreSQL. The README documents the overall app-to-agent-to-service-to-database flow. Some detailed runtime links are supported only by the shown excerpts or README; unsampled subsystems are represented without speculative internal call chains.
Main entry points: main.py FastAPI endpoints · query.py Query execution · actions.py Action approvals · seed.py Data seeding
Components 18
Demo and agent
- Streamlit demo
app/streamlit_app.py - Agent loop
agent/loop.py - Tool definitions
agent/tools.py - LLM client
agent/llm.py
Ontology service
- FastAPI endpoints
service/main.py - Request schemas
service/schemas.py - Ontology definitions
ontology/ontology.yaml - Metadata loader
service/metadata.py - SQL compiler
service/compiler.py - Query execution
service/query.py - Role policies
service/policy.py - Action approvals
service/actions.py
Bank data
- PostgreSQL
- Database schema
data/schema.sql - Mock data generator
data/reference/generate_mock_data.py - Data seeding
data/seed.py
External systems
- OpenAI API
Other components
- User
Connections 22
- User → Streamlit demo: asks
README.md - Streamlit demo → Agent loop: invokes
app/streamlit_app.py - Agent loop → LLM client: requests completion
agent/loop.py - LLM client → Tool definitions: sends tools
agent/llm.py - Agent loop → Tool definitions: executes tools
agent/loop.py - LLM client → OpenAI API: calls
agent/llm.py - Tool definitions → FastAPI endpoints: routes requests
agent/tools.py - FastAPI endpoints → Request schemas: validates requests
service/main.py - FastAPI endpoints → Metadata loader: loads ontology
service/main.py - Ontology definitions → Metadata loader: defines metadata
README.md - FastAPI endpoints → Query execution: dispatches queries
service/main.py - FastAPI endpoints → Action approvals: dispatches actions
service/main.py - Query execution → SQL compiler: compiles queries
service/query.py - Query execution → Role policies: checks and masks
service/query.py - Action approvals → SQL compiler: compiles target lookup
service/actions.py - Action approvals → Role policies: checks roles
service/actions.py - Query execution → PostgreSQL: executes SQL
service/query.py - Action approvals → PostgreSQL: reads and writes
service/actions.py - Data seeding → Mock data generator: builds data from
data/seed.py - Data seeding → Database schema: applies schema
data/seed.py - Data seeding → PostgreSQL: loads records
data/seed.py - FastAPI endpoints → PostgreSQL: stores traces
service/main.py