How mizcausevic-dev/fintech-regulatory-knowledge-graph works
Purpose and principal workflow: This application serves a seeded fintech regulatory knowledge graph through FastAPI. A browser user or HTTP API client initiates the main workflow by requesting a page or API route; the application reads graph data to summarize entities, explain relationship paths, or produce a JSON-LD export. The dataset is constructed locally at startup, not ingested from an external source.
Components
HTTP callers — Path: null. Browser users request the HTML overview, graph board, and evidence pages; API clients can request graph summaries, filtered entities, paths, and JSON-LD.
FastAPI routes and page rendering — app/main.py. Defines the FastAPI application, HTTP endpoints, and HTML page handlers; page handlers assemble views from graph-service results, while API handlers return service results and translate unknown path entities to 404 responses.
Graph query and export logic — app/services/graph_service.py. Builds an in-memory node index and outbound-edge index from the loaded dataset, then computes summaries, filtered entity lists, breadth-first relationship paths, and JSON-LD output.
Seed graph data — app/data/sample_graph.py. Creates the local graph of regulators, rules, firms, products, obligations, controls, disclosures, and their rationale-bearing relationships.
Graph and response models — app/models.py. Defines Pydantic types and validation for graph nodes and edges, datasets, path steps, summaries, and JSON-LD results.
Downstream consumers — Path: null. The README identifies downstream AI systems and internal compliance tooling as consumers of the machine-readable JSON-LD export; no consumer implementation is present in the tree.
Relationships
• HTTP callers -> FastAPI routes and page rendering: send requests to the documented HTML and API routes.
• FastAPI routes and page rendering -> Graph query and export logic: call summary, entity, path, lead-path, and JSON-LD methods; source: app/main.py.
• Graph query and export logic -> Seed graph data: calls load_sample_graph() when constructing the service singleton; source: app/services/graph_service.py.
• Seed graph data -> Graph and response models: constructs typed nodes, edges, and a dataset; source: app/data/sample_graph.py.
• Graph query and export logic -> Graph and response models: returns typed summaries, paths, and JSON-LD results; source: app/services/graph_service.py.
• Graph query and export logic -> Graph query and export logic: reads its in-memory dataset and indexes to answer queries and build exports; source: app/services/graph_service.py.
• FastAPI routes and page rendering -> Downstream consumers: exposes the JSON-LD data through /api/export/jsonld and the evidence page.
• Downstream consumers -> HTTP callers: consumers can request the documented export endpoint; the repository does not establish a particular deployed consumer or invocation.
Coverage limits: The sampled source omits parts of app/main.py, including application startup details and portions of the page handlers. The repository documents a local run command, but the excerpts do not establish deployment topology, persistent storage, external data ingestion, or an actual downstream AI client.
Main entry points: graph_service.py Graph query service · main.py FastAPI routes · sample_graph.py Seed graph data · models.py Graph response models
Components 6
External actors
- HTTP callers · Browser users and API clients.
- Downstream consumers · AI systems and compliance tools consuming machine-readable exports.
Application
- FastAPI routes · Routes requests to API results and rendered pages.
app/main.py
Graph services and data
- Graph query service · Builds in-memory indexes and answers graph queries.
app/services/graph_service.py - Seed graph data · Constructs the regulatory knowledge graph at startup.
app/data/sample_graph.py - Graph response models
app/models.py
Connections 8
- HTTP callers → FastAPI routes: send requests · Requests documented HTML and API routes.
- FastAPI routes → Graph query service: call queries · Requests summaries, entities, paths, lead paths, and JSON-LD.
- Graph query service → Seed graph data: load dataset · Calls load_sample_graph() when constructing the service singleton.
- Seed graph data → Graph response models: construct typed data · Creates typed nodes, edges, and a dataset.
- Graph query service → Graph response models: return typed results · Returns summaries, paths, and JSON-LD results.
- Graph query service → Graph query service: query indexes · Reads its in-memory dataset and indexes for queries and exports.
- FastAPI routes → Downstream consumers: expose exports · Exposes JSON-LD through the export route and evidence page.
- Downstream consumers → HTTP callers: request exports · Consumers can request the documented export endpoint.